Open dkebler opened 4 years ago
made an issue at nodejs https://github.com/nodejs/node/issues/33795 and also a repo to demonstrate https://github.com/dkebler/core-esm-named-import-error
That was kinda of the danger of using esm before the commonjs interop was officially defined by node. And unfortunately until packages update to have real named exports, you will have to update your imports like you've done above.
I'm hoping to get some help here from the experts although it's technically not a std/esm issue. I am attempting move away from std/esm and use the "native" esm in V14.
The issue I am having is that unlike std/esm the native version is breaking the named imports (from I assume commonjs module exports) that worked fine with std/esm.
Take for example https://github.com/sindresorhus/make-dir/blob/978bee9186bf0c41640ed21567921daf8c303225/index.js#L106
I have in my package the import
import { sync as mkdir } from 'make-dir'
which works fine in std/esm. But using native it says it can't find the named exportsync
.Am I stuck here? Do I need to stay with std/esm? (but it looks like the project is over now) I can't/shouldn't go through my entire code base accommodating cjs modules with
Also if I add to any package.json
"type":"module"
and run with std/esm it throws errors so it looks like I can't mix these.Anyway was under the assumption that the native was going to be a drop in replacement for using std/esm. Apparently not :(.
I made a stack overflow post of this. Maybe best to reply there? https://stackoverflow.com/questions/62088912/std-esm-vs-native-esm-in-node-v14-cant-find-named-import-from-cjs-modules