From 8c1f09db1ff30f7309c85a188c6827e85dca7c94 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 21 Feb 2018 18:50:54 -0500 Subject: [PATCH] upgrade acorn and parse as ES2018 --- package.json | 2 +- src/parse/read/directives.ts | 6 ++++-- src/parse/read/expression.ts | 1 + src/parse/read/script.ts | 2 +- yarn.lock | 6 +++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7d1d9e3b33..e0a90fd46e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@types/mocha": "^2.2.41", "@types/node": "^8.0.17", - "acorn": "^5.1.1", + "acorn": "^5.4.1", "acorn-dynamic-import": "^2.0.2", "chalk": "^2.0.1", "codecov": "^2.2.0", diff --git a/src/parse/read/directives.ts b/src/parse/read/directives.ts index 2a27f37812..99744e0244 100644 --- a/src/parse/read/directives.ts +++ b/src/parse/read/directives.ts @@ -31,7 +31,9 @@ function readExpression(parser: Parser, start: number, quoteMark: string|null) { } } - const expression = parseExpressionAt(repeat(' ', start) + str, start); + const expression = parseExpressionAt(repeat(' ', start) + str, start, { + ecmaVersion: 9, + }); parser.index = expression.end; parser.allowWhitespace(); @@ -102,7 +104,7 @@ export function readBindingDirective( } const source = repeat(' ', a) + parser.template.slice(a, b); - value = parseExpressionAt(source, a); + value = parseExpressionAt(source, a, { ecmaVersion: 9 }); if (value.type !== 'Identifier' && value.type !== 'MemberExpression') { parser.error(`Cannot bind to rvalue`, value.start); diff --git a/src/parse/read/expression.ts b/src/parse/read/expression.ts index 47e1d706df..c8c3054274 100644 --- a/src/parse/read/expression.ts +++ b/src/parse/read/expression.ts @@ -32,6 +32,7 @@ export default function readExpression(parser: Parser) { try { const node = parseExpressionAt(parser.template, parser.index, { + ecmaVersion: 9, preserveParens: true, }); parser.index = node.end; diff --git a/src/parse/read/script.ts b/src/parse/read/script.ts index d88c0a822d..4f28200b43 100644 --- a/src/parse/read/script.ts +++ b/src/parse/read/script.ts @@ -22,7 +22,7 @@ export default function readScript(parser: Parser, start: number, attributes: No try { ast = acorn.parse(source, { - ecmaVersion: 8, + ecmaVersion: 9, sourceType: 'module', plugins: { dynamicImport: true diff --git a/yarn.lock b/yarn.lock index e79897d0af..65ad9e5307 100644 --- a/yarn.lock +++ b/yarn.lock @@ -58,10 +58,14 @@ acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0, acorn@^5.1.1, acorn@^5.2.1, acorn@^5.3.0: +acorn@^5.0.0, acorn@^5.2.1, acorn@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" +acorn@^5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102" + acorn@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7"