-
Notifications
You must be signed in to change notification settings - Fork 284
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
require vs ES6 import #53
Comments
You can find some discussion about In a nutshell, Support for ES6 modules first needs to land in V8. The tracking bug is here but it's blocked by finalization of the module loader spec. |
@bnoordhuis thanks! |
Hi,
What's the correct syntax to export this class as a module? Tried many things Thanks. |
@romu70 import/export isn't supported yet but // a.js
class A {
// ...
}
module.exports = A; Or: // b.js
module.exports = class B {
// ...
}; |
Why ? The current module syntax doesn't rely on any V8 support to work and |
Is your question "why won't node.js support import/export until V8 does"? Because node.js doesn't parse JS code, V8 does, and we're not a transpiler. |
Fair enough, thanks. |
Does v5+ of V8 (and consequently nodejs v6+) support es6 modules yet? |
@paulwalker No, not yet. Maybe in node.js v7. |
You can star v8 Bug 1569. |
@lordKnighton why was this issue closed? I'd love to see this implemented as well |
|
Just came back here for an update. Currently there is blocking bug. https://bugs.chromium.org/p/v8/issues/detail?id=5685 Really looking forward to this finally dropping, it is so close, and the last thing that's preventing me dropping babel on some projects. |
- uses commonjs module loading cuz node is bugged atm. - nodejs/help#53
I've been reading up on ES Modules being supported in native node, it looks like there's two simultaneous discussions of how to implement it (ie, whether to use the .mjs file extension) and then also a consideration around a bug in V8. Which is the true current blocker? Does anyone have an ETA on when the blocker should be smoothed out and V8 will support the ES Module syntax? I'm in the same boat as a few others here who are hoping to drop babel, thanks! |
Why would they support it when you could use transcompilers? |
Since 2017-Jan-10, V8 supports modules. |
Awesome! And it looks like nightly node (and 7.4) uses v8 version: 5.4.500.46 Whereas the latest V8 version with es modules landed is around: 5.7.458 Wonder how long it will take to land in node 🤔 I don't actively develop node do any devs have a guesstimate? |
@mrmayfield it should eventually be on this experimental branch fwiw it landing in V8 will be only the first step towards proper support in node. I believe we are currently tracking V8 5.5 for inclusion in node 8... but other people will know better. /cc @nodejs/v8 |
Thanks @MylesBorins |
@mrmayfield yes. It is happening here: nodejs/node-eps#39 |
From James M Snell's Update on ES6 Modules in Node.js:
|
How's progress so far? |
On node 8.x, its not supported yet. |
You can use it with for |
Currently, it's not possible to import the same file from chrome and node.js at the same time. Something should be done about this. |
i'm not sure what exactly is lacking? obviously browsers won't implement node's loader algorithm or builtin modules. there is discussion around allowing node to import from urls but there's a lot of work to do behind that. |
the problem is *.mjs file extension (which is not application/javascript
and so the chrome will reject it)
2018-03-14 0:42 GMT+01:00 Gus Caplan <notifications@github.com>:
… Currently, it's not possible to import the same file from chrome and
node.js at the same time. Something should be done about this.
i'm not sure what exactly is lacking? obviously browsers won't implement
node's loader algorithm or builtin modules. there is discussion around
allowing node to import from urls but there's a lot of work to do behind
that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#53 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADXRCub3-r_WjTdDNRH-Q_vjuQf2z5vRks5teFmAgaJpZM4G4Bmk>
.
|
|
there are cases when you can't
2018-03-14 12:38 GMT+01:00 StyMaar <notifications@github.com>:
… application/javascript is a MIME type set by the web-server in the HTTP
response header.
Most http server automatically set the application/javascript MIME header
when delivering files with a .js extension but you can configure your web
server to do the same for .mjs.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADXRCtTwe8RB4at-bW6RfwUgnE_a768Kks5teQFNgaJpZM4G4Bmk>
.
|
What's your use-case ? In general, if you can't configure the MIME type, and the I'm still curious about your specific case though. |
for those of you following along at home: https://datatracker.ietf.org/submit/status/88872/ |
@cztomsik There is something being done about it on the web side of things too. |
Are there any plans to move from CommonJs modules to ES6 modules and import syntax?
The text was updated successfully, but these errors were encountered: