Skip to content

Conversation

@lwasser
Copy link
Member

@lwasser lwasser commented Feb 11, 2026

closes #407

THIS pr migrates teh build configuration from kcd-scripts to native babel.

What:

I created a simple migration and removed some babel dependencies that kcd-scripts uses in the project that i think we don't need. i documented it in the development.md in case i made some false assumptions.

I just reviewed the migration plan i had in the issue and I do still need to check npm validate !
Why:

How:

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

"scripts": {
"add-contributor": "kcd-scripts contributors add",
"build": "kcd-scripts build",
"build": "babel src --out-dir dist --copy-files && find dist -type d -name '__tests__' -exec rm -rf {} + 2>/dev/null; find dist -type d -name '__snapshots__' -exec rm -rf {} + 2>/dev/null; true",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this. Somehow in the original build, the tests and snapshots were removed from the output dist. but i couldn't figure out where that happened in the kcd workflow so this is bash. we could create a .sh script but i wondered if anyone knew of a better way to configure babel to ignore tests.

- **Purpose:** Preset that compiles modern JS to match a target environment
(e.g. Node 22). Handles syntax and, optionally, module format.

- **@babel/plugin-transform-runtime**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seemed like a nice thing to make the dist just a tiny bit smaller?

`require('@babel/runtime/...')` so helpers live in one place. Keeps dist
smaller and avoids duplicating helper code in every file.

- **@babel/plugin-transform-modules-commonjs**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be abel to skip transpiling (i think?) if we implement #435

preset-env is set with `modules: false`; if preset-env uses
`modules: 'commonjs'`, this plugin is redundant.

- **@babel/plugin-transform-class-properties**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not carefully look at ALL of the code for classes so i could have missed something here?

that `@babel/plugin-transform-runtime` injects imports for. Required at
runtime when using that plugin.

IMPORTANT: there are still 2 bugs in the cli that i don't want to fix in this PR
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These bugs arose as well in #421 @jdalrymple opened!! they must just be on main right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix seemed to fix the function! but i don't add scope creep or tests to this pr!

async function addContribution(argv) {
  // ensure the config file exists and merge config into argv (repoType, contributors, etc.)
  const config = await util.configFile.readConfig(argv.config)
  Object.assign(argv, config)

  const username = argv._[1] === undefined ? undefined : String(argv._[1])
  const contributions = argv._[2]

  // Add or update contributor in the config file
  const data = await updateContributors(argv, username, contributions)

  argv.contributors = data.contributors

  await startGeneration(argv)

  // Commit if configured
  if (argv.commit) {
    return util.git.commit(argv, data)
  }
}

[
'@babel/preset-env',
{
targets: {node: '22.22.0'},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22.22 was an arbitrary value that i think i added to our package.json. should we "floor" it to 22.00 and update the package.json? what is best practice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KCD Migration(build): migrate build system --> native babel configuration

1 participant