-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Convert package to ESM #35
Comments
You don’t need type:module at all; that’s only if you want .js files to be ESM (which will break back compat and a number of tools). I’d suggest using .mjs for ESM instead. |
We want .JS files to be ESM. |
Just a note that due to there being a number of dynamic |
Another question raised is whether you want to change the files which export objects like: module.exports = {
method1,
method2
}; ...into named exports (as can support tree-shaking) like: export{
method1,
method2
}; ...even though one technically could continue to export as a default object like: export default {
method1,
method2
}; |
We can’t change methods to be async because these APIs are frozen. If that’s a blocker for this effort, then so be it. Ultimately this package will be used infrequently once the new config system is in place, so it’s a lower property to convert. |
Yeah, ok, appears it will be a blocker then. |
Wait, maybe need to take another look as it may be requiring JSON which could be safely read synchronously. |
No, it looks like at least |
Could we use |
Oh, wonderful. I had just associated that mentally as a workaround for JSON. :-) Will see if I can complete the work then. |
This would presumably mean that the parser and plugins could not be expressed themselves (without a build step) as ESM yet though. |
For the cases where some |
Presumably no dependencies would eliminate CJS without a major version change, so I think we are safe using I think it's probably safe to use |
* Breaking: Switch to ESM * Fix: CJS changes * Fix: Though tests in prev. commit passed, change all CJS to cjs extension, except tests/fixtures/rules/make-syntax-error-rule.js given that ModuleResolve uses the Node Resolution Algorithm * Fix: Rollup did not like requiring of default module.exports (without a plugin at least), so create require * New: Add exports; also update devDeps. specify external modules in Rollup config, and align it with eslint-scope * Fix: Add `dist` file * Fix: We can use cjs for our final file after all * Test: CommonJS * Refactor: Drop Node overrides while still using non-ESM config * Refactor: Drop `Module.createRequireFromPath` * Test: Supply Node version which won't fail with dev. * Fix: Windows needs file: for absolute URLs * Refactor: Remove line break * Fix: Convert further paths to file: imports for Windows * Fix: Point `main` to CJS for older browsers * Chore: update devDeps * Update .github/workflows/ci.yml Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update tests/_utils/index.js Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update package.json Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Refactor: Switch two of the `conf` files to ESM Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
To convert this package from CommonJS to ECMAScript modules (ESM):
type: module
topackage.json
lib
to ESMtests/lib
to ESMbuild
script inpackage.json
to generate CommonJS file (.cjs
) indist
directory (use Rollup)dist
to.gitignore
build
inprepare
script inpackage.json
to ensure build is run at key momentspackage.json
so thatmain
points in the CJS file indist
andexports
provides bothrequire
andimport
optionsThe text was updated successfully, but these errors were encountered: