-
-
Notifications
You must be signed in to change notification settings - Fork 0
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: Invalid ESM-style import of ./visit
#12
Comments
@tvsbrent https://nodejs.org/api/esm.html#esm_enabling
|
Unfortunately, a dependency that references this library, @uiw/react-markdown-preview, is importing this in one of our projects that has not yet converted to ESM. This is causing our Webpack builds to fail with this error:
It seems that Node knows this is module is defined as an EcmaScript Module, but wants to enforce the file extension. For the time being, I've pinned our version of the markdown library to the last version that referred to the 1.x version of this dependency. |
or |
That is what I'm doing currently, however, I am having to do this with the dependency referring to your module. I'll let the authors of that library know and maybe they can come up with a better solution. |
One thing I thought worth mentioning, if you look at one of the repos for the author of the guide you referenced above, you'll see he is including https://github.com/sindresorhus/got/blob/main/source/index.ts#L1-L3 |
According to this issue in TypeScript, you need to write the import as you want it to appear in the JS: So, as I understand the recommendation, you need to write |
Saw that you just did a release and I tried the above repro steps, and the module imported successfully. Thanks for the fix! |
@tvsbrent thx! |
Repo:
1.) In an existing project, run
npm install rehype-rewrite@2.0.1
2.) With Node 14 installed, from the command line run
node --experimental-repl-await --experimental-modules
3.) In the Node REPL, run the following code:
let rehypeRewrite = await import('rehype-rewrite')
Results:
The following error message is displayed:
Notes:
My guess is that the TypeScript compilation is not adding the needed
.js
extension to the generated code.The text was updated successfully, but these errors were encountered: