diff --git a/src/babel/helpers/parse.js b/src/babel/helpers/parse.js index 66d269a6b7..f7bcef7ba9 100644 --- a/src/babel/helpers/parse.js +++ b/src/babel/helpers/parse.js @@ -22,8 +22,10 @@ export default function (opts, code, callback) { ranges: true }; - parseOpts.plugins.jsx = true; - parseOpts.plugins.flow = true; + if (opts.nonStandard) { + parseOpts.plugins.jsx = true; + parseOpts.plugins.flow = true; + } var ast = acorn.parse(code, parseOpts); diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js index 050bf00053..b3828173c0 100644 --- a/src/babel/transformation/file/index.js +++ b/src/babel/transformation/file/index.js @@ -395,6 +395,7 @@ export default class File { var parseOpts = { highlightCode: opts.highlightCode, + nonStandard: opts.nonStandard, filename: opts.filename, plugins: {} }; diff --git a/src/babel/transformation/file/options.json b/src/babel/transformation/file/options.json index f84f766c6b..8d344b6476 100644 --- a/src/babel/transformation/file/options.json +++ b/src/babel/transformation/file/options.json @@ -15,8 +15,11 @@ "hidden": true }, - "moduleId": { + "moduleId": {}, + "nonStandard": { + "type": "boolean", + "default": true }, "highlightTheme": { diff --git a/test/core/generation.js b/test/core/generation.js index 2eb34d34d5..9084e0b4b4 100644 --- a/test/core/generation.js +++ b/test/core/generation.js @@ -28,6 +28,7 @@ _.each(helper.get("generation"), function (testSuite) { var actualAst = parse({ filename: actual.loc, + nonStandard: true, experimental: true, strictMode: false, sourceType: "module",