Skip to content

Commit

Permalink
Merge pull request #1182 from sveltejs/upgrade-acorn-es2018
Browse files Browse the repository at this point in the history
upgrade acorn and parse as ES2018
  • Loading branch information
Rich-Harris authored Feb 23, 2018
2 parents 8330f32 + 8c1f09d commit b3b5e6c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/parse/read/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/parse/read/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/parse/read/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b3b5e6c

Please sign in to comment.