-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Unexpected top-level await error
for type: module
+ top level await in node_modules
#552
Comments
Thanks for the bug report @JounQin tsx supports loading ESM in Node's CommonJS mode by compiling it to CommonJS syntax... so if a module file (.mjs or Looking at Prettier's code, it looks like it tries node --import tsx/esm scripts/test This way, the Since it catches the By the way, if you have any sway in how Prettier loads the config files, the new It's being experimented in ESLint via eslint/eslint#18440 |
Acknowledgements
Minimal reproduction URL
https://github.com/JounQin/test/tree/tsx
Version
4.10.1
Node.js version
v20.11.0
Package manager
yarn
Operating system
macOS
Problem & expected behavior (under 200 words)
prettier@v3
is a dual package, I havetype: module
in mypackage.json
, it should be run in ESM module, and it will resolve its own configs withimport()
,@1stg/prettier-config
is a pure ESM package with top level await used, it should just work without runtime exceptionBut it just throws like the following:
I'm not for sure why
node_modules
packages are also transformed byesbuild
, is that expected to be transformed or configurable?Contributions
The text was updated successfully, but these errors were encountered: