-
-
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
Recent versions of vite-node
fail to execute a script when ESM is imported
#1208
Comments
msw doesn't have More about dual-packaging: https://github.com/sheremet-va/dual-packaging I would recommend adding "exports" field, because "module" field is not respected. |
👍 Will do! Also, thanks for the dual-packaging example. In my opinion, the behaviour around CJS and ESM is quite tricky to get working, and your explanation definitely helps me! Side question though, I'm trying to understand if the recent changes were expected or not. Since it's working with versions below |
Previously We try not to transform code inside We have two important options to fix this
|
Overall, ESM/CJS compatibility is a catastrophe :) Because a lot of the packages relly on how bundlers treat esm (with "module" field) instead of rellying on the current standard ("exports" field with correct file extensions). |
Deeply appreciate the explanation! 🙇♂️
Is there a way to configure these for |
Actually, you are correct! Unfortunately, right now it doesn't support this. But I don't see why we shouldn't allow it. PR welcome :) |
Aaaand, PR is here: #1215! |
Describe the bug
TLDR;
vite-node
higher than0.8.5
fails to run a script where ESM is imported.I'm using
vite-node
to execute some code that relies on several dependencies. One of those dependencies (in my casemsw
) provides both ESM and UMD bundles. When executing the script,vite-node
imports the ESM bundle, and immediately crashes.The script works fine when running
[email protected]
, but fails with any higher version. I believe that the turning point is the c4a25ae commit, where some checks to inline dependencies where removed.Reproduction
https://github.com/antoinerey/vite-node-reproduction-esm-import
System Info
System: OS: macOS 12.0.1 CPU: (8) x64 Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz Memory: 104.10 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.0.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.6.0 - /usr/local/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Browsers: Brave Browser: 100.1.37.116 Chrome: 101.0.4951.41 Firefox: 98.0.1 Safari: 15.1 npmPackages: vite-node: ^0.10.0 => 0.10.0
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: