google-code-export / esprima

Automatically exported from code.google.com/p/esprima
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

implement top-level type option to indicate what rules to apply: module vs scripts #598

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Based on the discussion in PR #287, we came to the conclusion that such flag is 
needed due to the nature of the modules vs scripts, more details here:
https://github.com/ariya/esprima/pull/287#issuecomment-57369128

Proposed solution:

esprima.parse(code, { type: "module" });

which default to "script", but when specifying "module", it will turn on 
"strict mode" and will allow import and export declaration.

In the future, it is very likely to have other rules that only apply to the 
`module` type.

Original issue reported on code.google.com by car...@gmail.com on 1 Oct 2014 at 4:43

GoogleCodeExporter commented 9 years ago
I was the one who raised the stink about this, so figured I'd step up and take 
on the work :)

Here's a pull request: https://github.com/ariya/esprima/pull/290

Original comment by LBLJef...@gmail.com on 20 Oct 2014 at 9:17

GoogleCodeExporter commented 9 years ago
Add options.sourceType for disambiguating module parsing mode from script 
parsing mode
https://github.com/ariya/esprima/commit/85fc2f4b6a

Original comment by ariya.hi...@gmail.com on 10 Jan 2015 at 9:05