From 3ca75dc9ecb12da1eaef5b16659b8dfbf509e47c Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 30 May 2017 15:31:13 -0400 Subject: [PATCH 1/4] Adds test to ensure that numericSeparator plugin does not alter "_" handling in Identifier (#548) --- .../identifier-start-0/actual.js | 1 + .../identifier-start-0/expected.json | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/fixtures/experimental/numeric-literal-separator/identifier-start-0/actual.js create mode 100644 test/fixtures/experimental/numeric-literal-separator/identifier-start-0/expected.json diff --git a/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/actual.js b/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/actual.js new file mode 100644 index 0000000000..adc9bff555 --- /dev/null +++ b/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/actual.js @@ -0,0 +1 @@ +_123 diff --git a/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/expected.json b/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/expected.json new file mode 100644 index 0000000000..70cf57a548 --- /dev/null +++ b/test/fixtures/experimental/numeric-literal-separator/identifier-start-0/expected.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "_123" + }, + "name": "_123" + } + } + ], + "directives": [] + } +} \ No newline at end of file From 2f5d146d5454958ab4c294fcb68492dc7b3ea446 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 30 May 2017 19:14:31 -0400 Subject: [PATCH 2/4] Don't treat e, b, E, B as forbidden siblings for hex literals. (#549) --- src/tokenizer/index.js | 37 ++++++---- .../valid-12/actual.js | 1 + .../valid-12/expected.json | 69 +++++++++++++++++++ 3 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/experimental/numeric-literal-separator/valid-12/actual.js create mode 100644 test/fixtures/experimental/numeric-literal-separator/valid-12/expected.json diff --git a/src/tokenizer/index.js b/src/tokenizer/index.js index b41067c43b..743c3286a5 100644 --- a/src/tokenizer/index.js +++ b/src/tokenizer/index.js @@ -17,18 +17,24 @@ import State from "./state"; // The following character codes are forbidden from being // an immediate sibling of NumericLiteralSeparator _ -const forbiddenNumericLiteralSeparatorSiblings = [ - 46, // . - 66, // B - 69, // E - 79, // O - 88, // X - 95, // _ (multiple separators are not allowed) - 98, // b - 101, // e - 111, // o - 120, // x -]; +const forbiddenNumericSeparatorSiblings = { + decBinOct: [ + 46, // . + 66, // B + 69, // E + 79, // O + 95, // _ (multiple separators are not allowed) + 98, // b + 101, // e + 111, // o + ], + hex: [ + 46, // . + 88, // X + 95, // _ (multiple separators are not allowed) + 120, // x + ], +}; // Object type used to represent tokens. Note that normally, tokens // simply exist as properties on the parser object. This is only @@ -567,6 +573,9 @@ export default class Tokenizer extends LocationParser { readInt(radix: number, len?: number): number | null { const start = this.state.pos; + const forbiddenSiblings = radix === 16 ? + forbiddenNumericSeparatorSiblings.hex : + forbiddenNumericSeparatorSiblings.decBinOct; let total = 0; for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { @@ -577,8 +586,8 @@ export default class Tokenizer extends LocationParser { const prev = this.input.charCodeAt(this.state.pos - 1); const next = this.input.charCodeAt(this.state.pos + 1); if (code === 95) { - if ((forbiddenNumericLiteralSeparatorSiblings.indexOf(prev) > -1) || - (forbiddenNumericLiteralSeparatorSiblings.indexOf(next) > -1) || + if ((forbiddenSiblings.indexOf(prev) > -1) || + (forbiddenSiblings.indexOf(next) > -1) || Number.isNaN(next)) { this.raise(this.state.pos, "Invalid NumericLiteralSeparator"); } diff --git a/test/fixtures/experimental/numeric-literal-separator/valid-12/actual.js b/test/fixtures/experimental/numeric-literal-separator/valid-12/actual.js new file mode 100644 index 0000000000..4115d0bd97 --- /dev/null +++ b/test/fixtures/experimental/numeric-literal-separator/valid-12/actual.js @@ -0,0 +1 @@ +0xBE_be_EB_eb; diff --git a/test/fixtures/experimental/numeric-literal-separator/valid-12/expected.json b/test/fixtures/experimental/numeric-literal-separator/valid-12/expected.json new file mode 100644 index 0000000000..8719155cde --- /dev/null +++ b/test/fixtures/experimental/numeric-literal-separator/valid-12/expected.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 3200183275, + "raw": "0xBE_be_EB_eb" + }, + "value": 3200183275 + } + } + ], + "directives": [] + } +} \ No newline at end of file From d4e842d4eb17df3455209821cf69aeac766a4c89 Mon Sep 17 00:00:00 2001 From: Jan Olaf Krems Date: Tue, 30 May 2017 16:28:51 -0700 Subject: [PATCH 3/4] Add plugin for import.meta proposal (#544) * Add plugin for import.meta proposal Fixes https://github.com/babel/babylon/issues/539 * Tests for assignment/mutation of import.meta * Use correct identifier in failure message * Simpler & more consistent script errors for import.meta --- README.md | 1 + src/parser/expression.js | 16 +- src/parser/statement.js | 3 +- .../import-meta/error-in-script/actual.js | 1 + .../import-meta/error-in-script/options.json | 5 + .../import-meta/no-other-prop-names/actual.js | 1 + .../no-other-prop-names/options.json | 5 + .../import-meta/not-assignable/actual.js | 1 + .../import-meta/not-assignable/options.json | 5 + .../import-meta/valid-in-module/actual.js | 5 + .../import-meta/valid-in-module/expected.json | 555 ++++++++++++++++++ .../import-meta/valid-in-module/options.json | 4 + .../without-dynamic-import/actual.js | 5 + .../without-dynamic-import/expected.json | 555 ++++++++++++++++++ .../without-dynamic-import/options.json | 4 + 15 files changed, 1164 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/experimental/import-meta/error-in-script/actual.js create mode 100644 test/fixtures/experimental/import-meta/error-in-script/options.json create mode 100644 test/fixtures/experimental/import-meta/no-other-prop-names/actual.js create mode 100644 test/fixtures/experimental/import-meta/no-other-prop-names/options.json create mode 100644 test/fixtures/experimental/import-meta/not-assignable/actual.js create mode 100644 test/fixtures/experimental/import-meta/not-assignable/options.json create mode 100644 test/fixtures/experimental/import-meta/valid-in-module/actual.js create mode 100644 test/fixtures/experimental/import-meta/valid-in-module/expected.json create mode 100644 test/fixtures/experimental/import-meta/valid-in-module/options.json create mode 100644 test/fixtures/experimental/import-meta/without-dynamic-import/actual.js create mode 100644 test/fixtures/experimental/import-meta/without-dynamic-import/expected.json create mode 100644 test/fixtures/experimental/import-meta/without-dynamic-import/options.json diff --git a/README.md b/README.md index be6f771feb..8e92625e34 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ require("babylon").parse("code", { - `functionSent` - `dynamicImport` ([proposal](https://github.com/tc39/proposal-dynamic-import)) - `numericSeparator` ([proposal](https://github.com/samuelgoto/proposal-numeric-separator)) + - `importMeta` ([proposal](https://github.com/tc39/proposal-import-meta)) ### FAQ diff --git a/src/parser/expression.js b/src/parser/expression.js index b097be7e10..13b2371fae 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -427,6 +427,10 @@ export default class ExpressionParser extends LValParser { return this.finishNode(node, "Super"); case tt._import: + if (this.hasPlugin("importMeta") && this.lookahead().type === tt.dot) { + return this.parseImportMetaProperty(); + } + if (!this.hasPlugin("dynamicImport")) this.unexpected(); node = this.startNode(); @@ -588,12 +592,22 @@ export default class ExpressionParser extends LValParser { node.property = this.parseIdentifier(true); if (node.property.name !== propertyName) { - this.raise(node.property.start, `The only valid meta property for new is ${meta.name}.${propertyName}`); + this.raise(node.property.start, `The only valid meta property for ${meta.name} is ${meta.name}.${propertyName}`); } return this.finishNode(node, "MetaProperty"); } + parseImportMetaProperty(): N.MetaProperty { + const node = this.startNode(); + const id = this.parseIdentifier(true); + this.expect(tt.dot); + if (!this.inModule) { + this.raise(id.start, "import.meta may appear only with 'sourceType: module'"); + } + return this.parseMetaProperty(node, id, "meta"); + } + parseLiteral(value: any, type: /*T["kind"]*/string, startPos?: number, startLoc?: Position): T { startPos = startPos || this.state.start; startLoc = startLoc || this.state.startLoc; diff --git a/src/parser/statement.js b/src/parser/statement.js index 080b3a0e02..012066d822 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -106,7 +106,8 @@ export default class StatementParser extends ExpressionParser { case tt.semi: return this.parseEmptyStatement(node); case tt._export: case tt._import: - if (this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL) break; + if ((this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL) || + (this.hasPlugin("importMeta") && this.lookahead().type === tt.dot)) break; if (!this.options.allowImportExportEverywhere) { if (!topLevel) { diff --git a/test/fixtures/experimental/import-meta/error-in-script/actual.js b/test/fixtures/experimental/import-meta/error-in-script/actual.js new file mode 100644 index 0000000000..e1cfc5468e --- /dev/null +++ b/test/fixtures/experimental/import-meta/error-in-script/actual.js @@ -0,0 +1 @@ +const x = import.meta; diff --git a/test/fixtures/experimental/import-meta/error-in-script/options.json b/test/fixtures/experimental/import-meta/error-in-script/options.json new file mode 100644 index 0000000000..8fc6ce37a5 --- /dev/null +++ b/test/fixtures/experimental/import-meta/error-in-script/options.json @@ -0,0 +1,5 @@ +{ + "throws": "import.meta may appear only with 'sourceType: module' (1:10)", + "plugins": ["dynamicImport", "importMeta"], + "sourceType": "script" +} diff --git a/test/fixtures/experimental/import-meta/no-other-prop-names/actual.js b/test/fixtures/experimental/import-meta/no-other-prop-names/actual.js new file mode 100644 index 0000000000..cfa01aa85e --- /dev/null +++ b/test/fixtures/experimental/import-meta/no-other-prop-names/actual.js @@ -0,0 +1 @@ +import.notMeta; diff --git a/test/fixtures/experimental/import-meta/no-other-prop-names/options.json b/test/fixtures/experimental/import-meta/no-other-prop-names/options.json new file mode 100644 index 0000000000..97ba83ec46 --- /dev/null +++ b/test/fixtures/experimental/import-meta/no-other-prop-names/options.json @@ -0,0 +1,5 @@ +{ + "throws": "The only valid meta property for import is import.meta (1:7)", + "sourceType": "module", + "plugins": ["dynamicImport", "importMeta"] +} diff --git a/test/fixtures/experimental/import-meta/not-assignable/actual.js b/test/fixtures/experimental/import-meta/not-assignable/actual.js new file mode 100644 index 0000000000..d1f20b1c0a --- /dev/null +++ b/test/fixtures/experimental/import-meta/not-assignable/actual.js @@ -0,0 +1 @@ +import.meta = true; diff --git a/test/fixtures/experimental/import-meta/not-assignable/options.json b/test/fixtures/experimental/import-meta/not-assignable/options.json new file mode 100644 index 0000000000..647ad9f65d --- /dev/null +++ b/test/fixtures/experimental/import-meta/not-assignable/options.json @@ -0,0 +1,5 @@ +{ + "throws": "Invalid left-hand side in assignment expression (1:0)", + "sourceType": "module", + "plugins": ["dynamicImport", "importMeta"] +} diff --git a/test/fixtures/experimental/import-meta/valid-in-module/actual.js b/test/fixtures/experimental/import-meta/valid-in-module/actual.js new file mode 100644 index 0000000000..fd4422fc6f --- /dev/null +++ b/test/fixtures/experimental/import-meta/valid-in-module/actual.js @@ -0,0 +1,5 @@ +const x = import.meta; +const url = import.meta.url; +import.meta; +import.meta.url; +import.meta.couldBeMutable = true; diff --git a/test/fixtures/experimental/import-meta/valid-in-module/expected.json b/test/fixtures/experimental/import-meta/valid-in-module/expected.json new file mode 100644 index 0000000000..dc33442309 --- /dev/null +++ b/test/fixtures/experimental/import-meta/valid-in-module/expected.json @@ -0,0 +1,555 @@ +{ + "type": "File", + "start": 0, + "end": 116, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 116, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "MetaProperty", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "meta": { + "type": "Identifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "meta" + }, + "name": "meta" + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 23, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "url" + }, + "name": "url" + }, + "init": { + "type": "MemberExpression", + "start": 35, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "object": { + "type": "MetaProperty", + "start": 35, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "meta": { + "type": "Identifier", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 42, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + }, + "identifierName": "url" + }, + "name": "url" + }, + "computed": false + } + } + ], + "kind": "const" + }, + { + "type": "ExpressionStatement", + "start": 52, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "expression": { + "type": "MetaProperty", + "start": 52, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 52, + "end": 58, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 59, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + } + }, + { + "type": "ExpressionStatement", + "start": 65, + "end": 81, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "expression": { + "type": "MemberExpression", + "start": 65, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "object": { + "type": "MetaProperty", + "start": 65, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 65, + "end": 71, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 72, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 77, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + }, + "identifierName": "url" + }, + "name": "url" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 82, + "end": 116, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 82, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "operator": "=", + "left": { + "type": "MemberExpression", + "start": 82, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "object": { + "type": "MetaProperty", + "start": 82, + "end": 93, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 82, + "end": 88, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 89, + "end": 93, + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 94, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 26 + }, + "identifierName": "couldBeMutable" + }, + "name": "couldBeMutable" + }, + "computed": false + }, + "right": { + "type": "BooleanLiteral", + "start": 111, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": true + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/import-meta/valid-in-module/options.json b/test/fixtures/experimental/import-meta/valid-in-module/options.json new file mode 100644 index 0000000000..be1070ffed --- /dev/null +++ b/test/fixtures/experimental/import-meta/valid-in-module/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["dynamicImport", "importMeta"] +} diff --git a/test/fixtures/experimental/import-meta/without-dynamic-import/actual.js b/test/fixtures/experimental/import-meta/without-dynamic-import/actual.js new file mode 100644 index 0000000000..fd4422fc6f --- /dev/null +++ b/test/fixtures/experimental/import-meta/without-dynamic-import/actual.js @@ -0,0 +1,5 @@ +const x = import.meta; +const url = import.meta.url; +import.meta; +import.meta.url; +import.meta.couldBeMutable = true; diff --git a/test/fixtures/experimental/import-meta/without-dynamic-import/expected.json b/test/fixtures/experimental/import-meta/without-dynamic-import/expected.json new file mode 100644 index 0000000000..dc33442309 --- /dev/null +++ b/test/fixtures/experimental/import-meta/without-dynamic-import/expected.json @@ -0,0 +1,555 @@ +{ + "type": "File", + "start": 0, + "end": 116, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 116, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "sourceType": "module", + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "MetaProperty", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "meta": { + "type": "Identifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "meta" + }, + "name": "meta" + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 23, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "url" + }, + "name": "url" + }, + "init": { + "type": "MemberExpression", + "start": 35, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "object": { + "type": "MetaProperty", + "start": 35, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "meta": { + "type": "Identifier", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 42, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + }, + "identifierName": "url" + }, + "name": "url" + }, + "computed": false + } + } + ], + "kind": "const" + }, + { + "type": "ExpressionStatement", + "start": 52, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "expression": { + "type": "MetaProperty", + "start": 52, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 52, + "end": 58, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 59, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + } + }, + { + "type": "ExpressionStatement", + "start": 65, + "end": 81, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "expression": { + "type": "MemberExpression", + "start": 65, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "object": { + "type": "MetaProperty", + "start": 65, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 65, + "end": 71, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 72, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 77, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + }, + "identifierName": "url" + }, + "name": "url" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 82, + "end": 116, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 82, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "operator": "=", + "left": { + "type": "MemberExpression", + "start": 82, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "object": { + "type": "MetaProperty", + "start": 82, + "end": 93, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 82, + "end": 88, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 89, + "end": 93, + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "property": { + "type": "Identifier", + "start": 94, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 26 + }, + "identifierName": "couldBeMutable" + }, + "name": "couldBeMutable" + }, + "computed": false + }, + "right": { + "type": "BooleanLiteral", + "start": 111, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": true + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/import-meta/without-dynamic-import/options.json b/test/fixtures/experimental/import-meta/without-dynamic-import/options.json new file mode 100644 index 0000000000..a6638b6528 --- /dev/null +++ b/test/fixtures/experimental/import-meta/without-dynamic-import/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["importMeta"] +} From 324e2f025366ff3d443fecb3f81022a4494299cf Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 30 May 2017 19:30:08 -0400 Subject: [PATCH 4/4] 7.0.0-beta.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56928ae0c1..64c9cc0654 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "babylon", - "version": "7.0.0-beta.11", + "version": "7.0.0-beta.12", "description": "A JavaScript parser", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/",