-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Re: Re: Move to ESM #106
Merged
Merged
Re: Re: Move to ESM #106
Conversation
This file contains 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
mizdra
added
Type: Breaking Change
Includes breaking changes
Type: Maintenance
Repository Maintenance
labels
Dec 27, 2021
It works! It's perfect... |
mizdra
force-pushed
the
use-module-node12-3
branch
from
December 27, 2021 17:39
d6e4cc4
to
d20f879
Compare
mizdra
changed the title
Re-re-challenge: Use
Re: Re: Use Dec 28, 2021
module: node12
in tsconfig.json
module: node12
in tsconfig.json
BREAKING CHANGES: drop node `< 14.3.1`
… of `tsconfig.json`
- `dist/index.js` does not exist before `yarn run build` - So if lint `bin/` before `yarn run build`, the error of `import/no-unresolved` occurs
mizdra
force-pushed
the
use-module-node12-3
branch
from
December 28, 2021 16:25
d20f879
to
19016e1
Compare
mizdra
changed the title
Re: Re: Use
Re: Re: Move to ESM
Dec 28, 2021
module: node12
in tsconfig.json
Everything is ready to go. We're moving forward! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
ref: #84, #85
BREAKING CHANGES
< 14.3.1
Tasks
Phase 1: Read guides
The conversion to ESM can cause a lot of BREAKING CHANGES. Also, support for various toolchains is partial. I will read this guide and check if I can really convert eslint-interactive to ESM and not have any problems.
14.13.1
.Phase 2: Check support status of toolchains
At this time, many toolchains have partial support for ESM. While many applications can be converted to ESM, some may not be able to be converted due to lack of support in the toolchain. Therefore, it is necessary to check the support status of various toolchains.
typescript@nightly
.typescript
is devDeps, so there was no problem.jest.requireActual
is not yet supported in ESM.jest.requireActual
, or remove the tests.Phase 3: Setup
Add some basic configs.
"type": "module"
inpackage.json
: 1d0756dtypescript@nightly
: cae48aa"module": "node12"
and"moduleResolution": "node12"
oftsconfig.json
: 03e2117Phase 4: Fix type errors
Fix type errors by checking the results of
yarn run lint:tsc
.import ... from './path/to/module';
toimport ... from './path/to/module.js';
: 888b431import ... from './path/to/dir';
toimport ... from './path/to/dir/index.js';
: bfd8558index.js
.import ... from '...';
).import ... = require('...')
syntax: ab398aa, be4d269require
Phase 5: Fix lint errors
Fix lint errors by checking the results of
yarn run lint:eslint
..eslintrc.js
to.eslintrc.cjs
: b8cfc2eimport/no-unresolved
rule: 9e91c7cpkg.exports
..cjs
,.mjs
,.cts
and.mts
as lint targets: 36e4c54, d97a2b4*.cts
and*.mts
eslint-config-mizdra#108Phase 6: Fix runtime errors
Fix runtime errors by checking the results of
yarn run dev
..js
) to the path in thebin
field ofpackage.json
: a932cb1TypeError: Unknown file extension "" for /Users/mizdra/src/github.com/mizdra/eslint-interactive/bin/eslint-interactive
--input-type=module
to shebang looks like it should work, but it doesn't. We have to add an extension."type": "module",
is specified nodejs/node#34049__dirname
todirname(fileURLToPath(import.meta.url))
: 6db3b65__dirname
is not supported in ESMmodule.exports
: 0a980admodule.exports
in some packages to support both CJS/ESM.module.exports
is not supported in ESM.fixtures/
CJS: bca4371fixtures/
must be treated as CJS.fixtures/package.json
with{"type": "commonjs"}
.fixtures/
as CJS.Phase 7: Fix tests
Fix tests by checking the results of
yarn run test
.jest.config.js
tojest.config.mjs
: cdc1672pkg.exports
.jest-resolve
jestjs/jest#9771 (comment)import { jest } from '@jest/globals';
: deea149, 7683a9djest
objects are not automatically assigned.globalThis.jest
is used, it causesReferenceError: jest is not defined
.import { jest } from '@jest/globals';
.jest.requireActual
with another solutions: 009081e, 45b5015jest.requireActual
is not yet supported in ESM..cjs
,.mjs
,.cts
and.mts
as coverage targets: 2b4bd5ePhase 8: Refactor codes
Refactoring bad code.
comlink
provides an ESM module (ex.comlink/dist/esm/node-adapter.mjs
)comlink
also provide type definitions (ex.comlink/dist/esm/node-adapter.d.ts
)xxx.mjs
isxxx.d.mts
in"module": "node12"
modepaths
option oftsconfig.json
to forcexxx.mjs
to be mapped toxxx.d.ts
.Phase 9: Confirm operation
npm pack
npm install -D xxx.zip
TODO
comlink