-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug w/ named exports #1469
Comments
This is because your code is actually transformed to CJS format independently by esbuild-register. You may search the source code to see why it happens. In fact, if you can bundle them all and run instead of let esbuild-register transform each file, the result will be the same as |
@hyrious thank you, yes, you are correct; the problem is with esbuild-register.
I tried the tool you created @hyrious/esbuild-dev and it doesn't have this issue. I'll be using it, thank you very much! On a side note, imho, the only missing feature in the tool you created is it needs a predefined script (with
|
The Maybe you will be interested in creating such register by yourself. |
@o-alexandrov I found another transformer loads esm, maybe you could give it a try: https://github.com/antfu/esbuild-node-loader |
@hyrious thank you, I need the preloaded module to return |
Please find a reproduction of this bug here:
The complete code sample there is 2 files:
There are two npm scripts:
nodejs
&esbuild
.When you run
npm run nodejs
, you'd see the following output in the console:whereas when you run
npm run esbuild
, the CLI output is:default
valueAs you could see above,
esbuild
provides a different output than plain Node.js either withesm
to transpile JS, or by running against.mjs
files.Originally posted by @o-alexandrov in #532 (comment)
The text was updated successfully, but these errors were encountered: