allow imports and exports everywhere in loose mode
This commit is contained in:
parent
f33cd7184f
commit
0cbcbc60de
@ -14,7 +14,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
## 3.0.0
|
||||
|
||||
* **Breaking Change**
|
||||
* `allowImportExportEverywhere` acorn option has been disabled for spec compliancy so imports and exports can **only** be present at the top level.
|
||||
* Imports and exports are now illegal anywhere except the root level by default. Set `modules` to [loose mode](http://6to5.org/docs/usage/loose) to allow them everywhere.
|
||||
* Caching is now always enabled for the require hook. It also now no longer caches require resolutions.
|
||||
* `ignoreRegex` fallback has now been dropped from the require hook. `register(/foo/);`, `register({ ignoreRegex: /foo/ })` -> `register({ ignore: /foo/ })`.
|
||||
* Optional fast transformer backwards compatibility support has been removed. Use [loose mode](https://6to5.org/docs/usage/loose).
|
||||
|
||||
@ -244,7 +244,10 @@ File.prototype.parse = function (code) {
|
||||
|
||||
code = this.addCode(code);
|
||||
|
||||
return util.parse(this.opts, code, function (tree) {
|
||||
var opts = this.opts;
|
||||
opts.looseModules = this.isLoose("modules");
|
||||
|
||||
return util.parse(opts, code, function (tree) {
|
||||
self.transform(tree);
|
||||
return self.generate();
|
||||
});
|
||||
|
||||
@ -218,14 +218,15 @@ exports.parse = function (opts, code, callback) {
|
||||
var tokens = [];
|
||||
|
||||
var ast = acorn.parse(code, {
|
||||
allowReturnOutsideFunction: true,
|
||||
ecmaVersion: opts.experimental ? 7 : 6,
|
||||
playground: opts.playground,
|
||||
strictMode: true,
|
||||
onComment: comments,
|
||||
locations: true,
|
||||
onToken: tokens,
|
||||
ranges: true
|
||||
allowImportExportEverywhere: opts.looseModules,
|
||||
allowReturnOutsideFunction: true,
|
||||
ecmaVersion: opts.experimental ? 7 : 6,
|
||||
playground: opts.playground,
|
||||
strictMode: true,
|
||||
onComment: comments,
|
||||
locations: true,
|
||||
onToken: tokens,
|
||||
ranges: true
|
||||
});
|
||||
|
||||
estraverse.attachComments(ast, comments, tokens);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user