From 34d2fbfa58e447a3bcc695a1f5a77841e072152f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 18:04:27 -0400 Subject: [PATCH] remove ES5 constraint --- src/shared/.eslintrc.json | 2 +- src/shared/_build.js | 7 +--- test/runtime/index.js | 32 ------------------- .../samples/binding-indirect/_config.js | 1 - .../samples/function-in-expression/_config.js | 2 -- test/store/index.js | 17 ---------- 6 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/shared/.eslintrc.json b/src/shared/.eslintrc.json index 46f1957077..cd108372ce 100644 --- a/src/shared/.eslintrc.json +++ b/src/shared/.eslintrc.json @@ -29,7 +29,7 @@ "plugin:import/warnings" ], "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 9, "sourceType": "module" }, "settings": { diff --git a/src/shared/_build.js b/src/shared/_build.js index 3cc523e7cd..72bd5ab2a8 100644 --- a/src/shared/_build.js +++ b/src/shared/_build.js @@ -9,18 +9,13 @@ fs.readdirSync(__dirname).forEach(file => { const source = fs.readFileSync(path.join(__dirname, file), 'utf-8'); const ast = acorn.parse(source, { - ecmaVersion: 6, + ecmaVersion: 9, sourceType: 'module' }); ast.body.forEach(node => { if (node.type !== 'ExportNamedDeclaration') return; - // check no ES6+ slipped in - acorn.parse(source.slice(node.declaration.start, node.end), { - ecmaVersion: 5 - }); - const declaration = node.declaration; if (!declaration) return; diff --git a/test/runtime/index.js b/test/runtime/index.js index a184bb46d0..b491dafa20 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -74,38 +74,6 @@ describe("runtime", () => { compileOptions.immutable = config.immutable; compileOptions.parser = v2 ? 'v2' : 'v1'; - // check that no ES2015+ syntax slipped in - if (!config.allowES2015) { - try { - const source = fs.readFileSync( - `test/runtime/samples/${dir}/main${v2 ? '-v2' : ''}.html`, - "utf-8" - ); - const { code } = compile(source, compileOptions); - const startIndex = code.indexOf("function create_main_fragment"); // may change! - if (startIndex === -1) throw new Error("missing create_main_fragment"); - const endIndex = code.lastIndexOf("export default"); - const es5 = - code.slice(0, startIndex).split('\n').map(x => spaces(x.length)).join('\n') + - code.slice(startIndex, endIndex); - - acorn.parse(es5, { ecmaVersion: 5 }); - - if (/Object\.assign/.test(es5)) { - throw new Error( - "cannot use Object.assign in generated code, as it is not supported everywhere" - ); - } - } catch (err) { - failed.add(dir); - if (err.frame) { - console.error(chalk.red(err.frame)); // eslint-disable-line no-console - } - showOutput(cwd, { shared, format: 'cjs', store: !!compileOptions.store, v2 }, compile); // eslint-disable-line no-console - throw err; - } - } - Object.keys(require.cache) .filter(x => x.endsWith(".html")) .forEach(file => { diff --git a/test/runtime/samples/binding-indirect/_config.js b/test/runtime/samples/binding-indirect/_config.js index 9fdfa23a25..343cd0d0d3 100644 --- a/test/runtime/samples/binding-indirect/_config.js +++ b/test/runtime/samples/binding-indirect/_config.js @@ -7,7 +7,6 @@ const tasks = [ export default { 'skip-ssr': true, - allowES2015: true, data: { tasks, diff --git a/test/runtime/samples/function-in-expression/_config.js b/test/runtime/samples/function-in-expression/_config.js index 14cfb8f89f..9b79770eb9 100644 --- a/test/runtime/samples/function-in-expression/_config.js +++ b/test/runtime/samples/function-in-expression/_config.js @@ -1,6 +1,4 @@ export default { - allowES2015: true, - data: { numbers: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] }, diff --git a/test/store/index.js b/test/store/index.js index fd84322d35..0e989c03f5 100644 --- a/test/store/index.js +++ b/test/store/index.js @@ -5,23 +5,6 @@ import { parse } from 'acorn'; import { Store } from '../../store.js'; describe('store', () => { - it('is written in ES5', () => { - const source = fs.readFileSync('store.js', 'utf-8'); - - const ast = parse(source, { - sourceType: 'module' - }); - - const magicString = new MagicString(source); - ast.body.forEach(node => { - if (/^(Im|Ex)port/.test(node.type)) magicString.remove(node.start, node.end); - }); - - parse(magicString.toString(), { - ecmaVersion: 5 - }); - }); - describe('get', () => { it('gets a specific key', () => { const store = new Store({