Last active
January 7, 2016 16:05
-
-
Save zenparsing/a74c69130c74332f7f6f to your computer and use it in GitHub Desktop.
Issues with Automatic Module Detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OK if a script, but not ok if a "module". | |
// We'll have to remember this error and location as we parse. | |
with (x) {} | |
// The export declaration means that we need to throw a parse error | |
// using the location of the "with" statement. | |
export const A = "a"; | |
// V8 doesn't remember strict mode errors like this, and the V8 team has | |
// previously objected to features which seem to require it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Am I a module or script? | |
// This could be either. To assume it's a script violates the ECMAScript specification. |
It's just that the language allows "modules" to not have import and export statements, and so should Node.
- we can always double parse to get this.
a. if v8 doesn't want to record a single Error object (they won't ever need 2) thats pretty lame, but I bet it is less effort than porting all of npm's stuff
b. workable already so non-blocker - node, the host env, not ecma262 will assume if it can be parsed as a script, it is a script, else check if it is a module
should v8 provide a single call that will let us check both of these without a double parse, all the nicer.
Also all these "goals" in the grammar are just for parsing, not for execution so we aren't going to cause side effects.
@zenparsing, would require some opt in to force things to be a module, could use a pragma. also spec people should stop using pragmas and goals.
is there any effect really w/o import/export
except making it strict mode?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, it's not really a "violation" to assume something is a module or script, that's too strong.