allow imports and exports everywhere in loose mode

This commit is contained in:
Sebastian McKenzie
2015-01-14 15:21:45 +11:00
parent f33cd7184f
commit 0cbcbc60de
3 changed files with 14 additions and 10 deletions

View File

@@ -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();
});

View File

@@ -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);