-
Notifications
You must be signed in to change notification settings - Fork 147
chore: migrate build/ babel to native configuration #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| "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", |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'}, |
There was a problem hiding this comment.
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?
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: