Skip to content
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

std/esm vs native esm in V14 #880

Open
dkebler opened this issue May 29, 2020 · 2 comments
Open

std/esm vs native esm in V14 #880

dkebler opened this issue May 29, 2020 · 2 comments

Comments

@dkebler
Copy link

dkebler commented May 29, 2020

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 export sync.

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

import mk from 'make-dir'
const mkdir = mk.sync

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

@dkebler
Copy link
Author

dkebler commented Jun 8, 2020

made an issue at nodejs nodejs/node#33795
and also a repo to demonstrate https://github.com/dkebler/core-esm-named-import-error

@jsg2021
Copy link
Contributor

jsg2021 commented Jul 24, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants