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

--harmony_modules isn't working? #2760

Closed
tusharmath opened this issue Sep 9, 2015 · 16 comments
Closed

--harmony_modules isn't working? #2760

tusharmath opened this issue Sep 9, 2015 · 16 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@tusharmath
Copy link
Contributor

Following the documentation given here https://nodejs.org/en/docs/es6/

Sample Code

import {partial} from 'lodash'
console.log(partial)

command

node --harmony_modules  Javascript.js
/Users/tushar.mathur/Documents/Projects/temp/Javascript.js:1
(function (exports, require, module, __filename, __dirname) { import {partial} from 'lodash'
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3
➜  temp

OS: Mac OS 10.10.4
Node: 4.0.0

@fl0w
Copy link

fl0w commented Sep 9, 2015

Same results here, also on OS X (also with strict mode).
However, I'm not sure it is expected to work - I'm still transforming with BabelJS.

@tusharmath
Copy link
Contributor Author

I guess I tweeted too soon :'(

Yay! ES6 modules finally :) https://t.co/g9oKPYXEEw

— Tushar Mathur (@tusharmath) September 8, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@fl0w
Copy link

fl0w commented Sep 9, 2015

modules are still in 'in progress' in v8 - so I'd withdraw that tweet anyway!

$ node --v8-options | grep 'in progress' 

@tusharmath
Copy link
Contributor Author

Well, I wanted to experiment with them without using a transpiler which I finally could (Or can't).

@ilkkao
Copy link

ilkkao commented Sep 9, 2015

See this comment: https://code.google.com/p/v8/issues/detail?id=1569#c29

V8 developers are currently waiting WHATWG loader spec to mature before completing the ES2015 module support.

@bnoordhuis
Copy link
Member

Closing. As others point out, ES6 modules are not implemented in V8 yet. As a rule of thumb, if a feature is behind a flag, you can expect it to be half-baked or downright broken.

@nguyenchilong
Copy link

I have problem with '--harmony' in command, and use AppJS module node --harmony ./app/app.js and after run then have error 'AppJS requires Node is run with the --harmony command line flag' pls help me for this error. I use xubuntu OS node v4.2.2.
have add '--harmony' or no then always show error message 'throw new Error ('AppJS requires Node is run with the --harmony command line flag'); ^
Error: AppJS requires Node is run with the --harmony command line flag
at Object. (/var/www/tutorial/app/node_modules/appjs/lib/index.js:2:9)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/var/www/tutorial/app/app.js:3:11)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)'

@Globik
Copy link

Globik commented May 15, 2016

And by now what? Is import implemented in node.js 6.0?

@fl0w
Copy link

fl0w commented May 15, 2016

AFAIK, V8 still doesn't support import/export, and thus neither does node.js v6.

@d3x0r
Copy link
Contributor

d3x0r commented May 15, 2016

https://bugs.chromium.org/p/v8/issues/detail?id=1569

Mar 16, 2016

Remove --harmony-modules flag and let embedder decide when modules are used

Modules already have a separate entrypoint into the engine (at the moment,
this is v8::ScriptCompiler::CompileModule, though that will change to
something like ParseModule). This meant that requiring a commandline flag
simply added an extra complexity burden on embedders. By removing the v8
flag, this lets embedders use their own flagging mechanism (such as d8's
"--module", or Blink's RuntimeEnabledFeatures) to control whether
modules are to be used.

Also remove old modules tests that were being skipped (since they test
very old, pre-ES2015 modules syntax).

@quantuminformation
Copy link

sad

@skrat
Copy link

skrat commented Jun 6, 2016

Yeah, keep the ticket closed. Modules in JS will never be truly standardized, and if they will, the standard will be obsolete or deprecated the next day, by a new solution, "new standard". Sad.

@cweilguny
Copy link

As node 6.5.0 still throws up on import ..., I guess it's still not in V8? Any news on that?
http://node.green/ is a great resource, but is there module support shown in any way?

@simonbengtsson
Copy link

V8 now has support for modules! And implementation has started in chromium 🎉🏆🎊 https://bugs.chromium.org/p/chromium/issues/detail?id=594639#c9

@avesus
Copy link

avesus commented Dec 23, 2017

Node 9.3.0 still not supported.

@devsnek
Copy link
Member

devsnek commented Dec 23, 2017

@avesus i believe modules are slated for node 10 (i don't know if they will be backported). however you can use them in nightly builds with --experimental-modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests