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

Support Node.js ES Modules #6

Open
adamhenson opened this issue Oct 8, 2020 · 2 comments
Open

Support Node.js ES Modules #6

adamhenson opened this issue Oct 8, 2020 · 2 comments

Comments

@adamhenson
Copy link
Collaborator

adamhenson commented Oct 8, 2020

Node.js now supports ES Modules. We should support it by exporting both CommonJS and ES modules as outlined in this article and this one.

I attempted this and got pretty far until I reached a blocker in which you need to explicitly define file extensions in the Node.js implementation as described in this issue (see below).

Allowed

import myModule from './myModule.js'

Not allowed

import myModule from './myModule'

Once this issue is addressed in Node.js, we can proceed with this support.

@jacogr
Copy link

jacogr commented Dec 16, 2020

Sorry for barging in... :)

So for the file extensions, since you use babel, I found this plugin useful - https://www.npmjs.com/package/babel-plugin-module-extension-resolver

(Not affiliated, not the author, just a user to solve the same file-extension madness in https://github.com/polkadot-js/dev/blob/master/packages/dev/config/babel-plugins.cjs#L26)

@adamhenson
Copy link
Collaborator Author

adamhenson commented Dec 16, 2020

@jacogr - thanks for the feedback. This issue is about removing the dependency of Babel to ES modules on Node.js natively. Everything works correctly in its current state.

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

No branches or pull requests

2 participants