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
build esm files to separate folder #684
Conversation
putting |
@alangpierce WDYT? I've published my change as |
Benchmark resultsBefore this PR: 334.2 thousand lines per second Measured change: 0.51% slower (0.66% slower to 0.76% faster) |
Codecov Report
@@ Coverage Diff @@
## main #684 +/- ##
==========================================
+ Coverage 82.59% 82.67% +0.07%
==========================================
Files 56 56
Lines 5694 5932 +238
Branches 1343 1343
==========================================
+ Hits 4703 4904 +201
- Misses 708 745 +37
Partials 283 283
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
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.
Hi @nihgwu , thanks for the PR! And sorry for the delay, I've had my hands full with other life things, but trying to get back to open source work now.
As you can tell, the current ESM structure was added when the best practices were all a bit speculative, so happy to restructure it in a way that works better. I was a little worried about people relying on the .mjs
or .d.ts
files in the old directory structure, but that seems pretty unlikely, and even so, it's not part of the public interface for the library, so it should be fine to change without a semver-major bump.
Changing getVersion
to a hard-coded string sounds good. I'll probably drop that function in a 4.0 release at some point.
There's a test failure that I already fixed on the main
branch, so I'll merge anyway and cut a release.
Just published this as 3.21.0 |
thanks @alangpierce 👏🏻 |
@alangpierce Thank you so much, I'll give it a shot right away UPDATE: It works like a charm, thank you again for your great work, I love your package so much, that's just what I dreamed for a modern builder |
Co-authored-by: Neo Nie <gongwu.nie@revolut.com>
I build a package based on
sucrase
and the current folder structure has raised lots of problem, I've tried my best to workaround them without touchingsucrase
, but now I think it's impossible.The current folder structure doesn't work for ESM as
mjs
extension is required by Node for importing an ESM file, whilesucrase
doesn't, so for webpack5 we have to addresolve.fullySpecified: false
as a workaround, and foresbuild
probably we need other workaround evanw/esbuild#2128 (comment), but for some build tools they don't expose the way to config esbuild, like Remix, Vite supports partially and doesn't change that config, so only alias to cjs version works for Vite, but there is no way to do that in RemixSo the case is that, even we import
sucrase/dist/index.mjs
, esbuild will importNameManager.js
instead ofNameManager.mjs
, while webpack will importNameManager.mjs
even we import fromsucrase/dist/index.js
After this change, we don't need any workarounds to make it work properly in the frontend world, and it won't break the Node environment as the current mjs file importing is wrong and doesn't work
I didn't move cjs files to
cjs
folder on purpose, in case some one would import the sub files manually