-
Notifications
You must be signed in to change notification settings - Fork 44
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 to ESM module #48
Merged
Merged
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
Upgrading the version for `terminal-size`, which forces us to switch to ESM and bump the min node version to 18. I got the build to work with esbuild using --format=esm. Also realized that we can remove the `bin/git-split-diffs` file and instead directly specify `index.mjs` in the `bin` field in `package.json` after inserting a shebang line at the top using esbuild. The stuff that doesn't work is: - `yarn benchmark`, likely because the `benchmark` lib generates the module in weird way that conversion to ESM doesn't work. I should find a more modern benchmarking lib. - `yarn test` fails because jest and ts-jest's ESM support seems kind of finicky.
- For benchmark, just needed to declare `benchmark` as external for esbuild - For tests, node needs to be invoked specially (https://jestjs.io/docs/ecmascript-modules) and `ts-jest` needs to be configured differently
Now that we can handle ESM-only modules, switch to the `shikiji` package, which at least supports lazy loading languages. I measured a small speedup of 40ms, which is lower than what I was expecting.
`ansi-regex` and `chalk` are ESM only, which we can now handle. Esbuild can also now bundle them into the output.
Didn't realize I was still on yarn 1. Used `yarn patch` to add the fix from antfu/shikiji#66.
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.
This converts the package to generate an ESM module as the build output. The instigator was #39 but there were a number of ESM-only packages in the dependencies. The final result is as follows:
term-size
toterminal-size
and upgradedansi-regex
,chalk
anddiff
.setTheme
from shiki.yarn
tonpm
.yarn v4
does pretty weird things that were hard to get to work esp on windows.