fix(plugin-manifest-validator): migrate dev environment to ESM#3837
Open
nameless-mc wants to merge 2 commits into
Open
fix(plugin-manifest-validator): migrate dev environment to ESM#3837nameless-mc wants to merge 2 commits into
nameless-mc wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates @kintone/plugin-manifest-validator’s development/tooling environment to ESM while preserving the published dist/ output as CommonJS to avoid breaking existing CJS consumers.
Changes:
- Set
"type": "module"for the package to author/tool as ESM. - Add a post-build step to generate
dist/package.jsonwith{ "type": "commonjs" }so Node treats emitteddist/as CJS under an ESM package root. - Remove the unused legacy
babel.config.jsthat would be incompatible under ESM.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/plugin-manifest-validator/script/write-cjs-pkg.ts | New build helper to write a dist/package.json CJS marker. |
| packages/plugin-manifest-validator/package.json | Mark package as ESM and run the new CJS marker generation after build. |
| packages/plugin-manifest-validator/babel.config.js | Remove unused Babel config incompatible with ESM package root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Set "type": "module" so the package is authored and tooled as ESM, while
keeping the build output in dist/ as CommonJS. A generated dist/package.json
marker ({"type":"commonjs"}) lets Node treat the emitted output as CJS even
under the ESM root, so existing CJS consumers (e.g. @kintone/plugin-packer)
keep working with require() on Node < 22.
- Add "type": "module" to package.json
- Add gen-cjs-pkg build step (script/write-cjs-pkg.ts) writing the dist marker
- Exclude **/dist/** from the pnpm workspace so the generated dist/package.json
marker is not picked up as a phantom workspace package (mirrors the existing
lib/esm exclusions)
- Remove dead babel.config.js (CJS, leftover from the jest era; unused since
the vitest migration and would break under "type": "module")
c1f7615 to
aff492d
Compare
write-cjs-pkg: mkdir dist (recursive) before writing the marker so the script also works when run on its own, not only as the postbuild step after tsc has already created dist/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Align
@kintone/plugin-manifest-validatorwith the kintone frontend tech standard by making its development environment ESM, while keeping the published output as CommonJS so existing consumers are unaffected.What
"type": "module"so the package is authored and tooled as ESM.dist/as CommonJS (tsconfig staysmodule: commonjs). A generateddist/package.jsonmarker ({"type":"commonjs"}, written byscript/write-cjs-pkg.ts) lets Node treat the emitted output as CJS even under the ESM root, so CJS consumers such as@kintone/plugin-packerkeep working withrequire()on Node < 22.babel.config.js(CJS, leftover from the jest era; unused since the vitest migration and would break under"type": "module").How to test
pnpm build/pnpm test/pnpm lint@kintone/plugin-packerstill builds and its tests pass against this change.