From 3b0ed3e7ccabbe57a296a58a56093122a30b6b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 17:44:44 +0200 Subject: [PATCH 01/17] Copy tests --- .../dynamic-import-with-valid-syntax/input.js | 1 + .../output.json | 81 +++++++++++ .../import-assert-call-expression/input.js | 2 + .../import-assert-call-expression/output.json | 48 +++++++ .../incorrect-arity/input.js | 2 + .../incorrect-arity/output.json | 107 ++++++++++++++ .../invalid-assert-entry-no-colon/input.js | 1 + .../options.json | 9 ++ .../invalid-escaped-assert/input.js | 1 + .../invalid-escaped-assert/options.json | 8 ++ .../invalid-escaped-assert/output.json | 74 ++++++++++ .../invalid-export-without-from/input.js | 2 + .../invalid-export-without-from/options.json | 8 ++ .../invalid-export-without-from/output.json | 107 ++++++++++++++ .../input.js | 1 + .../output.json | 48 +++++++ .../input.js | 1 + .../output.json | 84 +++++++++++ .../input.js | 1 + .../options.json | 5 + .../input.js | 2 + .../output.json | 69 +++++++++ .../input.js | 1 + .../output.json | 105 ++++++++++++++ .../input.js | 1 + .../output.json | 78 ++++++++++ .../input.js | 1 + .../options.json | 9 ++ .../options.json | 8 ++ .../string-literal/input.js | 2 + .../string-literal/output.json | 107 ++++++++++++++ .../trailing-comma-dynamic/input.js | 2 + .../trailing-comma-dynamic/output.json | 110 +++++++++++++++ .../trailing-comma/input.js | 2 + .../trailing-comma/output.json | 107 ++++++++++++++ .../valid-empty-assertion/input.js | 4 + .../valid-empty-assertion/output.json | 133 ++++++++++++++++++ .../valid-export-class/input.js | 1 + .../valid-export-class/output.json | 35 +++++ .../valid-export-function/input.js | 1 + .../valid-export-function/output.json | 38 +++++ .../valid-export-variable/input.js | 1 + .../valid-export-variable/output.json | 45 ++++++ .../valid-export-without-from/input.js | 3 + .../valid-export-without-from/output.json | 61 ++++++++ .../valid-string-assertion-key/input.js | 1 + .../valid-string-assertion-key/output.json | 51 +++++++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 46 ++++++ .../input.js | 2 + .../output.json | 63 +++++++++ .../input.js | 2 + .../output.json | 86 +++++++++++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../output.json | 81 +++++++++++ .../input.js | 1 + .../output.json | 44 ++++++ .../input.js | 2 + .../output.json | 66 +++++++++ .../input.js | 2 + .../output.json | 47 +++++++ .../valid-syntax-with-attributes/input.js | 1 + .../valid-syntax-with-attributes/output.json | 57 ++++++++ .../valid-syntax-with-invalid-value/input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 75 ++++++++++ .../valid-syntax-without-attributes/input.js | 1 + .../output.json | 38 +++++ .../without-plugin/input.js | 1 + .../without-plugin/options.json | 5 + .../dynamic-import-with-valid-syntax/input.js | 1 + .../output.json | 81 +++++++++++ .../import-assert-call-expression/input.js | 2 + .../import-assert-call-expression/output.json | 48 +++++++ .../incorrect-arity/input.js | 2 + .../incorrect-arity/output.json | 107 ++++++++++++++ .../invalid-assert-entry-no-colon/input.js | 1 + .../options.json | 9 ++ .../invalid-escaped-assert/input.js | 1 + .../invalid-escaped-assert/options.json | 8 ++ .../invalid-escaped-assert/output.json | 74 ++++++++++ .../invalid-export-without-from/input.js | 2 + .../invalid-export-without-from/options.json | 8 ++ .../invalid-export-without-from/output.json | 107 ++++++++++++++ .../input.js | 1 + .../output.json | 48 +++++++ .../input.js | 1 + .../output.json | 84 +++++++++++ .../input.js | 1 + .../options.json | 5 + .../input.js | 2 + .../output.json | 69 +++++++++ .../input.js | 1 + .../output.json | 105 ++++++++++++++ .../input.js | 1 + .../output.json | 78 ++++++++++ .../input.js | 1 + .../options.json | 9 ++ .../options.json | 4 + .../string-literal/input.js | 2 + .../string-literal/output.json | 107 ++++++++++++++ .../trailing-comma-dynamic/input.js | 2 + .../trailing-comma-dynamic/output.json | 110 +++++++++++++++ .../trailing-comma/input.js | 2 + .../trailing-comma/output.json | 107 ++++++++++++++ .../valid-empty-assertion/input.js | 4 + .../valid-empty-assertion/output.json | 133 ++++++++++++++++++ .../valid-export-class/input.js | 1 + .../valid-export-class/output.json | 35 +++++ .../valid-export-function/input.js | 1 + .../valid-export-function/output.json | 38 +++++ .../valid-export-variable/input.js | 1 + .../valid-export-variable/output.json | 45 ++++++ .../valid-export-without-from/input.js | 3 + .../valid-export-without-from/output.json | 61 ++++++++ .../valid-string-assertion-key/input.js | 1 + .../valid-string-assertion-key/output.json | 51 +++++++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 46 ++++++ .../input.js | 2 + .../output.json | 63 +++++++++ .../input.js | 2 + .../output.json | 86 +++++++++++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../output.json | 81 +++++++++++ .../input.js | 1 + .../output.json | 44 ++++++ .../input.js | 2 + .../output.json | 66 +++++++++ .../input.js | 2 + .../output.json | 47 +++++++ .../valid-syntax-with-attributes/input.js | 1 + .../valid-syntax-with-attributes/output.json | 57 ++++++++ .../valid-syntax-with-invalid-value/input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 75 ++++++++++ .../valid-syntax-without-attributes/input.js | 1 + .../output.json | 38 +++++ .../without-plugin/input.js | 1 + .../without-plugin/options.json | 5 + .../dynamic-import-with-valid-syntax/input.js | 1 + .../output.json | 81 +++++++++++ .../import-assert-call-expression/input.js | 2 + .../import-assert-call-expression/output.json | 48 +++++++ .../incorrect-arity/input.js | 2 + .../incorrect-arity/output.json | 107 ++++++++++++++ .../invalid-assert-entry-no-colon/input.js | 1 + .../options.json | 9 ++ .../invalid-escaped-assert/input.js | 1 + .../invalid-escaped-assert/options.json | 8 ++ .../invalid-escaped-assert/output.json | 74 ++++++++++ .../invalid-export-without-from/input.js | 2 + .../invalid-export-without-from/options.json | 8 ++ .../invalid-export-without-from/output.json | 107 ++++++++++++++ .../input.js | 1 + .../output.json | 48 +++++++ .../input.js | 1 + .../output.json | 84 +++++++++++ .../input.js | 1 + .../options.json | 5 + .../input.js | 2 + .../output.json | 69 +++++++++ .../input.js | 1 + .../output.json | 105 ++++++++++++++ .../input.js | 1 + .../output.json | 78 ++++++++++ .../input.js | 1 + .../options.json | 9 ++ .../import-attributes/options.json | 4 + .../import-attributes/string-literal/input.js | 2 + .../string-literal/output.json | 107 ++++++++++++++ .../trailing-comma-dynamic/input.js | 2 + .../trailing-comma-dynamic/output.json | 110 +++++++++++++++ .../import-attributes/trailing-comma/input.js | 2 + .../trailing-comma/output.json | 107 ++++++++++++++ .../valid-empty-assertion/input.js | 4 + .../valid-empty-assertion/output.json | 133 ++++++++++++++++++ .../valid-export-class/input.js | 1 + .../valid-export-class/output.json | 35 +++++ .../valid-export-function/input.js | 1 + .../valid-export-function/output.json | 38 +++++ .../valid-export-variable/input.js | 1 + .../valid-export-variable/output.json | 45 ++++++ .../valid-export-without-from/input.js | 3 + .../valid-export-without-from/output.json | 61 ++++++++ .../valid-string-assertion-key/input.js | 1 + .../valid-string-assertion-key/output.json | 51 +++++++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 46 ++++++ .../input.js | 2 + .../output.json | 63 +++++++++ .../input.js | 2 + .../output.json | 86 +++++++++++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 63 +++++++++ .../input.js | 1 + .../output.json | 81 +++++++++++ .../input.js | 1 + .../output.json | 44 ++++++ .../input.js | 2 + .../output.json | 66 +++++++++ .../input.js | 2 + .../output.json | 47 +++++++ .../valid-syntax-with-attributes/input.js | 1 + .../valid-syntax-with-attributes/output.json | 57 ++++++++ .../valid-syntax-with-invalid-value/input.js | 1 + .../options.json | 9 ++ .../input.js | 1 + .../output.json | 57 ++++++++ .../input.js | 1 + .../output.json | 75 ++++++++++ .../valid-syntax-without-attributes/input.js | 1 + .../output.json | 38 +++++ .../import-attributes/without-plugin/input.js | 1 + .../without-plugin/options.json | 5 + 243 files changed, 7360 insertions(+) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..481c52e1c75f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { assert: { type: "json" } }) diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json new file mode 100644 index 000000000000..6a600725554a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "program": { + "type": "Program", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "expression": { + "type": "CallExpression", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":17,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":17,"index":17}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, + "properties": [ + { + "type": "ObjectProperty", + "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, + "method": false, + "key": { + "type": "Identifier", + "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, + "properties": [ + { + "type": "ObjectProperty", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "method": false, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js new file mode 100644 index 000000000000..5b6c5fa3373a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +assert ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json new file mode 100644 index 000000000000..dff75e218c42 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "program": { + "type": "Program", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":11,"end":23,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":12,"index":23}}, + "expression": { + "type": "CallExpression", + "start":11,"end":22,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":11,"index":22}}, + "callee": { + "type": "Identifier", + "start":11,"end":17,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":6,"index":17},"identifierName":"assert"}, + "name": "assert" + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":19,"end":21,"loc":{"start":{"line":2,"column":8,"index":19},"end":{"line":2,"column":10,"index":21}}, + "properties": [] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js new file mode 100644 index 000000000000..0863c2ee4884 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js @@ -0,0 +1,2 @@ +import(); +import("./foo.json", { assert: { type: "json"} }, "unsupported"); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json new file mode 100644 index 000000000000..1075711b669a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "errors": [ + "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", + "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" + ], + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "expression": { + "type": "CallExpression", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":8,"index":8}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start":10,"end":75,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":65,"index":75}}, + "expression": { + "type": "CallExpression", + "start":10,"end":74,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":64,"index":74}}, + "callee": { + "type": "Import", + "start":10,"end":16,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":6,"index":16}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":17,"end":29,"loc":{"start":{"line":2,"column":7,"index":17},"end":{"line":2,"column":19,"index":29}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "ObjectExpression", + "start":31,"end":58,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":48,"index":58}}, + "properties": [ + { + "type": "ObjectProperty", + "start":33,"end":56,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":46,"index":56}}, + "method": false, + "key": { + "type": "Identifier", + "start":33,"end":39,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":29,"index":39},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":41,"end":56,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":46,"index":56}}, + "properties": [ + { + "type": "ObjectProperty", + "start":43,"end":55,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":45,"index":55}}, + "method": false, + "key": { + "type": "Identifier", + "start":43,"end":47,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":37,"index":47},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":49,"end":55,"loc":{"start":{"line":2,"column":39,"index":49},"end":{"line":2,"column":45,"index":55}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + }, + { + "type": "StringLiteral", + "start":60,"end":73,"loc":{"start":{"line":2,"column":50,"index":60},"end":{"line":2,"column":63,"index":73}}, + "extra": { + "rawValue": "unsupported", + "raw": "\"unsupported\"" + }, + "value": "unsupported" + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js new file mode 100644 index 000000000000..cfa5d6ec452c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js @@ -0,0 +1 @@ +import "foo" assert { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json new file mode 100644 index 000000000000..bd21352ea468 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module", + "throws": "Unexpected token, expected \":\" (1:26)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js new file mode 100644 index 000000000000..e316ef9d4abe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js @@ -0,0 +1 @@ +import "foo" \u{61}ssert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json new file mode 100644 index 000000000000..94e3f3742509 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json new file mode 100644 index 000000000000..966dec7cb644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "errors": [ + "SyntaxError: Missing semicolon. (1:12)", + "SyntaxError: Missing semicolon. (1:24)" + ], + "program": { + "type": "Program", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24}}, + "expression": { + "type": "Identifier", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":25,"end":41,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":41,"index":41}}, + "body": [ + { + "type": "LabeledStatement", + "start":27,"end":39,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":39,"index":39}}, + "body": { + "type": "ExpressionStatement", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "expression": { + "type": "StringLiteral", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":27,"end":31,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":31,"index":31},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":41,"end":42,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":42,"index":42}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js new file mode 100644 index 000000000000..cf94fe6e3cf3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo } assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json new file mode 100644 index 000000000000..dbfe1111af51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json new file mode 100644 index 000000000000..7f73183b8a8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:14)", + "SyntaxError: Missing semicolon. (2:21)" + ], + "program": { + "type": "Program", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":13,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":13,"index":13}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":15,"end":29,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":14,"index":29}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27}}, + "local": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36}}, + "expression": { + "type": "Identifier", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":37,"end":53,"loc":{"start":{"line":2,"column":22,"index":37},"end":{"line":2,"column":38,"index":53}}, + "body": [ + { + "type": "LabeledStatement", + "start":39,"end":51,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":36,"index":51}}, + "body": { + "type": "ExpressionStatement", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "expression": { + "type": "StringLiteral", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":39,"end":43,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":28,"index":43},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":53,"end":54,"loc":{"start":{"line":2,"column":38,"index":53},"end":{"line":2,"column":39,"index":54}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/input.js new file mode 100644 index 000000000000..0a9420c378f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/input.js @@ -0,0 +1 @@ +import("./foo.json", ...[]); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/output.json new file mode 100644 index 000000000000..dd7456506eef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-spread-element-import-call/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "errors": [ + "SyntaxError: `...` is not allowed in `import()`. (1:21)" + ], + "program": { + "type": "Program", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "expression": { + "type": "CallExpression", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "SpreadElement", + "start":21,"end":26,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":26,"index":26}}, + "argument": { + "type": "ArrayExpression", + "start":24,"end":26,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":26,"index":26}}, + "elements": [] + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js new file mode 100644 index 000000000000..1e421736cffd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json new file mode 100644 index 000000000000..70cab9f66df6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:65)" + ], + "program": { + "type": "Program", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":65,"end":77,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":77,"index":77}}, + "key": { + "type": "Identifier", + "start":65,"end":69,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":69,"index":69},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":71,"end":77,"loc":{"start":{"line":1,"column":71,"index":71},"end":{"line":1,"column":77,"index":77}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js new file mode 100644 index 000000000000..a6db9b5aacbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js @@ -0,0 +1 @@ +export { x } from "foo" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json new file mode 100644 index 000000000000..cf68988c8da6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [["importAssertions"]], + "sourceType": "module", + "throws": "Unexpected token (1:30)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js new file mode 100644 index 000000000000..ce0c366a9c9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js @@ -0,0 +1,2 @@ +import "foo" +assert { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json new file mode 100644 index 000000000000..7001818ec913 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:6)" + ], + "program": { + "type": "Program", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19}}, + "expression": { + "type": "Identifier", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":20,"end":36,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":23,"index":36}}, + "body": [ + { + "type": "LabeledStatement", + "start":22,"end":34,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":21,"index":34}}, + "body": { + "type": "ExpressionStatement", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "expression": { + "type": "StringLiteral", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":13,"index":26},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js new file mode 100644 index 000000000000..2330d9eaed15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { "type": "json", type: "html", "type": "js" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json new file mode 100644 index 000000000000..a41fd7dfce8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:52)", + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:66)" + ], + "program": { + "type": "Program", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, + "key": { + "type": "StringLiteral", + "start":36,"end":42,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":42,"index":42}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":44,"end":50,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":50,"index":50}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":52,"end":64,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":64,"index":64}}, + "key": { + "type": "Identifier", + "start":52,"end":56,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":56,"index":56},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":58,"end":64,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":64,"index":64}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + }, + { + "type": "ImportAttribute", + "start":66,"end":78,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":78,"index":78}}, + "key": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":78,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":78,"index":78}}, + "extra": { + "rawValue": "js", + "raw": "\"js\"" + }, + "value": "js" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js new file mode 100644 index 000000000000..7fcebc0d4fe6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json new file mode 100644 index 000000000000..fa45e8188e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json @@ -0,0 +1,78 @@ +{ + "type": "File", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)" + ], + "program": { + "type": "Program", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js new file mode 100644 index 000000000000..e2920266c8ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js @@ -0,0 +1 @@ +import "x" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json new file mode 100644 index 000000000000..7f991d8162b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module", + "throws": "Unexpected token (1:17)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/options.json new file mode 100644 index 000000000000..94e3f3742509 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js new file mode 100644 index 000000000000..1c1e4b79e789 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" assert { for: "for" } +export { foo } from "foo.json" assert { for: "for" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json new file mode 100644 index 000000000000..bb201929becd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "program": { + "type": "Program", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":36,"end":39,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":39,"index":39},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":41,"end":46,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":49,"end":101,"loc":{"start":{"line":2,"column":0,"index":49},"end":{"line":2,"column":52,"index":101}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61}}, + "local": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":69,"end":79,"loc":{"start":{"line":2,"column":20,"index":69},"end":{"line":2,"column":30,"index":79}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, + "key": { + "type": "Identifier", + "start":89,"end":92,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":43,"index":92},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":94,"end":99,"loc":{"start":{"line":2,"column":45,"index":94},"end":{"line":2,"column":50,"index":99}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..b448aa280c34 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { assert: { type: "json" } },); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json new file mode 100644 index 000000000000..e484d6873f0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "program": { + "type": "Program", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":18,"index":18}}, + "expression": { + "type": "CallExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "extra": { + "trailingComma": 15 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "extra": { + "rawValue": "foo.js", + "raw": "\"foo.js\"" + }, + "value": "foo.js" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, + "expression": { + "type": "CallExpression", + "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, + "callee": { + "type": "Import", + "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} + }, + "extra": { + "trailingComma": 66 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":26,"end":36,"loc":{"start":{"line":2,"column":7,"index":26},"end":{"line":2,"column":17,"index":36}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, + "properties": [ + { + "type": "ObjectProperty", + "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, + "method": false, + "key": { + "type": "Identifier", + "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, + "properties": [ + { + "type": "ObjectProperty", + "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, + "method": false, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js new file mode 100644 index 000000000000..077d150d81ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" assert { type: "json", } +export { default as foo } from "foo" assert { type: "json", } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json new file mode 100644 index 000000000000..77f11f2c63a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "program": { + "type": "Program", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":21,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":47,"end":108,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":61,"index":108}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":56,"end":70,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":23,"index":70}}, + "local": { + "type": "Identifier", + "start":56,"end":63,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":16,"index":63},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":67,"end":70,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":23,"index":70},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":78,"end":83,"loc":{"start":{"line":2,"column":31,"index":78},"end":{"line":2,"column":36,"index":83}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, + "key": { + "type": "Identifier", + "start":93,"end":97,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":50,"index":97},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":99,"end":105,"loc":{"start":{"line":2,"column":52,"index":99},"end":{"line":2,"column":58,"index":105}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js new file mode 100644 index 000000000000..758659de4037 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" assert {}; +import * as ns from "foo" assert {}; +export { quux } from "foo" assert {}; +export * as ns2 from "foo" assert {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json new file mode 100644 index 000000000000..7bb565c095bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "program": { + "type": "Program", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":41,"index":41}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + }, + { + "type": "ImportSpecifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17}}, + "imported": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + }, + "local": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":25,"end":30,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ImportDeclaration", + "start":42,"end":78,"loc":{"start":{"line":2,"column":0,"index":42},"end":{"line":2,"column":36,"index":78}}, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "start":49,"end":56,"loc":{"start":{"line":2,"column":7,"index":49},"end":{"line":2,"column":14,"index":56}}, + "local": { + "type": "Identifier", + "start":54,"end":56,"loc":{"start":{"line":2,"column":12,"index":54},"end":{"line":2,"column":14,"index":56},"identifierName":"ns"}, + "name": "ns" + } + } + ], + "source": { + "type": "StringLiteral", + "start":62,"end":67,"loc":{"start":{"line":2,"column":20,"index":62},"end":{"line":2,"column":25,"index":67}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":79,"end":116,"loc":{"start":{"line":3,"column":0,"index":79},"end":{"line":3,"column":37,"index":116}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92}}, + "local": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + }, + "exported": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + } + } + ], + "source": { + "type": "StringLiteral", + "start":100,"end":105,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":3,"column":26,"index":105}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":117,"end":154,"loc":{"start":{"line":4,"column":0,"index":117},"end":{"line":4,"column":37,"index":154}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":124,"end":132,"loc":{"start":{"line":4,"column":7,"index":124},"end":{"line":4,"column":15,"index":132}}, + "exported": { + "type": "Identifier", + "start":129,"end":132,"loc":{"start":{"line":4,"column":12,"index":129},"end":{"line":4,"column":15,"index":132},"identifierName":"ns2"}, + "name": "ns2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":138,"end":143,"loc":{"start":{"line":4,"column":21,"index":138},"end":{"line":4,"column":26,"index":143}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/output.json new file mode 100644 index 000000000000..aca45ad21ed1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-class/output.json @@ -0,0 +1,35 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "ClassDeclaration", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"Foo"}, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":17,"end":19,"loc":{"start":{"line":1,"column":17,"index":17},"end":{"line":1,"column":19,"index":19}}, + "body": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/output.json new file mode 100644 index 000000000000..0ee5e9db8111 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-function/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "program": { + "type": "Program", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "FunctionDeclaration", + "start":7,"end":24,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":24,"index":24}}, + "id": { + "type": "Identifier", + "start":16,"end":19,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":19,"index":19},"identifierName":"foo"}, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":24,"index":24}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/output.json new file mode 100644 index 000000000000..c653fb95cd93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-variable/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "VariableDeclaration", + "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":13,"end":21,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":21,"index":21}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":19,"end":21,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/output.json new file mode 100644 index 000000000000..8e9b3109b83e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-export-without-from/output.json @@ -0,0 +1,61 @@ +{ + "type": "File", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "program": { + "type": "Program", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":15,"index":15}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":14,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":14,"index":14}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":12,"end":14,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":14,"index":14}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":17,"end":32,"loc":{"start":{"line":3,"column":0,"index":17},"end":{"line":3,"column":15,"index":32}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29}}, + "local": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js new file mode 100644 index 000000000000..dcc37efe8067 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js @@ -0,0 +1 @@ +import "foo" assert { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json new file mode 100644 index 000000000000..b89ace5ec3fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json @@ -0,0 +1,51 @@ +{ + "type": "File", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "program": { + "type": "Program", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, + "key": { + "type": "StringLiteral", + "start":22,"end":28,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":28,"index":28}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":30,"end":36,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..f97e9ee25718 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json new file mode 100644 index 000000000000..65d77c809f2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "program": { + "type": "Program", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "exported": { + "type": "Identifier", + "start":12,"end":15,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":15,"index":15},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":21,"end":31,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":31,"index":31}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, + "key": { + "type": "Identifier", + "start":41,"end":45,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":45,"index":45},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":47,"end":53,"loc":{"start":{"line":1,"column":47,"index":47},"end":{"line":1,"column":53,"index":53}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..b8a5d6580862 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json new file mode 100644 index 000000000000..9b526a568057 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "program": { + "type": "Program", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportAllDeclaration", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "source": { + "type": "StringLiteral", + "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..a3830551716f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..88f1415f189c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "program": { + "type": "Program", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":21,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":21,"index":21}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":21,"index":21},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":29,"end":34,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":6,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":2,"column":8,"index":50},"end":{"line":2,"column":14,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..567f6335c84c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json new file mode 100644 index 000000000000..c947ca3ee8d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "program": { + "type": "Program", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":60,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":60,"index":60}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "StringLiteral", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":18,"index":18}}, + "extra": { + "rawValue": "default", + "raw": "\"default\"" + }, + "value": "default" + }, + "exported": { + "type": "Identifier", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":23,"index":23},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":36,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, + "key": { + "type": "Identifier", + "start":46,"end":50,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":50,"index":50},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":52,"end":58,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":58,"index":58}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "expression": { + "type": "ArrayExpression", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "elements": [ + { + "type": "NumericLiteral", + "start":62,"end":63,"loc":{"start":{"line":2,"column":1,"index":62},"end":{"line":2,"column":2,"index":63}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..08775ba22ed4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json new file mode 100644 index 000000000000..ef4f180d3be1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "program": { + "type": "Program", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..23710fef0b6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..75cee0d1de51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..5dbd2c429901 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json new file mode 100644 index 000000000000..3342a818b5fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "program": { + "type": "Program", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..8acdf464a395 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json new file mode 100644 index 000000000000..4a4a18b389c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "program": { + "type": "Program", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":58,"end":80,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":80,"index":80}}, + "key": { + "type": "Identifier", + "start":58,"end":72,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":72,"index":72},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":80,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":80,"index":80}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json new file mode 100644 index 000000000000..d1a3c1dde93b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "program": { + "type": "Program", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":20,"end":30,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..4f1ee63fb3a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json new file mode 100644 index 000000000000..da75c3198d9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":34,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":24,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":32,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "expression": { + "type": "ArrayExpression", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "elements": [ + { + "type": "NumericLiteral", + "start":36,"end":37,"loc":{"start":{"line":2,"column":1,"index":36},"end":{"line":2,"column":2,"index":37}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..92c0d33eddd0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..c11f4c7ce6cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "program": { + "type": "Program", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":6,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":14,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json new file mode 100644 index 000000000000..264361dead53 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..01425ab2e2e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..c70777c18cfa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..bdcedd93bb26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json new file mode 100644 index 000000000000..7f5e6b799987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..828d93472261 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json new file mode 100644 index 000000000000..c15b8c2d4f45 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":72,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":72,"index":72}}, + "key": { + "type": "Identifier", + "start":50,"end":64,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":64,"index":64},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json new file mode 100644 index 000000000000..8f00ebbb3e89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "program": { + "type": "Program", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json new file mode 100644 index 000000000000..28d88bde86ea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..481c52e1c75f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { assert: { type: "json" } }) diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json new file mode 100644 index 000000000000..6a600725554a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "program": { + "type": "Program", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "expression": { + "type": "CallExpression", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":17,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":17,"index":17}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, + "properties": [ + { + "type": "ObjectProperty", + "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, + "method": false, + "key": { + "type": "Identifier", + "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, + "properties": [ + { + "type": "ObjectProperty", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "method": false, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js new file mode 100644 index 000000000000..5b6c5fa3373a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +assert ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json new file mode 100644 index 000000000000..dff75e218c42 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "program": { + "type": "Program", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":11,"end":23,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":12,"index":23}}, + "expression": { + "type": "CallExpression", + "start":11,"end":22,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":11,"index":22}}, + "callee": { + "type": "Identifier", + "start":11,"end":17,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":6,"index":17},"identifierName":"assert"}, + "name": "assert" + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":19,"end":21,"loc":{"start":{"line":2,"column":8,"index":19},"end":{"line":2,"column":10,"index":21}}, + "properties": [] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js new file mode 100644 index 000000000000..0863c2ee4884 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js @@ -0,0 +1,2 @@ +import(); +import("./foo.json", { assert: { type: "json"} }, "unsupported"); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json new file mode 100644 index 000000000000..1075711b669a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "errors": [ + "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", + "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" + ], + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "expression": { + "type": "CallExpression", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":8,"index":8}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start":10,"end":75,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":65,"index":75}}, + "expression": { + "type": "CallExpression", + "start":10,"end":74,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":64,"index":74}}, + "callee": { + "type": "Import", + "start":10,"end":16,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":6,"index":16}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":17,"end":29,"loc":{"start":{"line":2,"column":7,"index":17},"end":{"line":2,"column":19,"index":29}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "ObjectExpression", + "start":31,"end":58,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":48,"index":58}}, + "properties": [ + { + "type": "ObjectProperty", + "start":33,"end":56,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":46,"index":56}}, + "method": false, + "key": { + "type": "Identifier", + "start":33,"end":39,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":29,"index":39},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":41,"end":56,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":46,"index":56}}, + "properties": [ + { + "type": "ObjectProperty", + "start":43,"end":55,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":45,"index":55}}, + "method": false, + "key": { + "type": "Identifier", + "start":43,"end":47,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":37,"index":47},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":49,"end":55,"loc":{"start":{"line":2,"column":39,"index":49},"end":{"line":2,"column":45,"index":55}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + }, + { + "type": "StringLiteral", + "start":60,"end":73,"loc":{"start":{"line":2,"column":50,"index":60},"end":{"line":2,"column":63,"index":73}}, + "extra": { + "rawValue": "unsupported", + "raw": "\"unsupported\"" + }, + "value": "unsupported" + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js new file mode 100644 index 000000000000..cfa5d6ec452c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js @@ -0,0 +1 @@ +import "foo" assert { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json new file mode 100644 index 000000000000..a5800dc58846 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module", + "throws": "Unexpected token, expected \":\" (1:26)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js new file mode 100644 index 000000000000..e316ef9d4abe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js @@ -0,0 +1 @@ +import "foo" \u{61}ssert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json new file mode 100644 index 000000000000..5065055eb5eb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json new file mode 100644 index 000000000000..966dec7cb644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "errors": [ + "SyntaxError: Missing semicolon. (1:12)", + "SyntaxError: Missing semicolon. (1:24)" + ], + "program": { + "type": "Program", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24}}, + "expression": { + "type": "Identifier", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":25,"end":41,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":41,"index":41}}, + "body": [ + { + "type": "LabeledStatement", + "start":27,"end":39,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":39,"index":39}}, + "body": { + "type": "ExpressionStatement", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "expression": { + "type": "StringLiteral", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":27,"end":31,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":31,"index":31},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":41,"end":42,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":42,"index":42}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js new file mode 100644 index 000000000000..cf94fe6e3cf3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo } assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json new file mode 100644 index 000000000000..ac19d36b8567 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json new file mode 100644 index 000000000000..7f73183b8a8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:14)", + "SyntaxError: Missing semicolon. (2:21)" + ], + "program": { + "type": "Program", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":13,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":13,"index":13}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":15,"end":29,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":14,"index":29}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27}}, + "local": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36}}, + "expression": { + "type": "Identifier", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":37,"end":53,"loc":{"start":{"line":2,"column":22,"index":37},"end":{"line":2,"column":38,"index":53}}, + "body": [ + { + "type": "LabeledStatement", + "start":39,"end":51,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":36,"index":51}}, + "body": { + "type": "ExpressionStatement", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "expression": { + "type": "StringLiteral", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":39,"end":43,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":28,"index":43},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":53,"end":54,"loc":{"start":{"line":2,"column":38,"index":53},"end":{"line":2,"column":39,"index":54}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js new file mode 100644 index 000000000000..0a9420c378f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js @@ -0,0 +1 @@ +import("./foo.json", ...[]); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json new file mode 100644 index 000000000000..dd7456506eef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "errors": [ + "SyntaxError: `...` is not allowed in `import()`. (1:21)" + ], + "program": { + "type": "Program", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "expression": { + "type": "CallExpression", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "SpreadElement", + "start":21,"end":26,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":26,"index":26}}, + "argument": { + "type": "ArrayExpression", + "start":24,"end":26,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":26,"index":26}}, + "elements": [] + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js new file mode 100644 index 000000000000..1e421736cffd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json new file mode 100644 index 000000000000..70cab9f66df6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:65)" + ], + "program": { + "type": "Program", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":65,"end":77,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":77,"index":77}}, + "key": { + "type": "Identifier", + "start":65,"end":69,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":69,"index":69},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":71,"end":77,"loc":{"start":{"line":1,"column":71,"index":71},"end":{"line":1,"column":77,"index":77}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js new file mode 100644 index 000000000000..a6db9b5aacbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js @@ -0,0 +1 @@ +export { x } from "foo" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json new file mode 100644 index 000000000000..12a6493c7c4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [[["importAttributes", { "deprecatedAssertSyntax": true }]]], + "sourceType": "module", + "throws": "Unexpected token (1:30)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js new file mode 100644 index 000000000000..ce0c366a9c9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js @@ -0,0 +1,2 @@ +import "foo" +assert { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json new file mode 100644 index 000000000000..7001818ec913 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:6)" + ], + "program": { + "type": "Program", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19}}, + "expression": { + "type": "Identifier", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":20,"end":36,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":23,"index":36}}, + "body": [ + { + "type": "LabeledStatement", + "start":22,"end":34,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":21,"index":34}}, + "body": { + "type": "ExpressionStatement", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "expression": { + "type": "StringLiteral", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":13,"index":26},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js new file mode 100644 index 000000000000..2330d9eaed15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { "type": "json", type: "html", "type": "js" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json new file mode 100644 index 000000000000..a41fd7dfce8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:52)", + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:66)" + ], + "program": { + "type": "Program", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, + "key": { + "type": "StringLiteral", + "start":36,"end":42,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":42,"index":42}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":44,"end":50,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":50,"index":50}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":52,"end":64,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":64,"index":64}}, + "key": { + "type": "Identifier", + "start":52,"end":56,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":56,"index":56},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":58,"end":64,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":64,"index":64}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + }, + { + "type": "ImportAttribute", + "start":66,"end":78,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":78,"index":78}}, + "key": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":78,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":78,"index":78}}, + "extra": { + "rawValue": "js", + "raw": "\"js\"" + }, + "value": "js" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js new file mode 100644 index 000000000000..7fcebc0d4fe6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json new file mode 100644 index 000000000000..fa45e8188e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json @@ -0,0 +1,78 @@ +{ + "type": "File", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)" + ], + "program": { + "type": "Program", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js new file mode 100644 index 000000000000..e2920266c8ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js @@ -0,0 +1 @@ +import "x" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json new file mode 100644 index 000000000000..441eba531e76 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module", + "throws": "Unexpected token (1:17)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json new file mode 100644 index 000000000000..85aa77c49fdc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["importAttributes", { "deprecatedAssertSyntax": true }]], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js new file mode 100644 index 000000000000..1c1e4b79e789 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" assert { for: "for" } +export { foo } from "foo.json" assert { for: "for" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json new file mode 100644 index 000000000000..bb201929becd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "program": { + "type": "Program", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":36,"end":39,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":39,"index":39},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":41,"end":46,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":49,"end":101,"loc":{"start":{"line":2,"column":0,"index":49},"end":{"line":2,"column":52,"index":101}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61}}, + "local": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":69,"end":79,"loc":{"start":{"line":2,"column":20,"index":69},"end":{"line":2,"column":30,"index":79}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, + "key": { + "type": "Identifier", + "start":89,"end":92,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":43,"index":92},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":94,"end":99,"loc":{"start":{"line":2,"column":45,"index":94},"end":{"line":2,"column":50,"index":99}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..b448aa280c34 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { assert: { type: "json" } },); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json new file mode 100644 index 000000000000..e484d6873f0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "program": { + "type": "Program", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":18,"index":18}}, + "expression": { + "type": "CallExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "extra": { + "trailingComma": 15 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "extra": { + "rawValue": "foo.js", + "raw": "\"foo.js\"" + }, + "value": "foo.js" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, + "expression": { + "type": "CallExpression", + "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, + "callee": { + "type": "Import", + "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} + }, + "extra": { + "trailingComma": 66 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":26,"end":36,"loc":{"start":{"line":2,"column":7,"index":26},"end":{"line":2,"column":17,"index":36}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, + "properties": [ + { + "type": "ObjectProperty", + "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, + "method": false, + "key": { + "type": "Identifier", + "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, + "properties": [ + { + "type": "ObjectProperty", + "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, + "method": false, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js new file mode 100644 index 000000000000..077d150d81ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" assert { type: "json", } +export { default as foo } from "foo" assert { type: "json", } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json new file mode 100644 index 000000000000..77f11f2c63a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "program": { + "type": "Program", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":21,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":47,"end":108,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":61,"index":108}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":56,"end":70,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":23,"index":70}}, + "local": { + "type": "Identifier", + "start":56,"end":63,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":16,"index":63},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":67,"end":70,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":23,"index":70},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":78,"end":83,"loc":{"start":{"line":2,"column":31,"index":78},"end":{"line":2,"column":36,"index":83}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, + "key": { + "type": "Identifier", + "start":93,"end":97,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":50,"index":97},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":99,"end":105,"loc":{"start":{"line":2,"column":52,"index":99},"end":{"line":2,"column":58,"index":105}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js new file mode 100644 index 000000000000..758659de4037 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" assert {}; +import * as ns from "foo" assert {}; +export { quux } from "foo" assert {}; +export * as ns2 from "foo" assert {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json new file mode 100644 index 000000000000..7bb565c095bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "program": { + "type": "Program", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":41,"index":41}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + }, + { + "type": "ImportSpecifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17}}, + "imported": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + }, + "local": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":25,"end":30,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ImportDeclaration", + "start":42,"end":78,"loc":{"start":{"line":2,"column":0,"index":42},"end":{"line":2,"column":36,"index":78}}, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "start":49,"end":56,"loc":{"start":{"line":2,"column":7,"index":49},"end":{"line":2,"column":14,"index":56}}, + "local": { + "type": "Identifier", + "start":54,"end":56,"loc":{"start":{"line":2,"column":12,"index":54},"end":{"line":2,"column":14,"index":56},"identifierName":"ns"}, + "name": "ns" + } + } + ], + "source": { + "type": "StringLiteral", + "start":62,"end":67,"loc":{"start":{"line":2,"column":20,"index":62},"end":{"line":2,"column":25,"index":67}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":79,"end":116,"loc":{"start":{"line":3,"column":0,"index":79},"end":{"line":3,"column":37,"index":116}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92}}, + "local": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + }, + "exported": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + } + } + ], + "source": { + "type": "StringLiteral", + "start":100,"end":105,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":3,"column":26,"index":105}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":117,"end":154,"loc":{"start":{"line":4,"column":0,"index":117},"end":{"line":4,"column":37,"index":154}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":124,"end":132,"loc":{"start":{"line":4,"column":7,"index":124},"end":{"line":4,"column":15,"index":132}}, + "exported": { + "type": "Identifier", + "start":129,"end":132,"loc":{"start":{"line":4,"column":12,"index":129},"end":{"line":4,"column":15,"index":132},"identifierName":"ns2"}, + "name": "ns2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":138,"end":143,"loc":{"start":{"line":4,"column":21,"index":138},"end":{"line":4,"column":26,"index":143}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json new file mode 100644 index 000000000000..aca45ad21ed1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json @@ -0,0 +1,35 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "ClassDeclaration", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"Foo"}, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":17,"end":19,"loc":{"start":{"line":1,"column":17,"index":17},"end":{"line":1,"column":19,"index":19}}, + "body": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json new file mode 100644 index 000000000000..0ee5e9db8111 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "program": { + "type": "Program", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "FunctionDeclaration", + "start":7,"end":24,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":24,"index":24}}, + "id": { + "type": "Identifier", + "start":16,"end":19,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":19,"index":19},"identifierName":"foo"}, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":24,"index":24}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json new file mode 100644 index 000000000000..c653fb95cd93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "VariableDeclaration", + "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":13,"end":21,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":21,"index":21}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":19,"end":21,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json new file mode 100644 index 000000000000..8e9b3109b83e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json @@ -0,0 +1,61 @@ +{ + "type": "File", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "program": { + "type": "Program", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":15,"index":15}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":14,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":14,"index":14}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":12,"end":14,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":14,"index":14}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":17,"end":32,"loc":{"start":{"line":3,"column":0,"index":17},"end":{"line":3,"column":15,"index":32}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29}}, + "local": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js new file mode 100644 index 000000000000..dcc37efe8067 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js @@ -0,0 +1 @@ +import "foo" assert { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json new file mode 100644 index 000000000000..b89ace5ec3fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json @@ -0,0 +1,51 @@ +{ + "type": "File", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "program": { + "type": "Program", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, + "key": { + "type": "StringLiteral", + "start":22,"end":28,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":28,"index":28}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":30,"end":36,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..f97e9ee25718 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json new file mode 100644 index 000000000000..65d77c809f2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "program": { + "type": "Program", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "exported": { + "type": "Identifier", + "start":12,"end":15,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":15,"index":15},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":21,"end":31,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":31,"index":31}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, + "key": { + "type": "Identifier", + "start":41,"end":45,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":45,"index":45},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":47,"end":53,"loc":{"start":{"line":1,"column":47,"index":47},"end":{"line":1,"column":53,"index":53}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..b8a5d6580862 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json new file mode 100644 index 000000000000..9b526a568057 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "program": { + "type": "Program", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportAllDeclaration", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "source": { + "type": "StringLiteral", + "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..a3830551716f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..88f1415f189c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "program": { + "type": "Program", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":21,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":21,"index":21}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":21,"index":21},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":29,"end":34,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":6,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":2,"column":8,"index":50},"end":{"line":2,"column":14,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..567f6335c84c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json new file mode 100644 index 000000000000..c947ca3ee8d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "program": { + "type": "Program", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":60,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":60,"index":60}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "StringLiteral", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":18,"index":18}}, + "extra": { + "rawValue": "default", + "raw": "\"default\"" + }, + "value": "default" + }, + "exported": { + "type": "Identifier", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":23,"index":23},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":36,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, + "key": { + "type": "Identifier", + "start":46,"end":50,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":50,"index":50},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":52,"end":58,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":58,"index":58}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "expression": { + "type": "ArrayExpression", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "elements": [ + { + "type": "NumericLiteral", + "start":62,"end":63,"loc":{"start":{"line":2,"column":1,"index":62},"end":{"line":2,"column":2,"index":63}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..08775ba22ed4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json new file mode 100644 index 000000000000..ef4f180d3be1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "program": { + "type": "Program", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..23710fef0b6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..f4dfaf194d1c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..5dbd2c429901 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json new file mode 100644 index 000000000000..3342a818b5fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "program": { + "type": "Program", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..8acdf464a395 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json new file mode 100644 index 000000000000..4a4a18b389c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "program": { + "type": "Program", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":58,"end":80,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":80,"index":80}}, + "key": { + "type": "Identifier", + "start":58,"end":72,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":72,"index":72},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":80,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":80,"index":80}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json new file mode 100644 index 000000000000..d1a3c1dde93b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "program": { + "type": "Program", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":20,"end":30,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..4f1ee63fb3a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json new file mode 100644 index 000000000000..da75c3198d9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":34,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":24,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":32,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "expression": { + "type": "ArrayExpression", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "elements": [ + { + "type": "NumericLiteral", + "start":36,"end":37,"loc":{"start":{"line":2,"column":1,"index":36},"end":{"line":2,"column":2,"index":37}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..92c0d33eddd0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..c11f4c7ce6cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "program": { + "type": "Program", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":6,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":14,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json new file mode 100644 index 000000000000..264361dead53 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..01425ab2e2e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..24f89b10b845 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..bdcedd93bb26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json new file mode 100644 index 000000000000..7f5e6b799987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..828d93472261 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json new file mode 100644 index 000000000000..c15b8c2d4f45 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":72,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":72,"index":72}}, + "key": { + "type": "Identifier", + "start":50,"end":64,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":64,"index":64},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json new file mode 100644 index 000000000000..8f00ebbb3e89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "program": { + "type": "Program", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json new file mode 100644 index 000000000000..ef8b957b9903 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:27)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..481c52e1c75f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { assert: { type: "json" } }) diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json new file mode 100644 index 000000000000..6a600725554a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "program": { + "type": "Program", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "expression": { + "type": "CallExpression", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":17,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":17,"index":17}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, + "properties": [ + { + "type": "ObjectProperty", + "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, + "method": false, + "key": { + "type": "Identifier", + "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, + "properties": [ + { + "type": "ObjectProperty", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "method": false, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js new file mode 100644 index 000000000000..5b6c5fa3373a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +assert ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json new file mode 100644 index 000000000000..dff75e218c42 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "program": { + "type": "Program", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":11,"end":23,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":12,"index":23}}, + "expression": { + "type": "CallExpression", + "start":11,"end":22,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":11,"index":22}}, + "callee": { + "type": "Identifier", + "start":11,"end":17,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":6,"index":17},"identifierName":"assert"}, + "name": "assert" + }, + "arguments": [ + { + "type": "ObjectExpression", + "start":19,"end":21,"loc":{"start":{"line":2,"column":8,"index":19},"end":{"line":2,"column":10,"index":21}}, + "properties": [] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js new file mode 100644 index 000000000000..0863c2ee4884 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js @@ -0,0 +1,2 @@ +import(); +import("./foo.json", { assert: { type: "json"} }, "unsupported"); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json new file mode 100644 index 000000000000..1075711b669a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "errors": [ + "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", + "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" + ], + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "expression": { + "type": "CallExpression", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":8,"index":8}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start":10,"end":75,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":65,"index":75}}, + "expression": { + "type": "CallExpression", + "start":10,"end":74,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":64,"index":74}}, + "callee": { + "type": "Import", + "start":10,"end":16,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":6,"index":16}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":17,"end":29,"loc":{"start":{"line":2,"column":7,"index":17},"end":{"line":2,"column":19,"index":29}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "ObjectExpression", + "start":31,"end":58,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":48,"index":58}}, + "properties": [ + { + "type": "ObjectProperty", + "start":33,"end":56,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":46,"index":56}}, + "method": false, + "key": { + "type": "Identifier", + "start":33,"end":39,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":29,"index":39},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":41,"end":56,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":46,"index":56}}, + "properties": [ + { + "type": "ObjectProperty", + "start":43,"end":55,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":45,"index":55}}, + "method": false, + "key": { + "type": "Identifier", + "start":43,"end":47,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":37,"index":47},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":49,"end":55,"loc":{"start":{"line":2,"column":39,"index":49},"end":{"line":2,"column":45,"index":55}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + }, + { + "type": "StringLiteral", + "start":60,"end":73,"loc":{"start":{"line":2,"column":50,"index":60},"end":{"line":2,"column":63,"index":73}}, + "extra": { + "rawValue": "unsupported", + "raw": "\"unsupported\"" + }, + "value": "unsupported" + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js new file mode 100644 index 000000000000..cfa5d6ec452c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js @@ -0,0 +1 @@ +import "foo" assert { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json new file mode 100644 index 000000000000..079a016c4661 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module", + "throws": "Unexpected token, expected \":\" (1:26)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js new file mode 100644 index 000000000000..e316ef9d4abe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js @@ -0,0 +1 @@ +import "foo" \u{61}ssert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json new file mode 100644 index 000000000000..f7821e2088eb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json new file mode 100644 index 000000000000..966dec7cb644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "errors": [ + "SyntaxError: Missing semicolon. (1:12)", + "SyntaxError: Missing semicolon. (1:24)" + ], + "program": { + "type": "Program", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24}}, + "expression": { + "type": "Identifier", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":25,"end":41,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":41,"index":41}}, + "body": [ + { + "type": "LabeledStatement", + "start":27,"end":39,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":39,"index":39}}, + "body": { + "type": "ExpressionStatement", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "expression": { + "type": "StringLiteral", + "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":27,"end":31,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":31,"index":31},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":41,"end":42,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":42,"index":42}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js new file mode 100644 index 000000000000..cf94fe6e3cf3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo } assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json new file mode 100644 index 000000000000..7b13c05e4000 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json new file mode 100644 index 000000000000..7f73183b8a8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:14)", + "SyntaxError: Missing semicolon. (2:21)" + ], + "program": { + "type": "Program", + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":13,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":13,"index":13}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":15,"end":29,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":14,"index":29}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27}}, + "local": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36}}, + "expression": { + "type": "Identifier", + "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":37,"end":53,"loc":{"start":{"line":2,"column":22,"index":37},"end":{"line":2,"column":38,"index":53}}, + "body": [ + { + "type": "LabeledStatement", + "start":39,"end":51,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":36,"index":51}}, + "body": { + "type": "ExpressionStatement", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "expression": { + "type": "StringLiteral", + "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":39,"end":43,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":28,"index":43},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + }, + { + "type": "EmptyStatement", + "start":53,"end":54,"loc":{"start":{"line":2,"column":38,"index":53},"end":{"line":2,"column":39,"index":54}} + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/input.js new file mode 100644 index 000000000000..0a9420c378f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/input.js @@ -0,0 +1 @@ +import("./foo.json", ...[]); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json new file mode 100644 index 000000000000..dd7456506eef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "errors": [ + "SyntaxError: `...` is not allowed in `import()`. (1:21)" + ], + "program": { + "type": "Program", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, + "expression": { + "type": "CallExpression", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "extra": { + "rawValue": "./foo.json", + "raw": "\"./foo.json\"" + }, + "value": "./foo.json" + }, + { + "type": "SpreadElement", + "start":21,"end":26,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":26,"index":26}}, + "argument": { + "type": "ArrayExpression", + "start":24,"end":26,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":26,"index":26}}, + "elements": [] + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js new file mode 100644 index 000000000000..1e421736cffd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json new file mode 100644 index 000000000000..70cab9f66df6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:65)" + ], + "program": { + "type": "Program", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":65,"end":77,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":77,"index":77}}, + "key": { + "type": "Identifier", + "start":65,"end":69,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":69,"index":69},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":71,"end":77,"loc":{"start":{"line":1,"column":71,"index":71},"end":{"line":1,"column":77,"index":77}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js new file mode 100644 index 000000000000..a6db9b5aacbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js @@ -0,0 +1 @@ +export { x } from "foo" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json new file mode 100644 index 000000000000..0626123e4168 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [["importAttributes"]], + "sourceType": "module", + "throws": "Unexpected token (1:30)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js new file mode 100644 index 000000000000..ce0c366a9c9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js @@ -0,0 +1,2 @@ +import "foo" +assert { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json new file mode 100644 index 000000000000..7001818ec913 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "errors": [ + "SyntaxError: Missing semicolon. (2:6)" + ], + "program": { + "type": "Program", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExpressionStatement", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19}}, + "expression": { + "type": "Identifier", + "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19},"identifierName":"assert"}, + "name": "assert" + } + }, + { + "type": "BlockStatement", + "start":20,"end":36,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":23,"index":36}}, + "body": [ + { + "type": "LabeledStatement", + "start":22,"end":34,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":21,"index":34}}, + "body": { + "type": "ExpressionStatement", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "expression": { + "type": "StringLiteral", + "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + "label": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":13,"index":26},"identifierName":"type"}, + "name": "type" + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js new file mode 100644 index 000000000000..2330d9eaed15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { "type": "json", type: "html", "type": "js" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json new file mode 100644 index 000000000000..a41fd7dfce8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:52)", + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:66)" + ], + "program": { + "type": "Program", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, + "key": { + "type": "StringLiteral", + "start":36,"end":42,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":42,"index":42}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":44,"end":50,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":50,"index":50}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":52,"end":64,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":64,"index":64}}, + "key": { + "type": "Identifier", + "start":52,"end":56,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":56,"index":56},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":58,"end":64,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":64,"index":64}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + }, + { + "type": "ImportAttribute", + "start":66,"end":78,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":78,"index":78}}, + "key": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":78,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":78,"index":78}}, + "extra": { + "rawValue": "js", + "raw": "\"js\"" + }, + "value": "js" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js new file mode 100644 index 000000000000..7fcebc0d4fe6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json new file mode 100644 index 000000000000..fa45e8188e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json @@ -0,0 +1,78 @@ +{ + "type": "File", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "errors": [ + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)" + ], + "program": { + "type": "Program", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, + "extra": { + "rawValue": "html", + "raw": "\"html\"" + }, + "value": "html" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js new file mode 100644 index 000000000000..e2920266c8ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js @@ -0,0 +1 @@ +import "x" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json new file mode 100644 index 000000000000..cbefdaa6edd8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module", + "throws": "Unexpected token (1:17)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/options.json new file mode 100644 index 000000000000..cc7fb4a170d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["importAttributes"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js new file mode 100644 index 000000000000..1c1e4b79e789 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" assert { for: "for" } +export { foo } from "foo.json" assert { for: "for" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json new file mode 100644 index 000000000000..bb201929becd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "program": { + "type": "Program", + "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":36,"end":39,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":39,"index":39},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":41,"end":46,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":49,"end":101,"loc":{"start":{"line":2,"column":0,"index":49},"end":{"line":2,"column":52,"index":101}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61}}, + "local": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":69,"end":79,"loc":{"start":{"line":2,"column":20,"index":69},"end":{"line":2,"column":30,"index":79}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, + "key": { + "type": "Identifier", + "start":89,"end":92,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":43,"index":92},"identifierName":"for"}, + "name": "for" + }, + "value": { + "type": "StringLiteral", + "start":94,"end":99,"loc":{"start":{"line":2,"column":45,"index":94},"end":{"line":2,"column":50,"index":99}}, + "extra": { + "rawValue": "for", + "raw": "\"for\"" + }, + "value": "for" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..b448aa280c34 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { assert: { type: "json" } },); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json new file mode 100644 index 000000000000..e484d6873f0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "program": { + "type": "Program", + "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":18,"index":18}}, + "expression": { + "type": "CallExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, + "callee": { + "type": "Import", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} + }, + "extra": { + "trailingComma": 15 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "extra": { + "rawValue": "foo.js", + "raw": "\"foo.js\"" + }, + "value": "foo.js" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, + "expression": { + "type": "CallExpression", + "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, + "callee": { + "type": "Import", + "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} + }, + "extra": { + "trailingComma": 66 + }, + "arguments": [ + { + "type": "StringLiteral", + "start":26,"end":36,"loc":{"start":{"line":2,"column":7,"index":26},"end":{"line":2,"column":17,"index":36}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + { + "type": "ObjectExpression", + "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, + "properties": [ + { + "type": "ObjectProperty", + "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, + "method": false, + "key": { + "type": "Identifier", + "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, + "name": "assert" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, + "properties": [ + { + "type": "ObjectProperty", + "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, + "method": false, + "key": { + "type": "Identifier", + "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, + "name": "type" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "StringLiteral", + "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js new file mode 100644 index 000000000000..077d150d81ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" assert { type: "json", } +export { default as foo } from "foo" assert { type: "json", } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json new file mode 100644 index 000000000000..77f11f2c63a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "program": { + "type": "Program", + "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":21,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "key": { + "type": "Identifier", + "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExportNamedDeclaration", + "start":47,"end":108,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":61,"index":108}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":56,"end":70,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":23,"index":70}}, + "local": { + "type": "Identifier", + "start":56,"end":63,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":16,"index":63},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":67,"end":70,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":23,"index":70},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":78,"end":83,"loc":{"start":{"line":2,"column":31,"index":78},"end":{"line":2,"column":36,"index":83}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, + "key": { + "type": "Identifier", + "start":93,"end":97,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":50,"index":97},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":99,"end":105,"loc":{"start":{"line":2,"column":52,"index":99},"end":{"line":2,"column":58,"index":105}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js new file mode 100644 index 000000000000..758659de4037 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" assert {}; +import * as ns from "foo" assert {}; +export { quux } from "foo" assert {}; +export * as ns2 from "foo" assert {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json new file mode 100644 index 000000000000..7bb565c095bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "program": { + "type": "Program", + "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":41,"index":41}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + }, + { + "type": "ImportSpecifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17}}, + "imported": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + }, + "local": { + "type": "Identifier", + "start":14,"end":17,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":17,"index":17},"identifierName":"bar"}, + "name": "bar" + } + } + ], + "source": { + "type": "StringLiteral", + "start":25,"end":30,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ImportDeclaration", + "start":42,"end":78,"loc":{"start":{"line":2,"column":0,"index":42},"end":{"line":2,"column":36,"index":78}}, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "start":49,"end":56,"loc":{"start":{"line":2,"column":7,"index":49},"end":{"line":2,"column":14,"index":56}}, + "local": { + "type": "Identifier", + "start":54,"end":56,"loc":{"start":{"line":2,"column":12,"index":54},"end":{"line":2,"column":14,"index":56},"identifierName":"ns"}, + "name": "ns" + } + } + ], + "source": { + "type": "StringLiteral", + "start":62,"end":67,"loc":{"start":{"line":2,"column":20,"index":62},"end":{"line":2,"column":25,"index":67}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":79,"end":116,"loc":{"start":{"line":3,"column":0,"index":79},"end":{"line":3,"column":37,"index":116}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92}}, + "local": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + }, + "exported": { + "type": "Identifier", + "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "name": "quux" + } + } + ], + "source": { + "type": "StringLiteral", + "start":100,"end":105,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":3,"column":26,"index":105}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [] + }, + { + "type": "ExportNamedDeclaration", + "start":117,"end":154,"loc":{"start":{"line":4,"column":0,"index":117},"end":{"line":4,"column":37,"index":154}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":124,"end":132,"loc":{"start":{"line":4,"column":7,"index":124},"end":{"line":4,"column":15,"index":132}}, + "exported": { + "type": "Identifier", + "start":129,"end":132,"loc":{"start":{"line":4,"column":12,"index":129},"end":{"line":4,"column":15,"index":132},"identifierName":"ns2"}, + "name": "ns2" + } + } + ], + "source": { + "type": "StringLiteral", + "start":138,"end":143,"loc":{"start":{"line":4,"column":21,"index":138},"end":{"line":4,"column":26,"index":143}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json new file mode 100644 index 000000000000..aca45ad21ed1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json @@ -0,0 +1,35 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "ClassDeclaration", + "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"Foo"}, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":17,"end":19,"loc":{"start":{"line":1,"column":17,"index":17},"end":{"line":1,"column":19,"index":19}}, + "body": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json new file mode 100644 index 000000000000..0ee5e9db8111 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "program": { + "type": "Program", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "FunctionDeclaration", + "start":7,"end":24,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":24,"index":24}}, + "id": { + "type": "Identifier", + "start":16,"end":19,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":19,"index":19},"identifierName":"foo"}, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":24,"index":24}}, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json new file mode 100644 index 000000000000..c653fb95cd93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, + "specifiers": [], + "source": null, + "assertions": [], + "declaration": { + "type": "VariableDeclaration", + "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":13,"end":21,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":21,"index":21}}, + "id": { + "type": "Identifier", + "start":13,"end":16,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":16,"index":16},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":19,"end":21,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":21,"index":21}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json new file mode 100644 index 000000000000..8e9b3109b83e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json @@ -0,0 +1,61 @@ +{ + "type": "File", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "program": { + "type": "Program", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":15,"index":32}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":15,"index":15}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":14,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":14,"index":14}}, + "id": { + "type": "Identifier", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, + "name": "foo" + }, + "init": { + "type": "StringLiteral", + "start":12,"end":14,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":14,"index":14}}, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start":17,"end":32,"loc":{"start":{"line":3,"column":0,"index":17},"end":{"line":3,"column":15,"index":32}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29}}, + "local": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":26,"end":29,"loc":{"start":{"line":3,"column":9,"index":26},"end":{"line":3,"column":12,"index":29},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": null, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js new file mode 100644 index 000000000000..dcc37efe8067 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js @@ -0,0 +1 @@ +import "foo" assert { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json new file mode 100644 index 000000000000..b89ace5ec3fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json @@ -0,0 +1,51 @@ +{ + "type": "File", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "program": { + "type": "Program", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, + "key": { + "type": "StringLiteral", + "start":22,"end":28,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":28,"index":28}}, + "extra": { + "rawValue": "type", + "raw": "\"type\"" + }, + "value": "type" + }, + "value": { + "type": "StringLiteral", + "start":30,"end":36,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..f97e9ee25718 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json new file mode 100644 index 000000000000..65d77c809f2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "program": { + "type": "Program", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, + "exported": { + "type": "Identifier", + "start":12,"end":15,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":15,"index":15},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":21,"end":31,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":31,"index":31}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, + "key": { + "type": "Identifier", + "start":41,"end":45,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":45,"index":45},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":47,"end":53,"loc":{"start":{"line":1,"column":47,"index":47},"end":{"line":1,"column":53,"index":53}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..b8a5d6580862 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json new file mode 100644 index 000000000000..9b526a568057 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "program": { + "type": "Program", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportAllDeclaration", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "source": { + "type": "StringLiteral", + "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, + "key": { + "type": "Identifier", + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..a3830551716f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..88f1415f189c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "program": { + "type": "Program", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":21,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":21,"index":21}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":21,"index":21},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":29,"end":34,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":6,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":2,"column":8,"index":50},"end":{"line":2,"column":14,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..567f6335c84c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json new file mode 100644 index 000000000000..c947ca3ee8d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "program": { + "type": "Program", + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":60,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":60,"index":60}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "StringLiteral", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":18,"index":18}}, + "extra": { + "rawValue": "default", + "raw": "\"default\"" + }, + "value": "default" + }, + "exported": { + "type": "Identifier", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":23,"index":23},"identifierName":"x"}, + "name": "x" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":36,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":36,"index":36}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, + "key": { + "type": "Identifier", + "start":46,"end":50,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":50,"index":50},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":52,"end":58,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":58,"index":58}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "expression": { + "type": "ArrayExpression", + "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "elements": [ + { + "type": "NumericLiteral", + "start":62,"end":63,"loc":{"start":{"line":2,"column":1,"index":62},"end":{"line":2,"column":2,"index":63}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..08775ba22ed4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json new file mode 100644 index 000000000000..ef4f180d3be1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "program": { + "type": "Program", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":23,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":23,"index":23}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":20,"end":23,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":23,"index":23},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":31,"end":41,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":41,"index":41}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "key": { + "type": "Identifier", + "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..23710fef0b6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..c370bb9870ad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..5dbd2c429901 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json new file mode 100644 index 000000000000..3342a818b5fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json @@ -0,0 +1,63 @@ +{ + "type": "File", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "program": { + "type": "Program", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..8acdf464a395 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json new file mode 100644 index 000000000000..4a4a18b389c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json @@ -0,0 +1,81 @@ +{ + "type": "File", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "program": { + "type": "Program", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16}}, + "local": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start":9,"end":16,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":16,"index":16},"identifierName":"default"}, + "name": "default" + } + } + ], + "source": { + "type": "StringLiteral", + "start":24,"end":34,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [ + { + "type": "ImportAttribute", + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "key": { + "type": "Identifier", + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":58,"end":80,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":80,"index":80}}, + "key": { + "type": "Identifier", + "start":58,"end":72,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":72,"index":72},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":74,"end":80,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":80,"index":80}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json new file mode 100644 index 000000000000..d1a3c1dde93b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "program": { + "type": "Program", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":31,"index":31}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12}}, + "local": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":12,"index":12},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":20,"end":30,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":30,"index":30}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "declaration": null, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..4f1ee63fb3a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" assert { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json new file mode 100644 index 000000000000..da75c3198d9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json @@ -0,0 +1,66 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":34,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":24,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":32,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + }, + { + "type": "ExpressionStatement", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "expression": { + "type": "ArrayExpression", + "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "elements": [ + { + "type": "NumericLiteral", + "start":36,"end":37,"loc":{"start":{"line":2,"column":1,"index":36},"end":{"line":2,"column":2,"index":37}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..92c0d33eddd0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" assert +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json new file mode 100644 index 000000000000..c11f4c7ce6cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "program": { + "type": "Program", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":6,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":14,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json new file mode 100644 index 000000000000..264361dead53 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..01425ab2e2e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..63ec3761f53d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + [ + "importAttributes" + ] + ], + "sourceType": "module", + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..bdcedd93bb26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json new file mode 100644 index 000000000000..7f5e6b799987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"lazy"}, + "name": "lazy" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..828d93472261 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json new file mode 100644 index 000000000000..c15b8c2d4f45 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "program": { + "type": "Program", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [ + { + "type": "ImportAttribute", + "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "key": { + "type": "Identifier", + "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + }, + { + "type": "ImportAttribute", + "start":50,"end":72,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":72,"index":72}}, + "key": { + "type": "Identifier", + "start":50,"end":64,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":64,"index":64},"identifierName":"hasOwnProperty"}, + "name": "hasOwnProperty" + }, + "value": { + "type": "StringLiteral", + "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "extra": { + "rawValue": "true", + "raw": "\"true\"" + }, + "value": "true" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json new file mode 100644 index 000000000000..8f00ebbb3e89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "program": { + "type": "Program", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], + "source": { + "type": "StringLiteral", + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "assertions": [] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json new file mode 100644 index 000000000000..ef8b957b9903 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:27)" +} From da03382e3aac7ae526a178a90911025db23072e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 18:26:11 +0200 Subject: [PATCH 02/17] Add parser support for import attributes: - the old `"importAssertions"` plugin now also supports the new syntax, to make it easier to migrate - the new `"importAttributes"` plugin supports only the new syntax by default, but it can be used with the depreated (but still included in the proposal) `assert` keyword by enabling its `"deprecatedAssertSyntax"` option The new plugin and the old plugin cannot both be enabled at the same time --- packages/babel-parser/data/schema.json | 22 ++++ .../src/parse-error/standard-errors.ts | 2 + packages/babel-parser/src/parser/statement.ts | 115 ++++++++++++------ packages/babel-parser/src/plugin-utils.ts | 17 ++- packages/babel-parser/src/types.d.ts | 4 + packages/babel-parser/src/typings.d.ts | 4 +- 6 files changed, 120 insertions(+), 44 deletions(-) diff --git a/packages/babel-parser/data/schema.json b/packages/babel-parser/data/schema.json index ec354824d433..d59d0c495e12 100644 --- a/packages/babel-parser/data/schema.json +++ b/packages/babel-parser/data/schema.json @@ -17,6 +17,14 @@ }, "type": "object" }, + "ImportAttributesPluginOptions": { + "properties": { + "deprecatedAssertSyntax": { + "type": "boolean" + } + }, + "type": "object" + }, "PipelineOperatorPluginOptions": { "properties": { "proposal": { @@ -85,6 +93,19 @@ "additionalItems": false, "type": "array" }, + { + "items": [ + { + "enum": ["importAttributes"], + "type": "string" + }, + { + "$ref": "#/definitions/ImportAttributesPluginOptions" + } + ], + "additionalItems": false, + "type": "array" + }, { "items": [ { @@ -148,6 +169,7 @@ "functionBind", "functionSent", "importAssertions", + "importAttributes", "importMeta", "importReflection", "jsx", diff --git a/packages/babel-parser/src/parse-error/standard-errors.ts b/packages/babel-parser/src/parse-error/standard-errors.ts index 64df29c7efb5..06d25546a7e9 100644 --- a/packages/babel-parser/src/parse-error/standard-errors.ts +++ b/packages/babel-parser/src/parse-error/standard-errors.ts @@ -109,6 +109,8 @@ export default { IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.", IllegalReturn: "'return' outside of function.", + ImportAttributesUseAssert: + "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.", ImportBindingIsString: ({ importName }: { importName: string }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`, ImportCallArgumentTrailingComma: diff --git a/packages/babel-parser/src/parser/statement.ts b/packages/babel-parser/src/parser/statement.ts index bd023239ef5b..a06feab5835c 100644 --- a/packages/babel-parser/src/parser/statement.ts +++ b/packages/babel-parser/src/parser/statement.ts @@ -2590,11 +2590,8 @@ export default abstract class StatementParser extends ExpressionParser { if (this.eatContextual(tt._from)) { node.source = this.parseImportSource(); this.checkExport(node); - const assertions = this.maybeParseImportAssertions(); - if (assertions) { - node.assertions = assertions; - this.checkJSONModuleImport(node); - } + this.maybeParseImportAttributes(node); + this.checkJSONModuleImport(node); } else if (expect) { this.unexpected(); } @@ -2939,19 +2936,7 @@ export default abstract class StatementParser extends ExpressionParser { this.expectContextual(tt._from); } node.source = this.parseImportSource(); - // https://github.com/tc39/proposal-import-assertions - // parse module import assertions if the next token is `assert` or ignore - // and finish the ImportDeclaration node. - const assertions = this.maybeParseImportAssertions(); - if (assertions) { - node.assertions = assertions; - } else if (!process.env.BABEL_8_BREAKING) { - const attributes = this.maybeParseModuleAttributes(); - if (attributes) { - // @ts-expect-error attributes have been deprecated - node.attributes = attributes; - } - } + this.maybeParseImportAttributes(node); this.checkImportReflection(node); this.checkJSONModuleImport(node); @@ -3001,7 +2986,9 @@ export default abstract class StatementParser extends ExpressionParser { * * @see {@link https://tc39.es/proposal-import-assertions/#prod-AssertEntries AssertEntries} */ - parseAssertEntries(): N.ImportAttribute[] { + parseImportAttributes(): N.ImportAttribute[] { + this.expect(tt.braceL); + const attrs = []; const attrNames = new Set(); @@ -3040,6 +3027,8 @@ export default abstract class StatementParser extends ExpressionParser { attrs.push(this.finishNode(node, "ImportAttribute")); } while (this.eat(tt.comma)); + this.expect(tt.braceR); + return attrs; } @@ -3047,14 +3036,7 @@ export default abstract class StatementParser extends ExpressionParser { * parse module attributes * @deprecated It will be removed in Babel 8 */ - maybeParseModuleAttributes() { - if (this.match(tt._with) && !this.hasPrecedingLineBreak()) { - this.expectPlugin("moduleAttributes"); - this.next(); - } else { - if (this.hasPlugin("moduleAttributes")) return []; - return null; - } + parseModuleAttributes() { const attrs = []; const attributes = new Set(); do { @@ -3082,27 +3064,80 @@ export default abstract class StatementParser extends ExpressionParser { } node.value = this.parseStringLiteral(this.state.value); this.finishNode(node, "ImportAttribute"); - attrs.push(node); + attrs.push(node as N.ImportAttribute); } while (this.eat(tt.comma)); return attrs; } - maybeParseImportAssertions() { - // [no LineTerminator here] AssertClause - if (this.isContextual(tt._assert) && !this.hasPrecedingLineBreak()) { - this.expectPlugin("importAssertions"); + expectImportAttributesPlugin() { + if (!this.hasPlugin("importAssertions")) { + this.expectPlugin("importAttributes"); + } + } + + maybeParseImportAttributes( + node: Undone, + ) { + let attributes: N.ImportAttribute[]; + let useWith = false; + + if (this.match(tt._with)) { + if ( + this.hasPrecedingLineBreak() && + this.lookaheadCharCode() === charCodes.leftParenthesis + ) { + // This will be parsed as a with statement, and we will throw a + // better error about it not being supported in strict mode. + return; + } + + this.next(); // eat `with` + + if (!process.env.BABEL_8_BREAKING) { + if (this.hasPlugin("moduleAttributes")) { + attributes = this.parseModuleAttributes(); + } else { + this.expectImportAttributesPlugin(); + attributes = this.parseImportAttributes(); + } + } else { + this.expectImportAttributesPlugin(); + attributes = this.parseImportAttributes(); + } + useWith = true; + } else if (this.isContextual(tt._assert) && !this.hasPrecedingLineBreak()) { + if (this.hasPlugin("importAttributes")) { + if ( + this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== + true + ) { + this.raise(Errors.ImportAttributesUseAssert, { + at: this.state.startLoc, + }); + } + } else { + this.expectOnePlugin(["importAttributes", "importAssertions"]); + } this.next(); // eat `assert` + attributes = this.parseImportAttributes(); + this.addExtra(node, "usesAssertKeyword", true); + } else if ( + this.hasPlugin("importAttributes") || + this.hasPlugin("importAssertions") + ) { + attributes = []; + } else if (!process.env.BABEL_8_BREAKING) { + if (this.hasPlugin("moduleAttributes")) { + attributes = []; + } else return; + } else return; + + if (!useWith && this.hasPlugin("importAssertions")) { + node.assertions = attributes; } else { - if (this.hasPlugin("importAssertions")) return []; - return null; + node.attributes = attributes; } - // https://tc39.es/proposal-import-assertions/#prod-AssertClause - this.eat(tt.braceL); - const attrs = this.parseAssertEntries(); - this.eat(tt.braceR); - - return attrs; } maybeParseDefaultImportSpecifier(node: Undone): boolean { diff --git a/packages/babel-parser/src/plugin-utils.ts b/packages/babel-parser/src/plugin-utils.ts index 40d1babe1f27..661cb8297ed7 100644 --- a/packages/babel-parser/src/plugin-utils.ts +++ b/packages/babel-parser/src/plugin-utils.ts @@ -174,12 +174,15 @@ export function validatePlugins(plugins: PluginList) { if (hasPlugin(plugins, "moduleAttributes")) { if (process.env.BABEL_8_BREAKING) { throw new Error( - "`moduleAttributes` has been removed in Babel 8, please use `importAssertions` parser plugin, or `@babel/plugin-syntax-import-assertions`.", + "`moduleAttributes` has been removed in Babel 8, please use `importAttributes` parser plugin, or `@babel/plugin-syntax-import-attributes`.", ); } else { - if (hasPlugin(plugins, "importAssertions")) { + if ( + hasPlugin(plugins, "importAssertions") || + hasPlugin(plugins, "importAttributes") + ) { throw new Error( - "Cannot combine importAssertions and moduleAttributes plugins.", + "Cannot combine importAssertions, importAttributes and moduleAttributes plugins.", ); } const moduleAttributesVersionPluginOption = getPluginOption( @@ -196,6 +199,14 @@ export function validatePlugins(plugins: PluginList) { } } } + if ( + hasPlugin(plugins, "importAssertions") && + hasPlugin(plugins, "importAttributes") + ) { + throw new Error( + "Cannot combine importAssertions and importAttributes plugins.", + ); + } if ( hasPlugin(plugins, "recordAndTuple") && diff --git a/packages/babel-parser/src/types.d.ts b/packages/babel-parser/src/types.d.ts index 3c178224b0bd..4dfc4ed4dd66 100644 --- a/packages/babel-parser/src/types.d.ts +++ b/packages/babel-parser/src/types.d.ts @@ -921,6 +921,8 @@ export interface ImportDeclaration extends NodeBase { >; source: Literal; importKind?: "type" | "typeof" | "value"; // TODO: Not in spec, + attributes?: ImportAttribute[]; + // @deprecated assertions?: ImportAttribute[]; module?: boolean; } @@ -947,6 +949,8 @@ export interface ExportNamedDeclaration extends NodeBase { specifiers: Array; source: Literal | undefined | null; exportKind?: "type" | "value"; // TODO: Not in spec, + attributes?: ImportAttribute[]; + // @deprecated assertions?: ImportAttribute[]; } diff --git a/packages/babel-parser/src/typings.d.ts b/packages/babel-parser/src/typings.d.ts index 3ed4a5c70b59..0e54ac344cf4 100644 --- a/packages/babel-parser/src/typings.d.ts +++ b/packages/babel-parser/src/typings.d.ts @@ -22,7 +22,8 @@ export type Plugin = | "importMeta" | "jsx" | "logicalAssignment" - | "importAssertions" + | "importAssertions" // deprecated + | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" @@ -43,6 +44,7 @@ export type Plugin = export type ParserPluginWithOptions = | ["decorators", DecoratorsPluginOptions] | ["estree", { classFeatures?: boolean }] + | ["importAttributes", { deprecatedAssertSyntax: boolean }] // @deprecated | ["moduleAttributes", { version: "may-2020" }] | ["pipelineOperator", PipelineOperatorPluginOptions] From e4bc1e1ea997b7f01fbc05208d3d0bf4f1f384c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 18:26:35 +0200 Subject: [PATCH 03/17] Parser tests --- .../valid-syntax-with-attributes/options.json | 7 +- .../valid-syntax-with-attributes/output.json | 5 +- .../_no-plugin/import-assertions/options.json | 4 +- .../_no-plugin/import-attributes/input.js | 1 + .../_no-plugin/import-attributes/options.json | 4 + .../_no-plugin/module-attributes/input.js | 1 - .../_no-plugin/module-attributes/options.json | 4 - .../dynamic-import-with-valid-syntax/input.js | 2 +- .../output.json | 24 ++-- .../import-assert-call-expression/output.json | 48 -------- .../import-with-call-expression/input.js | 2 + .../import-with-call-expression/output.json | 43 +++++++ .../incorrect-arity/input.js | 2 +- .../incorrect-arity/output.json | 26 ++--- .../options.json | 9 -- .../invalid-export-without-from/input.js | 2 +- .../invalid-export-without-from/options.json | 9 +- .../input.js | 2 +- .../output.json | 23 ++-- .../input.js | 1 + .../options.json | 3 + .../options.json | 5 - .../input.js | 2 +- .../output.json | 30 ++--- .../input.js | 2 +- .../output.json | 22 ++-- .../input.js | 1 + .../options.json | 3 + .../options.json | 9 -- .../invalid-with-entry-no-colon/input.js | 1 + .../invalid-with-entry-no-colon/options.json | 3 + .../linebreak-before-with/input.js | 2 + .../linebreak-before-with}/output.json | 22 ++-- .../string-literal/input.js | 4 +- .../string-literal/output.json | 33 +++--- .../trailing-comma-dynamic/input.js | 2 +- .../trailing-comma-dynamic/output.json | 26 ++--- .../trailing-comma/input.js | 4 +- .../trailing-comma/output.json | 33 +++--- .../valid-empty-assertion/input.js | 8 +- .../valid-empty-assertion/output.json | 41 +++---- .../valid-string-assertion-key/input.js | 2 +- .../valid-string-assertion-key/output.json | 14 +-- .../input.js | 1 + .../output.json | 14 +-- .../input.js | 1 + .../output.json | 46 ++++++++ .../input.js | 2 + .../output.json | 15 +-- .../input.js | 2 + .../output.json | 21 ++-- .../input.js | 1 + .../output.json | 15 +-- .../input.js | 2 +- .../options.json | 8 +- .../input.js | 1 + .../output.json | 15 +-- .../input.js | 1 + .../output.json | 21 ++-- .../input.js | 0 .../output.json | 0 .../input.js | 2 + .../output.json | 20 ++-- .../input.js | 2 + .../output.json | 47 ++++++++ .../valid-syntax-with-assertions/input.js | 1 + .../output.json | 17 ++- .../valid-syntax-with-attributes/output.json | 57 --------- .../valid-syntax-with-invalid-value/input.js | 2 +- .../options.json | 10 +- .../input.js | 1 + .../output.json | 14 +-- .../input.js | 1 + .../output.json | 20 ++-- .../input.js | 0 .../output.json | 0 .../without-plugin/input.js | 2 +- .../without-plugin/options.json | 2 +- .../options.json | 6 - .../output.json | 5 +- .../options.json | 4 +- .../output.json | 3 + .../output.json | 3 + .../options.json | 10 +- .../import-assertions/options.json | 6 +- .../string-literal/output.json | 8 +- .../trailing-comma/output.json | 8 +- .../valid-empty-assertion/output.json | 14 ++- .../valid-string-assertion-key/output.json | 3 + .../output.json | 3 + .../output.json | 3 + .../output.json | 5 +- .../output.json | 5 +- .../output.json | 5 +- .../options.json | 6 - .../output.json | 5 +- .../output.json | 5 +- .../output.json | 3 + .../output.json | 3 + .../valid-syntax-with-attributes/output.json | 3 + .../options.json | 6 - .../output.json | 3 + .../output.json | 3 + .../with-import-attributes/input.js | 1 + .../with-import-attributes/options.json | 8 ++ .../without-plugin/options.json | 2 +- .../_deprecated-syntax-not-enabled/input.js | 1 + .../options.json | 4 + .../output.json | 53 +++++++++ .../dynamic-import-with-valid-syntax/input.js | 0 .../options.json | 3 + .../import-assert-call-expression/input.js | 0 .../import-assert-call-expression/output.json | 2 +- .../incorrect-arity/input.js | 0 .../incorrect-arity/output.json | 4 +- .../invalid-assert-entry-no-colon/input.js | 0 .../options.json | 3 + .../invalid-escaped-assert/input.js | 0 .../invalid-escaped-assert/options.json | 0 .../invalid-escaped-assert/output.json | 0 .../invalid-export-without-from/input.js | 0 .../invalid-export-without-from}/options.json | 4 +- .../invalid-export-without-from/output.json | 0 .../input.js | 0 .../options.json | 3 + .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../options.json | 5 + .../input.js | 0 .../output.json | 2 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../options.json | 5 + .../options.json | 6 + .../string-literal/input.js | 0 .../string-literal/output.json | 10 +- .../trailing-comma-dynamic/input.js | 0 .../trailing-comma-dynamic/options.json | 3 + .../trailing-comma/input.js | 0 .../trailing-comma/output.json | 10 +- .../valid-empty-attribute}/input.js | 0 .../valid-empty-attribute}/output.json | 20 +++- .../valid-export-class/input.js | 0 .../valid-export-class/output.json | 1 - .../valid-export-function/input.js | 0 .../valid-export-function/output.json | 1 - .../valid-export-variable/input.js | 0 .../valid-export-variable/output.json | 1 - .../valid-export-without-from/input.js | 0 .../valid-export-without-from/output.json | 3 +- .../valid-string-attribute-key}/input.js | 0 .../valid-string-attribute-key}/output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../options.json | 3 + .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 2 +- .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../valid-syntax-with-attributes/input.js | 0 .../valid-syntax-with-attributes/output.json | 5 +- .../valid-syntax-with-invalid-value/input.js | 0 .../options.json | 3 + .../input.js | 0 .../output.json | 5 +- .../input.js | 0 .../output.json | 5 +- .../valid-syntax-without-attributes/input.js | 0 .../output.json | 2 +- .../without-plugin}/input.js | 0 .../without-plugin/options.json | 5 + .../output.json | 81 ------------- .../import-assert-call-expression/input.js | 2 - .../invalid-assert-entry-no-colon/input.js | 1 - .../options.json | 9 -- .../invalid-escaped-assert/input.js | 1 - .../invalid-escaped-assert/options.json | 8 -- .../invalid-escaped-assert/output.json | 74 ------------ .../invalid-export-without-from/options.json | 8 -- .../invalid-export-without-from/output.json | 107 ----------------- .../output.json | 48 -------- .../input.js | 1 - .../options.json | 5 - .../input.js | 2 - .../output.json | 69 ----------- .../input.js | 1 - .../options.json | 9 -- .../options.json | 4 - .../trailing-comma-dynamic/output.json | 110 ------------------ .../input.js | 1 - .../input.js | 1 - .../input.js | 2 - .../input.js | 2 - .../input.js | 1 - .../options.json | 9 -- .../input.js | 1 - .../input.js | 1 - .../input.js | 2 - .../input.js | 2 - .../options.json | 9 -- .../input.js | 1 - .../input.js | 1 - .../without-plugin/input.js | 1 - .../without-plugin/options.json | 5 - .../dynamic-import-with-valid-syntax/input.js | 2 +- .../options.json | 3 + .../output.json | 81 ------------- .../import-assert-call-expression/input.js | 2 - .../import-assert-call-expression/output.json | 48 -------- .../import-with-call-expression/input.js | 2 + .../import-with-call-expression/output.json | 43 +++++++ .../incorrect-arity/input.js | 2 +- .../incorrect-arity/output.json | 30 ++--- .../invalid-assert-entry-no-colon/input.js | 1 - .../options.json | 9 -- .../invalid-escaped-assert/input.js | 1 - .../invalid-escaped-assert/output.json | 74 ------------ .../invalid-export-without-from/input.js | 2 +- .../invalid-export-without-from/options.json | 9 +- .../invalid-export-without-from/output.json | 107 ----------------- .../options.json | 3 + .../output.json | 48 -------- .../input.js | 2 +- .../output.json | 22 ++-- .../input.js | 2 +- .../options.json | 4 +- .../input.js | 2 - .../output.json | 69 ----------- .../input.js | 2 +- .../output.json | 30 ++--- .../input.js | 2 +- .../output.json | 22 ++-- .../input.js | 2 +- .../options.json | 10 +- .../invalid-with-entry-no-colon/input.js | 1 + .../invalid-with-entry-no-colon/options.json | 3 + .../linebreak-before-with/input.js | 2 + .../linebreak-before-with/output.json | 47 ++++++++ .../import-attributes/string-literal/input.js | 4 +- .../string-literal/output.json | 32 ++--- .../trailing-comma-dynamic/input.js | 2 +- .../trailing-comma-dynamic/options.json | 3 + .../trailing-comma-dynamic/output.json | 110 ------------------ .../import-attributes/trailing-comma/input.js | 4 +- .../trailing-comma/output.json | 32 ++--- .../valid-empty-assertion/input.js | 4 - .../valid-empty-attribute/input.js | 4 + .../output.json | 40 +++---- .../valid-export-class/output.json | 1 - .../valid-export-function/output.json | 1 - .../valid-export-variable/output.json | 1 - .../valid-export-without-from/output.json | 3 +- .../valid-string-assertion-key/input.js | 1 - .../valid-string-attribute-key/input.js | 1 + .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 20 ++-- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../options.json | 8 +- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 20 ++-- .../output.json | 2 +- .../input.js | 2 +- .../output.json | 20 ++-- .../input.js | 2 +- .../output.json | 14 +-- .../valid-syntax-with-attributes/input.js | 2 +- .../valid-syntax-with-attributes/output.json | 14 +-- .../valid-syntax-with-invalid-value/input.js | 2 +- .../options.json | 10 +- .../input.js | 2 +- .../output.json | 14 +-- .../input.js | 2 +- .../output.json | 20 ++-- .../output.json | 2 +- .../import-attributes/without-plugin/input.js | 2 +- .../without-plugin/options.json | 2 +- .../invalid-assertions/output.json | 3 + .../options.json | 5 +- .../output.json | 5 +- .../output.json | 3 + .../invalid-named-exports/output.json | 5 +- .../invalid-named-imports/output.json | 3 + .../valid-all-exports/output.json | 3 + .../options.json | 5 +- .../output.json | 3 + .../output.json | 3 + .../valid-namespace-exports/output.json | 3 + .../valid-namespace-imports/output.json | 3 + .../import-with-statement/output.json | 17 ++- .../without-plugin/options.json | 4 +- 320 files changed, 1161 insertions(+), 1908 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines => import-assertions-with-keyword/linebreak-before-with}/output.json (65%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes => import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions}/output.json (65%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-export-with-and-attributes-multiple-lines => valid-syntax-export-with-and-assertions-multiple-lines}/output.json (68%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value => import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value}/output.json (65%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-export-with-attributes => valid-syntax-export-with-assertions}/output.json (69%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute => import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion}/output.json (69%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute => import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion}/output.json (65%) rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-export-without-attributes => valid-syntax-export-without-assertions}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-export-without-attributes => valid-syntax-export-without-assertions}/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-with-attributes-and-value => valid-syntax-with-assertions-and-value}/output.json (54%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/input.js rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-export-star-with-attributes => valid-syntax-with-assertions}/output.json (69%) delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute => import-assertions-with-keyword/valid-syntax-with-no-type-assertion}/output.json (65%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-with-object-method-attribute => valid-syntax-with-object-method-assertion}/output.json (62%) rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-without-attributes => valid-syntax-without-assertions}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/{valid-syntax-without-attributes => valid-syntax-without-assertions}/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/output.json rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/dynamic-import-with-valid-syntax/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/options.json rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/import-assert-call-expression/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/import-assert-call-expression/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/incorrect-arity/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/incorrect-arity/output.json (96%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-assert-entry-no-colon/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/options.json rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-escaped-assert/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-escaped-assert/options.json (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-escaped-assert/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-export-without-from/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes/invalid-escaped-assert => import-attributes-deprecatedAssertKeyword/invalid-export-without-from}/options.json (68%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-export-without-from/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-spread-element-import-call/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/options.json rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-export-with-repeated-type/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-export-with-repeated-type/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-syntax-export-without-attributes-identifier/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/options.json rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-syntax-import-linebreak-asserts/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-syntax-import-linebreak-asserts/output.json (99%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-with-repeated-type-string/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-with-repeated-type-string/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-with-repeated-type/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/invalid-syntax-with-repeated-type/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/invalid-syntax-without-attributes-identifier/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/options.json rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/string-literal/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/string-literal/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/trailing-comma-dynamic/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/options.json rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/trailing-comma/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/trailing-comma/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-empty-assertion => import-attributes-deprecatedAssertKeyword/valid-empty-attribute}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-empty-assertion => import-attributes-deprecatedAssertKeyword/valid-empty-attribute}/output.json (93%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-class/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-class/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-function/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-function/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-variable/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-variable/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-without-from/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-export-without-from/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-string-assertion-key => import-attributes-deprecatedAssertKeyword/valid-string-attribute-key}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-string-assertion-key => import-attributes-deprecatedAssertKeyword/valid-string-attribute-key}/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-star-as-with-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-star-as-with-attributes/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-star-with-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-star-with-attributes/output.json (94%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-and-attributes-multiple-lines/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-and-attributes-multiple-lines/output.json (96%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-attributes-and-value/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-attributes-and-value/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-attributes/output.json (96%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-invalid-value/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-no-type-attribute/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-no-type-attribute/output.json (96%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-object-method-attribute/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-with-object-method-attribute/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-without-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-export-without-attributes/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes-and-value/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes-and-value/output.json (96%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes-multiple-lines/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes-multiple-lines/output.json (94%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-attributes/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-invalid-value/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-no-type-attribute/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-no-type-attribute/output.json (95%) rename packages/babel-parser/test/fixtures/experimental/{import-assertions-with-keyword => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-object-method-attribute/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-with-object-method-attribute/output.json (97%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-without-attributes/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax => import-attributes-deprecatedAssertKeyword}/valid-syntax-without-attributes/output.json (98%) rename packages/babel-parser/test/fixtures/experimental/{import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes => import-attributes-deprecatedAssertKeyword/without-plugin}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/input.js rename packages/babel-parser/test/fixtures/experimental/import-attributes/{valid-empty-assertion => valid-empty-attribute}/output.json (61%) delete mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/input.js rename packages/babel-parser/test/fixtures/experimental/import-attributes/{valid-string-assertion-key => valid-string-attribute-key}/output.json (58%) diff --git a/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/options.json b/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/options.json index bc028a2d77d0..3277398765c8 100644 --- a/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/options.json +++ b/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/options.json @@ -1,4 +1,9 @@ { - "plugins": ["flow", "jsx", "estree", "importAssertions"], + "plugins": [ + "flow", + "jsx", + "estree", + "importAssertions" + ], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/output.json index e08a9f151de8..cfdd658d725d 100644 --- a/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/estree/import-assertions/valid-syntax-with-attributes/output.json @@ -28,6 +28,9 @@ "value": "foo.json", "raw": "\"foo.json\"" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", @@ -48,4 +51,4 @@ } ] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json index 2cf013869687..b25504944b24 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json @@ -1,5 +1,5 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)", "sourceType": "module", - "plugins": [] + "plugins": [], + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"importAttributes\", \"importAssertions\". (1:27)" } diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/options.json new file mode 100644 index 000000000000..4bc9b35a9d18 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-attributes/options.json @@ -0,0 +1,4 @@ +{ + "BABEL_8_BREAKING": false, + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/input.js deleted file mode 100644 index fb31508a0860..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/input.js +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" with type: "json"; diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json deleted file mode 100644 index a9fd5eec2660..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "throws": "This experimental syntax requires enabling the parser plugin: \"moduleAttributes\". (1:27)", - "BABEL_8_BREAKING": false -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js index 481c52e1c75f..baa60fc43c5f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js @@ -1 +1 @@ -import("foo.json", { assert: { type: "json" } }) +import("foo.json", { with: { type: "json" } }) diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json index 6a600725554a..7583096e7b99 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/dynamic-import-with-valid-syntax/output.json @@ -1,18 +1,18 @@ { "type": "File", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "program": { "type": "Program", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExpressionStatement", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "expression": { "type": "CallExpression", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "callee": { "type": "Import", "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} @@ -29,37 +29,37 @@ }, { "type": "ObjectExpression", - "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, + "start":19,"end":45,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":45,"index":45}}, "properties": [ { "type": "ObjectProperty", - "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, + "start":21,"end":43,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":43,"index":43}}, "method": false, "key": { "type": "Identifier", - "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, - "name": "assert" + "start":21,"end":25,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":25,"index":25},"identifierName":"with"}, + "name": "with" }, "computed": false, "shorthand": false, "value": { "type": "ObjectExpression", - "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, + "start":27,"end":43,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":43,"index":43}}, "properties": [ { "type": "ObjectProperty", - "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "start":29,"end":41,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":41,"index":41}}, "method": false, "key": { "type": "Identifier", - "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "start":29,"end":33,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":33,"index":33},"identifierName":"type"}, "name": "type" }, "computed": false, "shorthand": false, "value": { "type": "StringLiteral", - "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "start":35,"end":41,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":41,"index":41}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json deleted file mode 100644 index dff75e218c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/output.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "type": "File", - "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, - "program": { - "type": "Program", - "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, - "extra": { - "rawValue": "x", - "raw": "\"x\"" - }, - "value": "x" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":11,"end":23,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":12,"index":23}}, - "expression": { - "type": "CallExpression", - "start":11,"end":22,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":11,"index":22}}, - "callee": { - "type": "Identifier", - "start":11,"end":17,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":6,"index":17},"identifierName":"assert"}, - "name": "assert" - }, - "arguments": [ - { - "type": "ObjectExpression", - "start":19,"end":21,"loc":{"start":{"line":2,"column":8,"index":19},"end":{"line":2,"column":10,"index":21}}, - "properties": [] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/input.js new file mode 100644 index 000000000000..bfa86f1acde6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +with ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/output.json new file mode 100644 index 000000000000..daa1d649fb2a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-with-call-expression/output.json @@ -0,0 +1,43 @@ +{ + "type": "File", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "errors": [ + "SyntaxError: 'with' in strict mode. (2:0)" + ], + "program": { + "type": "Program", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + } + }, + { + "type": "WithStatement", + "start":11,"end":21,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":10,"index":21}}, + "object": { + "type": "ObjectExpression", + "start":17,"end":19,"loc":{"start":{"line":2,"column":6,"index":17},"end":{"line":2,"column":8,"index":19}}, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start":20,"end":21,"loc":{"start":{"line":2,"column":9,"index":20},"end":{"line":2,"column":10,"index":21}} + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js index 0863c2ee4884..7f6df49300e8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/input.js @@ -1,2 +1,2 @@ import(); -import("./foo.json", { assert: { type: "json"} }, "unsupported"); +import("./foo.json", { with: { type: "json"} }, "unsupported"); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json index 1075711b669a..04c76d684ff8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/incorrect-arity/output.json @@ -1,13 +1,13 @@ { "type": "File", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":63,"index":73}}, "errors": [ "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" ], "program": { "type": "Program", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":63,"index":73}}, "sourceType": "module", "interpreter": null, "body": [ @@ -26,10 +26,10 @@ }, { "type": "ExpressionStatement", - "start":10,"end":75,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":65,"index":75}}, + "start":10,"end":73,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":63,"index":73}}, "expression": { "type": "CallExpression", - "start":10,"end":74,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":64,"index":74}}, + "start":10,"end":72,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":62,"index":72}}, "callee": { "type": "Import", "start":10,"end":16,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":6,"index":16}} @@ -46,37 +46,37 @@ }, { "type": "ObjectExpression", - "start":31,"end":58,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":48,"index":58}}, + "start":31,"end":56,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":46,"index":56}}, "properties": [ { "type": "ObjectProperty", - "start":33,"end":56,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":46,"index":56}}, + "start":33,"end":54,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":44,"index":54}}, "method": false, "key": { "type": "Identifier", - "start":33,"end":39,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":29,"index":39},"identifierName":"assert"}, - "name": "assert" + "start":33,"end":37,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":27,"index":37},"identifierName":"with"}, + "name": "with" }, "computed": false, "shorthand": false, "value": { "type": "ObjectExpression", - "start":41,"end":56,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":46,"index":56}}, + "start":39,"end":54,"loc":{"start":{"line":2,"column":29,"index":39},"end":{"line":2,"column":44,"index":54}}, "properties": [ { "type": "ObjectProperty", - "start":43,"end":55,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":45,"index":55}}, + "start":41,"end":53,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":43,"index":53}}, "method": false, "key": { "type": "Identifier", - "start":43,"end":47,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":37,"index":47},"identifierName":"type"}, + "start":41,"end":45,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":35,"index":45},"identifierName":"type"}, "name": "type" }, "computed": false, "shorthand": false, "value": { "type": "StringLiteral", - "start":49,"end":55,"loc":{"start":{"line":2,"column":39,"index":49},"end":{"line":2,"column":45,"index":55}}, + "start":47,"end":53,"loc":{"start":{"line":2,"column":37,"index":47},"end":{"line":2,"column":43,"index":53}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -91,7 +91,7 @@ }, { "type": "StringLiteral", - "start":60,"end":73,"loc":{"start":{"line":2,"column":50,"index":60},"end":{"line":2,"column":63,"index":73}}, + "start":58,"end":71,"loc":{"start":{"line":2,"column":48,"index":58},"end":{"line":2,"column":61,"index":71}}, "extra": { "rawValue": "unsupported", "raw": "\"unsupported\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json deleted file mode 100644 index bd21352ea468..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", - "throws": "Unexpected token, expected \":\" (1:26)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js index cf94fe6e3cf3..fe8bb1d93d4d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/input.js @@ -1,2 +1,2 @@ const foo = 1; -export { foo } assert { type: "json" }; +export { foo } with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json index dbfe1111af51..302206c7125f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/options.json @@ -1,8 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module" -} \ No newline at end of file + "throws": "Unexpected token, expected \"(\" (2:20)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js index 1e421736cffd..2559fb8f1aa8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/input.js @@ -1 +1 @@ -export { default as foo } from "foo.json" assert { type: "json", type: "html" }; +export { default as foo } from "foo.json" with { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json index 70cab9f66df6..0cacb05939c2 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-with-repeated-type/output.json @@ -1,18 +1,18 @@ { "type": "File", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:65)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:63)" ], "program": { "type": "Program", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "specifiers": [ { "type": "ExportSpecifier", @@ -39,18 +39,19 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "start":49,"end":61,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":61,"index":61}}, "key": { "type": "Identifier", - "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "start":49,"end":53,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":53,"index":53},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "start":55,"end":61,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":61,"index":61}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -60,15 +61,15 @@ }, { "type": "ImportAttribute", - "start":65,"end":77,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":77,"index":77}}, + "start":63,"end":75,"loc":{"start":{"line":1,"column":63,"index":63},"end":{"line":1,"column":75,"index":75}}, "key": { "type": "Identifier", - "start":65,"end":69,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":69,"index":69},"identifierName":"type"}, + "start":63,"end":67,"loc":{"start":{"line":1,"column":63,"index":63},"end":{"line":1,"column":67,"index":67},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":71,"end":77,"loc":{"start":{"line":1,"column":71,"index":71},"end":{"line":1,"column":77,"index":77}}, + "start":69,"end":75,"loc":{"start":{"line":1,"column":69,"index":69},"end":{"line":1,"column":75,"index":75}}, "extra": { "rawValue": "html", "raw": "\"html\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/input.js new file mode 100644 index 000000000000..4465bae1500e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/input.js @@ -0,0 +1 @@ +export { x } from "foo" with; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/options.json new file mode 100644 index 000000000000..162ec22ec51b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-assertions-identifier/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \"{\" (1:28)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json deleted file mode 100644 index cf68988c8da6..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [["importAssertions"]], - "sourceType": "module", - "throws": "Unexpected token (1:30)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js index 2330d9eaed15..8959e2b5bbfa 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo from "foo.json" with { "type": "json", type: "html", "type": "js" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json index a41fd7dfce8f..d35a44ec2db6 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type-string/output.json @@ -1,19 +1,19 @@ { "type": "File", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:52)", - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:66)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)", + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:64)" ], "program": { "type": "Program", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -34,13 +34,13 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, + "start":34,"end":48,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":48,"index":48}}, "key": { "type": "StringLiteral", - "start":36,"end":42,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":42,"index":42}}, + "start":34,"end":40,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":40,"index":40}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -49,7 +49,7 @@ }, "value": { "type": "StringLiteral", - "start":44,"end":50,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":50,"index":50}}, + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -59,15 +59,15 @@ }, { "type": "ImportAttribute", - "start":52,"end":64,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":64,"index":64}}, + "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, "key": { "type": "Identifier", - "start":52,"end":56,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":56,"index":56},"identifierName":"type"}, + "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":58,"end":64,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":64,"index":64}}, + "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, "extra": { "rawValue": "html", "raw": "\"html\"" @@ -77,10 +77,10 @@ }, { "type": "ImportAttribute", - "start":66,"end":78,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":78,"index":78}}, + "start":64,"end":76,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":76,"index":76}}, "key": { "type": "StringLiteral", - "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "start":64,"end":70,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":70,"index":70}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -89,7 +89,7 @@ }, "value": { "type": "StringLiteral", - "start":74,"end":78,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":78,"index":78}}, + "start":72,"end":76,"loc":{"start":{"line":1,"column":72,"index":72},"end":{"line":1,"column":76,"index":76}}, "extra": { "rawValue": "js", "raw": "\"js\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js index 7fcebc0d4fe6..e78284007f9d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json", type: "html" }; +import foo from "foo.json" with { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json index fa45e8188e72..ddfd540e2fd9 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-with-repeated-type/output.json @@ -1,18 +1,18 @@ { "type": "File", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:48)" ], "program": { "type": "Program", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -33,18 +33,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -54,15 +54,15 @@ }, { "type": "ImportAttribute", - "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, + "start":48,"end":60,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":60,"index":60}}, "key": { "type": "Identifier", - "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, + "start":48,"end":52,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":52,"index":52},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, + "start":54,"end":60,"loc":{"start":{"line":1,"column":54,"index":54},"end":{"line":1,"column":60,"index":60}}, "extra": { "rawValue": "html", "raw": "\"html\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/input.js new file mode 100644 index 000000000000..af54005dade7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/input.js @@ -0,0 +1 @@ +import "x" with; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/options.json new file mode 100644 index 000000000000..78ef8d224620 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-assertions-identifier/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \"{\" (1:15)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json deleted file mode 100644 index 7f991d8162b7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", - "throws": "Unexpected token (1:17)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/input.js new file mode 100644 index 000000000000..a2083b0faf65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/input.js @@ -0,0 +1 @@ +import "foo" with { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/options.json new file mode 100644 index 000000000000..31e1035d1bbf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-with-entry-no-colon/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (1:24)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/input.js new file mode 100644 index 000000000000..2320cac464a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/input.js @@ -0,0 +1,2 @@ +import "foo" +with { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/output.json similarity index 65% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/output.json index c11f4c7ce6cf..aced338989cc 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/linebreak-before-with/output.json @@ -1,37 +1,37 @@ { "type": "File", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, "program": { "type": "Program", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, "specifiers": [], "source": { "type": "StringLiteral", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, "extra": { - "rawValue": "x", - "raw": "\"x\"" + "rawValue": "foo", + "raw": "\"foo\"" }, - "value": "x" + "value": "foo" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, + "start":20,"end":32,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":19,"index":32}}, "key": { "type": "Identifier", - "start":20,"end":24,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":6,"index":24},"identifierName":"type"}, + "start":20,"end":24,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":11,"index":24},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":26,"end":32,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":14,"index":32}}, + "start":26,"end":32,"loc":{"start":{"line":2,"column":13,"index":26},"end":{"line":2,"column":19,"index":32}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js index 1c1e4b79e789..8af887a3cc06 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/input.js @@ -1,2 +1,2 @@ -import foo from "foo.json" assert { for: "for" } -export { foo } from "foo.json" assert { for: "for" } +import foo from "foo.json" with { for: "for" } +export { foo } from "foo.json" with { for: "for" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json index bb201929becd..6cc66edeba10 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/string-literal/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "start":0,"end":97,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":97}}, "program": { "type": "Program", - "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "start":0,"end":97,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":97}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, + "start":34,"end":44,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":44,"index":44}}, "key": { "type": "Identifier", - "start":36,"end":39,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":39,"index":39},"identifierName":"for"}, + "start":34,"end":37,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":37,"index":37},"identifierName":"for"}, "name": "for" }, "value": { "type": "StringLiteral", - "start":41,"end":46,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":46,"index":46}}, + "start":39,"end":44,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":44,"index":44}}, "extra": { "rawValue": "for", "raw": "\"for\"" @@ -53,26 +53,26 @@ }, { "type": "ExportNamedDeclaration", - "start":49,"end":101,"loc":{"start":{"line":2,"column":0,"index":49},"end":{"line":2,"column":52,"index":101}}, + "start":47,"end":97,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":50,"index":97}}, "specifiers": [ { "type": "ExportSpecifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61}}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59}}, "local": { "type": "Identifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59},"identifierName":"foo"}, "name": "foo" }, "exported": { "type": "Identifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59},"identifierName":"foo"}, "name": "foo" } } ], "source": { "type": "StringLiteral", - "start":69,"end":79,"loc":{"start":{"line":2,"column":20,"index":69},"end":{"line":2,"column":30,"index":79}}, + "start":67,"end":77,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":30,"index":77}}, "extra": { "rawValue": "foo.json", "raw": "\"foo.json\"" @@ -80,18 +80,19 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, + "start":85,"end":95,"loc":{"start":{"line":2,"column":38,"index":85},"end":{"line":2,"column":48,"index":95}}, "key": { "type": "Identifier", - "start":89,"end":92,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":43,"index":92},"identifierName":"for"}, + "start":85,"end":88,"loc":{"start":{"line":2,"column":38,"index":85},"end":{"line":2,"column":41,"index":88},"identifierName":"for"}, "name": "for" }, "value": { "type": "StringLiteral", - "start":94,"end":99,"loc":{"start":{"line":2,"column":45,"index":94},"end":{"line":2,"column":50,"index":99}}, + "start":90,"end":95,"loc":{"start":{"line":2,"column":43,"index":90},"end":{"line":2,"column":48,"index":95}}, "extra": { "rawValue": "for", "raw": "\"for\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js index b448aa280c34..0be461789922 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/input.js @@ -1,2 +1,2 @@ import("foo.js",); -import("foo.json", { assert: { type: "json" } },); +import("foo.json", { with: { type: "json" } },); diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json index e484d6873f0f..c532394181e4 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma-dynamic/output.json @@ -1,9 +1,9 @@ { "type": "File", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "start":0,"end":67,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":48,"index":67}}, "program": { "type": "Program", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, + "start":0,"end":67,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":48,"index":67}}, "sourceType": "module", "interpreter": null, "body": [ @@ -35,16 +35,16 @@ }, { "type": "ExpressionStatement", - "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, + "start":19,"end":67,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":48,"index":67}}, "expression": { "type": "CallExpression", - "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, + "start":19,"end":66,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":47,"index":66}}, "callee": { "type": "Import", "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} }, "extra": { - "trailingComma": 66 + "trailingComma": 64 }, "arguments": [ { @@ -58,37 +58,37 @@ }, { "type": "ObjectExpression", - "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, + "start":38,"end":64,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":45,"index":64}}, "properties": [ { "type": "ObjectProperty", - "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, + "start":40,"end":62,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":43,"index":62}}, "method": false, "key": { "type": "Identifier", - "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, - "name": "assert" + "start":40,"end":44,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":25,"index":44},"identifierName":"with"}, + "name": "with" }, "computed": false, "shorthand": false, "value": { "type": "ObjectExpression", - "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, + "start":46,"end":62,"loc":{"start":{"line":2,"column":27,"index":46},"end":{"line":2,"column":43,"index":62}}, "properties": [ { "type": "ObjectProperty", - "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, + "start":48,"end":60,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":41,"index":60}}, "method": false, "key": { "type": "Identifier", - "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, + "start":48,"end":52,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":33,"index":52},"identifierName":"type"}, "name": "type" }, "computed": false, "shorthand": false, "value": { "type": "StringLiteral", - "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, + "start":54,"end":60,"loc":{"start":{"line":2,"column":35,"index":54},"end":{"line":2,"column":41,"index":60}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js index 077d150d81ae..10bc32278776 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/input.js @@ -1,2 +1,2 @@ -import foo from "foo" assert { type: "json", } -export { default as foo } from "foo" assert { type: "json", } +import foo from "foo" with { type: "json", } +export { default as foo } from "foo" with { type: "json", } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json index 77f11f2c63a2..8d72b75aed0f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/trailing-comma/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "start":0,"end":104,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":59,"index":104}}, "program": { "type": "Program", - "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "start":0,"end":104,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":59,"index":104}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, + "start":0,"end":44,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":44,"index":44}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "start":29,"end":41,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":41,"index":41}}, "key": { "type": "Identifier", - "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "start":29,"end":33,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":33,"index":33},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "start":35,"end":41,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":41,"index":41}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -53,26 +53,26 @@ }, { "type": "ExportNamedDeclaration", - "start":47,"end":108,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":61,"index":108}}, + "start":45,"end":104,"loc":{"start":{"line":2,"column":0,"index":45},"end":{"line":2,"column":59,"index":104}}, "specifiers": [ { "type": "ExportSpecifier", - "start":56,"end":70,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":23,"index":70}}, + "start":54,"end":68,"loc":{"start":{"line":2,"column":9,"index":54},"end":{"line":2,"column":23,"index":68}}, "local": { "type": "Identifier", - "start":56,"end":63,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":16,"index":63},"identifierName":"default"}, + "start":54,"end":61,"loc":{"start":{"line":2,"column":9,"index":54},"end":{"line":2,"column":16,"index":61},"identifierName":"default"}, "name": "default" }, "exported": { "type": "Identifier", - "start":67,"end":70,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":23,"index":70},"identifierName":"foo"}, + "start":65,"end":68,"loc":{"start":{"line":2,"column":20,"index":65},"end":{"line":2,"column":23,"index":68},"identifierName":"foo"}, "name": "foo" } } ], "source": { "type": "StringLiteral", - "start":78,"end":83,"loc":{"start":{"line":2,"column":31,"index":78},"end":{"line":2,"column":36,"index":83}}, + "start":76,"end":81,"loc":{"start":{"line":2,"column":31,"index":76},"end":{"line":2,"column":36,"index":81}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" @@ -80,18 +80,19 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, + "start":89,"end":101,"loc":{"start":{"line":2,"column":44,"index":89},"end":{"line":2,"column":56,"index":101}}, "key": { "type": "Identifier", - "start":93,"end":97,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":50,"index":97},"identifierName":"type"}, + "start":89,"end":93,"loc":{"start":{"line":2,"column":44,"index":89},"end":{"line":2,"column":48,"index":93},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":99,"end":105,"loc":{"start":{"line":2,"column":52,"index":99},"end":{"line":2,"column":58,"index":105}}, + "start":95,"end":101,"loc":{"start":{"line":2,"column":50,"index":95},"end":{"line":2,"column":56,"index":101}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js index 758659de4037..8bde57a92d52 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/input.js @@ -1,4 +1,4 @@ -import foo, { bar } from "foo" assert {}; -import * as ns from "foo" assert {}; -export { quux } from "foo" assert {}; -export * as ns2 from "foo" assert {}; +import foo, { bar } from "foo" with {}; +import * as ns from "foo" with {}; +export { quux } from "foo" with {}; +export * as ns2 from "foo" with {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json index 7bb565c095bc..4623a00e749f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-empty-assertion/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "start":0,"end":146,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":35,"index":146}}, "program": { "type": "Program", - "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "start":0,"end":146,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":35,"index":146}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":41,"index":41}}, + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -44,55 +44,55 @@ }, "value": "foo" }, - "assertions": [] + "attributes": [] }, { "type": "ImportDeclaration", - "start":42,"end":78,"loc":{"start":{"line":2,"column":0,"index":42},"end":{"line":2,"column":36,"index":78}}, + "start":40,"end":74,"loc":{"start":{"line":2,"column":0,"index":40},"end":{"line":2,"column":34,"index":74}}, "specifiers": [ { "type": "ImportNamespaceSpecifier", - "start":49,"end":56,"loc":{"start":{"line":2,"column":7,"index":49},"end":{"line":2,"column":14,"index":56}}, + "start":47,"end":54,"loc":{"start":{"line":2,"column":7,"index":47},"end":{"line":2,"column":14,"index":54}}, "local": { "type": "Identifier", - "start":54,"end":56,"loc":{"start":{"line":2,"column":12,"index":54},"end":{"line":2,"column":14,"index":56},"identifierName":"ns"}, + "start":52,"end":54,"loc":{"start":{"line":2,"column":12,"index":52},"end":{"line":2,"column":14,"index":54},"identifierName":"ns"}, "name": "ns" } } ], "source": { "type": "StringLiteral", - "start":62,"end":67,"loc":{"start":{"line":2,"column":20,"index":62},"end":{"line":2,"column":25,"index":67}}, + "start":60,"end":65,"loc":{"start":{"line":2,"column":20,"index":60},"end":{"line":2,"column":25,"index":65}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" }, "value": "foo" }, - "assertions": [] + "attributes": [] }, { "type": "ExportNamedDeclaration", - "start":79,"end":116,"loc":{"start":{"line":3,"column":0,"index":79},"end":{"line":3,"column":37,"index":116}}, + "start":75,"end":110,"loc":{"start":{"line":3,"column":0,"index":75},"end":{"line":3,"column":35,"index":110}}, "specifiers": [ { "type": "ExportSpecifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92}}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88}}, "local": { "type": "Identifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88},"identifierName":"quux"}, "name": "quux" }, "exported": { "type": "Identifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88},"identifierName":"quux"}, "name": "quux" } } ], "source": { "type": "StringLiteral", - "start":100,"end":105,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":3,"column":26,"index":105}}, + "start":96,"end":101,"loc":{"start":{"line":3,"column":21,"index":96},"end":{"line":3,"column":26,"index":101}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" @@ -100,32 +100,33 @@ "value": "foo" }, "declaration": null, - "assertions": [] + "assertions": [], + "attributes": [] }, { "type": "ExportNamedDeclaration", - "start":117,"end":154,"loc":{"start":{"line":4,"column":0,"index":117},"end":{"line":4,"column":37,"index":154}}, + "start":111,"end":146,"loc":{"start":{"line":4,"column":0,"index":111},"end":{"line":4,"column":35,"index":146}}, "specifiers": [ { "type": "ExportNamespaceSpecifier", - "start":124,"end":132,"loc":{"start":{"line":4,"column":7,"index":124},"end":{"line":4,"column":15,"index":132}}, + "start":118,"end":126,"loc":{"start":{"line":4,"column":7,"index":118},"end":{"line":4,"column":15,"index":126}}, "exported": { "type": "Identifier", - "start":129,"end":132,"loc":{"start":{"line":4,"column":12,"index":129},"end":{"line":4,"column":15,"index":132},"identifierName":"ns2"}, + "start":123,"end":126,"loc":{"start":{"line":4,"column":12,"index":123},"end":{"line":4,"column":15,"index":126},"identifierName":"ns2"}, "name": "ns2" } } ], "source": { "type": "StringLiteral", - "start":138,"end":143,"loc":{"start":{"line":4,"column":21,"index":138},"end":{"line":4,"column":26,"index":143}}, + "start":132,"end":137,"loc":{"start":{"line":4,"column":21,"index":132},"end":{"line":4,"column":26,"index":137}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" }, "value": "foo" }, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js index dcc37efe8067..74070b3d002e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/input.js @@ -1 +1 @@ -import "foo" assert { "type": "json" }; +import "foo" with { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json index b89ace5ec3fa..12924620911d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-string-assertion-key/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "program": { "type": "Program", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "specifiers": [], "source": { "type": "StringLiteral", @@ -20,13 +20,13 @@ }, "value": "foo" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, + "start":20,"end":34,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":34,"index":34}}, "key": { "type": "StringLiteral", - "start":22,"end":28,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":28,"index":28}}, + "start":20,"end":26,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":26,"index":26}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -35,7 +35,7 @@ }, "value": { "type": "StringLiteral", - "start":30,"end":36,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":36,"index":36}}, + "start":28,"end":34,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":34,"index":34}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js new file mode 100644 index 000000000000..4e9fbefb8919 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/output.json similarity index 65% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/output.json index 65d77c809f2c..0bc31dfbd1b5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "program": { "type": "Program", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "specifiers": [ { "type": "ExportNamespaceSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, + "start":39,"end":51,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":51,"index":51}}, "key": { "type": "Identifier", - "start":41,"end":45,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":45,"index":45},"identifierName":"type"}, + "start":39,"end":43,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":43,"index":43},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":47,"end":53,"loc":{"start":{"line":1,"column":47,"index":47},"end":{"line":1,"column":53,"index":53}}, + "start":45,"end":51,"loc":{"start":{"line":1,"column":45,"index":45},"end":{"line":1,"column":51,"index":51}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js new file mode 100644 index 000000000000..70566cfaf1f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js @@ -0,0 +1 @@ +export * from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/output.json new file mode 100644 index 000000000000..7d2294b4a354 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, + "program": { + "type": "Program", + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportAllDeclaration", + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, + "source": { + "type": "StringLiteral", + "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, + "extra": { + "rawValue": "foo.json", + "raw": "\"foo.json\"" + }, + "value": "foo.json" + }, + "attributes": [ + { + "type": "ImportAttribute", + "start":32,"end":44,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":44,"index":44}}, + "key": { + "type": "Identifier", + "start":32,"end":36,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":36,"index":36},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":38,"end":44,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":44,"index":44}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js new file mode 100644 index 000000000000..e8a58d263541 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" with +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/output.json similarity index 68% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/output.json index 88f1415f189c..64243336f277 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "program": { "type": "Program", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,19 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":2,"column":2,"index":42},"end":{"line":2,"column":14,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":6,"index":48},"identifierName":"type"}, + "start":42,"end":46,"loc":{"start":{"line":2,"column":2,"index":42},"end":{"line":2,"column":6,"index":46},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":2,"column":8,"index":50},"end":{"line":2,"column":14,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":2,"column":8,"index":48},"end":{"line":2,"column":14,"index":54}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js new file mode 100644 index 000000000000..458d863897b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" with { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/output.json similarity index 65% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/output.json index c947ca3ee8d4..758c3adb2c59 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":62}}, "program": { "type": "Program", - "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":62}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":60,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":60,"index":60}}, + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":58,"index":58}}, "specifiers": [ { "type": "ExportSpecifier", @@ -40,18 +40,19 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, "key": { "type": "Identifier", - "start":46,"end":50,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":50,"index":50},"identifierName":"type"}, + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":52,"end":58,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":58,"index":58}}, + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -63,14 +64,14 @@ }, { "type": "ExpressionStatement", - "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "start":59,"end":62,"loc":{"start":{"line":2,"column":0,"index":59},"end":{"line":2,"column":3,"index":62}}, "expression": { "type": "ArrayExpression", - "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "start":59,"end":62,"loc":{"start":{"line":2,"column":0,"index":59},"end":{"line":2,"column":3,"index":62}}, "elements": [ { "type": "NumericLiteral", - "start":62,"end":63,"loc":{"start":{"line":2,"column":1,"index":62},"end":{"line":2,"column":2,"index":63}}, + "start":60,"end":61,"loc":{"start":{"line":2,"column":1,"index":60},"end":{"line":2,"column":2,"index":61}}, "extra": { "rawValue": 0, "raw": "0" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js new file mode 100644 index 000000000000..8d791f4fe480 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/output.json similarity index 69% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/output.json index ef4f180d3be1..39ba83bfe5de 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-assertions/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "program": { "type": "Program", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,19 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "start":49,"end":61,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":61,"index":61}}, "key": { "type": "Identifier", - "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "start":49,"end":53,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":53,"index":53},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "start":55,"end":61,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":61,"index":61}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js index 23710fef0b6d..7a70c7f04630 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js @@ -1 +1 @@ -export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; +export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json index 75cee0d1de51..3b039e9a62e8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:64)" + "throws": "Only string literals are allowed as module attribute values. (1:62)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js new file mode 100644 index 000000000000..4553d256b1cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/output.json similarity index 69% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/output.json index 3342a818b5fb..92462f22c7be 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "program": { "type": "Program", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,19 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":54,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"lazy"}, + "start":42,"end":46,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":46,"index":46},"identifierName":"lazy"}, "name": "lazy" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":54,"index":54}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js new file mode 100644 index 000000000000..0e8993714a3f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/output.json similarity index 65% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/output.json index 4a4a18b389c0..2d4d97f45704 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "program": { "type": "Program", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,19 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "assertions": [], + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":54,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, + "start":42,"end":46,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":46,"index":46},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":54,"index":54}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -57,15 +58,15 @@ }, { "type": "ImportAttribute", - "start":58,"end":80,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":80,"index":80}}, + "start":56,"end":78,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":78,"index":78}}, "key": { "type": "Identifier", - "start":58,"end":72,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":72,"index":72},"identifierName":"hasOwnProperty"}, + "start":56,"end":70,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":70,"index":70},"identifierName":"hasOwnProperty"}, "name": "hasOwnProperty" }, "value": { "type": "StringLiteral", - "start":74,"end":80,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":80,"index":80}}, + "start":72,"end":78,"loc":{"start":{"line":1,"column":72,"index":72},"end":{"line":1,"column":78,"index":78}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-assertions/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-without-assertions/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js new file mode 100644 index 000000000000..b9907829ef29 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js @@ -0,0 +1,2 @@ +import "x" with { type: "json" } +[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/output.json similarity index 54% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/output.json index da75c3198d9f..7bbeab6f8b80 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":36}}, "program": { "type": "Program", - "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":36}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":34,"index":34}}, + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":32,"index":32}}, "specifiers": [], "source": { "type": "StringLiteral", @@ -20,18 +20,18 @@ }, "value": "x" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, + "start":18,"end":30,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":30,"index":30}}, "key": { "type": "Identifier", - "start":20,"end":24,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":24,"index":24},"identifierName":"type"}, + "start":18,"end":22,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":22,"index":22},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":26,"end":32,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":32,"index":32}}, + "start":24,"end":30,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":30,"index":30}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -43,14 +43,14 @@ }, { "type": "ExpressionStatement", - "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "start":33,"end":36,"loc":{"start":{"line":2,"column":0,"index":33},"end":{"line":2,"column":3,"index":36}}, "expression": { "type": "ArrayExpression", - "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "start":33,"end":36,"loc":{"start":{"line":2,"column":0,"index":33},"end":{"line":2,"column":3,"index":36}}, "elements": [ { "type": "NumericLiteral", - "start":36,"end":37,"loc":{"start":{"line":2,"column":1,"index":36},"end":{"line":2,"column":2,"index":37}}, + "start":34,"end":35,"loc":{"start":{"line":2,"column":1,"index":34},"end":{"line":2,"column":2,"index":35}}, "extra": { "rawValue": 0, "raw": "0" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js new file mode 100644 index 000000000000..e78e2c90f72d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" with +{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/output.json new file mode 100644 index 000000000000..15988e0c945b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, + "program": { + "type": "Program", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + }, + "attributes": [ + { + "type": "ImportAttribute", + "start":18,"end":30,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":14,"index":30}}, + "key": { + "type": "Identifier", + "start":18,"end":22,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":6,"index":22},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":24,"end":30,"loc":{"start":{"line":2,"column":8,"index":24},"end":{"line":2,"column":14,"index":30}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/output.json similarity index 69% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/output.json index 9b526a568057..de2bdc0bfb5f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-assertions/output.json @@ -8,18 +8,29 @@ "interpreter": null, "body": [ { - "type": "ExportAllDeclaration", + "type": "ImportDeclaration", "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "local": { + "type": "Identifier", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, + "name": "foo" + } + } + ], "source": { "type": "StringLiteral", - "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, + "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, "extra": { "rawValue": "foo.json", "raw": "\"foo.json\"" }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json deleted file mode 100644 index 264361dead53..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/output.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "type": "File", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, - "program": { - "type": "Program", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, - "local": { - "type": "Identifier", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10},"identifierName":"foo"}, - "name": "foo" - } - } - ], - "source": { - "type": "StringLiteral", - "start":16,"end":26,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":1,"column":26,"index":26}}, - "extra": { - "rawValue": "foo.json", - "raw": "\"foo.json\"" - }, - "value": "foo.json" - }, - "assertions": [ - { - "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, - "key": { - "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, - "name": "type" - }, - "value": { - "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - } - ] - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js index 01425ab2e2e7..3f350904e07f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; +import foo from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json index c70777c18cfa..9326901e4d93 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:56)" -} \ No newline at end of file + "throws": "Only string literals are allowed as module attribute values. (1:54)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js new file mode 100644 index 000000000000..1858e49c2022 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/output.json similarity index 65% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/output.json index 7f5e6b799987..97e5d13bd9e5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "program": { "type": "Program", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"lazy"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"lazy"}, "name": "lazy" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js new file mode 100644 index 000000000000..2ec8345c8e15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/output.json similarity index 62% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/output.json index c15b8c2d4f45..bc507378678e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "program": { "type": "Program", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -51,15 +51,15 @@ }, { "type": "ImportAttribute", - "start":50,"end":72,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":72,"index":72}}, + "start":48,"end":70,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":70,"index":70}}, "key": { "type": "Identifier", - "start":50,"end":64,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":64,"index":64},"identifierName":"hasOwnProperty"}, + "start":48,"end":62,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":62,"index":62},"identifierName":"hasOwnProperty"}, "name": "hasOwnProperty" }, "value": { "type": "StringLiteral", - "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "start":64,"end":70,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":70,"index":70}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-assertions/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-assertions/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-assertions/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-without-assertions/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js index 7b43091236b9..83c51c971889 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json index 28d88bde86ea..a1899f538d7e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/without-plugin/options.json @@ -1,5 +1,5 @@ { "plugins": [], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-assert-entry-no-colon/options.json index bd21352ea468..6cb445517401 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-assert-entry-no-colon/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-assert-entry-no-colon/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", "throws": "Unexpected token, expected \":\" (1:26)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-with-repeated-type/output.json index 70cab9f66df6..fe5cea3eeccf 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-with-repeated-type/output.json @@ -76,7 +76,10 @@ "value": "html" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-without-attributes-identifier/options.json index cf68988c8da6..dfc77fa9d4be 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-without-attributes-identifier/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-export-without-attributes-identifier/options.json @@ -1,5 +1,5 @@ { - "plugins": [["importAssertions"]], + "plugins": ["importAssertions"], "sourceType": "module", - "throws": "Unexpected token (1:30)" + "throws": "Unexpected token, expected \"{\" (1:30)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type-string/output.json index a41fd7dfce8f..5e7dab9e6f8a 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type-string/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type-string/output.json @@ -34,6 +34,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type/output.json index fa45e8188e72..bcf5e89dab96 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-with-repeated-type/output.json @@ -33,6 +33,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-without-attributes-identifier/options.json index 7f991d8162b7..fe925afbc0b8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-without-attributes-identifier/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/invalid-syntax-without-attributes-identifier/options.json @@ -1,9 +1,5 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], + "plugins": ["importAssertions"], "sourceType": "module", - "throws": "Unexpected token (1:17)" -} \ No newline at end of file + "throws": "Unexpected token, expected \"{\" (1:17)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/options.json index 94e3f3742509..51a9e56a5cbd 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/options.json @@ -1,8 +1,4 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], + "plugins": ["importAssertions"], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/string-literal/output.json index bb201929becd..ffc4157ac7ee 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/string-literal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/string-literal/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", @@ -99,7 +102,10 @@ "value": "for" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/trailing-comma/output.json index 77f11f2c63a2..751d09c617fa 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/trailing-comma/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/trailing-comma/output.json @@ -30,6 +30,9 @@ }, "value": "foo" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", @@ -99,7 +102,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-empty-assertion/output.json index 7bb565c095bc..9bdc377bfd44 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-empty-assertion/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-empty-assertion/output.json @@ -44,6 +44,9 @@ }, "value": "foo" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [] }, { @@ -69,6 +72,9 @@ }, "value": "foo" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [] }, { @@ -100,7 +106,10 @@ "value": "foo" }, "declaration": null, - "assertions": [] + "assertions": [], + "extra": { + "usesAssertKeyword": true + } }, { "type": "ExportNamedDeclaration", @@ -125,6 +134,9 @@ }, "value": "foo" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [] } ], diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-string-assertion-key/output.json index b89ace5ec3fa..f6f6c02381f7 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-string-assertion-key/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-string-assertion-key/output.json @@ -20,6 +20,9 @@ }, "value": "foo" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/output.json index 65d77c809f2c..6acd82cd0008 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-as-with-attributes/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-with-attributes/output.json index 9b526a568057..0857c2144344 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-star-with-attributes/output.json @@ -19,6 +19,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/output.json index 88f1415f189c..25cb45e420d1 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -55,7 +55,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes-and-value/output.json index c947ca3ee8d4..8ce8afc8b3a3 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes-and-value/output.json @@ -59,7 +59,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } }, { "type": "ExpressionStatement", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes/output.json index ef4f180d3be1..19317070fd25 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-attributes/output.json @@ -55,7 +55,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-invalid-value/options.json index 75cee0d1de51..6b41733141f4 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", "throws": "Only string literals are allowed as module attribute values. (1:64)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-no-type-attribute/output.json index 3342a818b5fb..9497f7e15fc4 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-no-type-attribute/output.json @@ -55,7 +55,10 @@ "value": "true" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-object-method-attribute/output.json index 4a4a18b389c0..35d54441c710 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-export-with-object-method-attribute/output.json @@ -73,7 +73,10 @@ "value": "true" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-and-value/output.json index da75c3198d9f..686a05a24afc 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-and-value/output.json @@ -20,6 +20,9 @@ }, "value": "x" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-multiple-lines/output.json index c11f4c7ce6cf..c0387f68bae7 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes-multiple-lines/output.json @@ -20,6 +20,9 @@ }, "value": "x" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes/output.json index 264361dead53..8aa8d77a174d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-attributes/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-invalid-value/options.json index c70777c18cfa..64ca989b41fc 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAssertions" - ] - ], - "sourceType": "module", "throws": "Only string literals are allowed as module attribute values. (1:56)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-no-type-attribute/output.json index 7f5e6b799987..12b82a6e4679 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-no-type-attribute/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-object-method-attribute/output.json index c15b8c2d4f45..ffdb41f16f9e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/valid-syntax-with-object-method-attribute/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/input.js new file mode 100644 index 000000000000..1c8a0e797620 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/input.js @@ -0,0 +1 @@ +; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/options.json new file mode 100644 index 000000000000..f93381a098e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/with-import-attributes/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "importAttributes", + "importAssertions" + ], + "sourceType": "module", + "throws": "Cannot combine importAssertions and importAttributes plugins." +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json index 28d88bde86ea..43b0784e30a8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json @@ -1,5 +1,5 @@ { "plugins": [], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"importAttributes\", \"importAssertions\". (1:27)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js new file mode 100644 index 000000000000..e93bcb742ad0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js @@ -0,0 +1 @@ +import "foo" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json new file mode 100644 index 000000000000..cc7fb4a170d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["importAttributes"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/output.json new file mode 100644 index 000000000000..daec17e88b2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/output.json @@ -0,0 +1,53 @@ +{ + "type": "File", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, + "errors": [ + "SyntaxError: The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error. (1:13)" + ], + "program": { + "type": "Program", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ + { + "type": "ImportAttribute", + "start":22,"end":34,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":34,"index":34}}, + "key": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":26,"index":26},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":28,"end":34,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":34,"index":34}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/options.json new file mode 100644 index 000000000000..6a5d447b4fee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:48)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/import-assert-call-expression/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/output.json index dff75e218c42..bea5574679e9 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/output.json @@ -20,7 +20,7 @@ }, "value": "x" }, - "assertions": [] + "attributes": [] }, { "type": "ExpressionStatement", diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/incorrect-arity/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/incorrect-arity/output.json index 1075711b669a..5d65bac43138 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/incorrect-arity/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/incorrect-arity/output.json @@ -2,8 +2,8 @@ "type": "File", "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, "errors": [ - "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", - "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" + "SyntaxError: `import()` requires exactly one argument. (1:0)", + "SyntaxError: `import()` requires exactly one argument. (2:0)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-assert-entry-no-colon/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/options.json new file mode 100644 index 000000000000..6cb445517401 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-assert-entry-no-colon/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (1:26)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/options.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-escaped-assert/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-escaped-assert/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/options.json similarity index 68% rename from packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/options.json index f7821e2088eb..dbfe1111af51 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/options.json @@ -1,8 +1,8 @@ { "plugins": [ [ - "importAttributes" + "importAssertions" ] ], "sourceType": "module" -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-export-without-from/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-export-without-from/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/options.json new file mode 100644 index 000000000000..aa2ef11e2d24 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-spread-element-import-call/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-with-repeated-type/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-with-repeated-type/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-with-repeated-type/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-with-repeated-type/output.json index 70cab9f66df6..2bf21a6409a9 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-with-repeated-type/output.json @@ -39,7 +39,10 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-export-without-attributes-identifier/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/options.json new file mode 100644 index 000000000000..dfc77fa9d4be --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-export-without-attributes-identifier/options.json @@ -0,0 +1,5 @@ +{ + "plugins": ["importAssertions"], + "sourceType": "module", + "throws": "Unexpected token, expected \"{\" (1:30)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-import-linebreak-asserts/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-import-linebreak-asserts/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-import-linebreak-asserts/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-import-linebreak-asserts/output.json index 7001818ec913..90d5e851b15f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-import-linebreak-asserts/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-import-linebreak-asserts/output.json @@ -23,7 +23,7 @@ }, "value": "foo" }, - "assertions": [] + "attributes": [] }, { "type": "ExpressionStatement", diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type-string/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type-string/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type-string/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type-string/output.json index a41fd7dfce8f..092d7417eb78 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type-string/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type-string/output.json @@ -34,7 +34,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type/output.json index fa45e8188e72..b9b9c3d5b993 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-with-repeated-type/output.json @@ -33,7 +33,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/invalid-syntax-without-attributes-identifier/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/options.json new file mode 100644 index 000000000000..fe925afbc0b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/invalid-syntax-without-attributes-identifier/options.json @@ -0,0 +1,5 @@ +{ + "plugins": ["importAssertions"], + "sourceType": "module", + "throws": "Unexpected token, expected \"{\" (1:17)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/options.json new file mode 100644 index 000000000000..49dd7647ae83 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/string-literal/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/string-literal/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/string-literal/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/string-literal/output.json index bb201929becd..1c69969df135 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/string-literal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/string-literal/output.json @@ -30,7 +30,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, @@ -80,7 +83,10 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/options.json new file mode 100644 index 000000000000..5ede5a8858ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (2:49)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma/output.json index 77f11f2c63a2..b23a040b20a1 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/trailing-comma/output.json @@ -30,7 +30,10 @@ }, "value": "foo" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, @@ -80,7 +83,10 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/output.json similarity index 93% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/output.json index 7bb565c095bc..d3dc9bc1ef91 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-empty-assertion/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/output.json @@ -44,7 +44,10 @@ }, "value": "foo" }, - "assertions": [] + "extra": { + "usesAssertKeyword": true + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -69,7 +72,10 @@ }, "value": "foo" }, - "assertions": [] + "extra": { + "usesAssertKeyword": true + }, + "attributes": [] }, { "type": "ExportNamedDeclaration", @@ -100,7 +106,10 @@ "value": "foo" }, "declaration": null, - "assertions": [] + "extra": { + "usesAssertKeyword": true + }, + "attributes": [] }, { "type": "ExportNamedDeclaration", @@ -125,7 +134,10 @@ }, "value": "foo" }, - "assertions": [] + "extra": { + "usesAssertKeyword": true + }, + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-class/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-class/output.json index aca45ad21ed1..f3d5a6da191c 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-class/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-class/output.json @@ -12,7 +12,6 @@ "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "ClassDeclaration", "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-function/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-function/output.json index 0ee5e9db8111..8644fb8db119 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-function/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-function/output.json @@ -12,7 +12,6 @@ "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "FunctionDeclaration", "start":7,"end":24,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":24,"index":24}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-variable/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-variable/output.json index c653fb95cd93..79a96b788df5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-variable/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-variable/output.json @@ -12,7 +12,6 @@ "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "VariableDeclaration", "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-without-from/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-without-from/output.json index 8e9b3109b83e..03a1202728af 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-export-without-from/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-export-without-from/output.json @@ -52,8 +52,7 @@ } ], "source": null, - "declaration": null, - "assertions": [] + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/output.json index b89ace5ec3fa..488c7e71b4e6 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-string-assertion-key/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/output.json @@ -20,7 +20,10 @@ }, "value": "foo" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/output.json index 65d77c809f2c..91b0938507fd 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-as-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/output.json @@ -30,7 +30,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-star-with-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/output.json similarity index 94% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/output.json index 9b526a568057..04347ada0890 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/output.json @@ -19,7 +19,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json index 88f1415f189c..b7eaf07fcb1d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -36,7 +36,10 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/output.json index c947ca3ee8d4..f8ed26e510e9 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/output.json @@ -40,7 +40,10 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/output.json index ef4f180d3be1..52f8381e0134 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/output.json @@ -36,7 +36,10 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..6b41733141f4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/output.json index 3342a818b5fb..81f5af8bc300 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/output.json @@ -36,7 +36,10 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/output.json index 4a4a18b389c0..038742b09246 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-export-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/output.json @@ -36,7 +36,10 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/output.json index d1a3c1dde93b..65a4f9f1ed38 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-without-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/output.json @@ -36,7 +36,7 @@ "value": "foo.json" }, "declaration": null, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-and-value/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/output.json index da75c3198d9f..69493b396965 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/output.json @@ -20,7 +20,10 @@ }, "value": "x" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/output.json similarity index 94% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/output.json index c11f4c7ce6cf..825fe1176801 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/output.json @@ -20,7 +20,10 @@ }, "value": "x" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/output.json index 264361dead53..c86906ea9868 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/output.json @@ -30,7 +30,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..64ca989b41fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/output.json index 7f5e6b799987..efc361f015fe 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/output.json @@ -30,7 +30,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-assertions-with-keyword/valid-syntax-with-object-method-attribute/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/output.json similarity index 97% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/output.json index c15b8c2d4f45..de90a547df36 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/output.json @@ -30,7 +30,10 @@ }, "value": "foo.json" }, - "assertions": [ + "extra": { + "usesAssertKeyword": true + }, + "attributes": [ { "type": "ImportAttribute", "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/output.json index 8f00ebbb3e89..de12941db425 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-without-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/output.json @@ -30,7 +30,7 @@ }, "value": "foo.json" }, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes/input.js rename to packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/options.json new file mode 100644 index 000000000000..43b0784e30a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertKeyword/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"importAttributes\", \"importAssertions\". (1:27)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json deleted file mode 100644 index 6a600725554a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/dynamic-import-with-valid-syntax/output.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "type": "File", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "program": { - "type": "Program", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "expression": { - "type": "CallExpression", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":17,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":17,"index":17}}, - "extra": { - "rawValue": "foo.json", - "raw": "\"foo.json\"" - }, - "value": "foo.json" - }, - { - "type": "ObjectExpression", - "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, - "properties": [ - { - "type": "ObjectProperty", - "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, - "method": false, - "key": { - "type": "Identifier", - "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, - "name": "assert" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "ObjectExpression", - "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, - "properties": [ - { - "type": "ObjectProperty", - "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, - "method": false, - "key": { - "type": "Identifier", - "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, - "name": "type" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "StringLiteral", - "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - } - ] - } - } - ] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js deleted file mode 100644 index 5b6c5fa3373a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/import-assert-call-expression/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "x" -assert ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js deleted file mode 100644 index cfa5d6ec452c..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/input.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" assert { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json deleted file mode 100644 index a5800dc58846..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-assert-entry-no-colon/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module", - "throws": "Unexpected token, expected \":\" (1:26)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js deleted file mode 100644 index e316ef9d4abe..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/input.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" \u{61}ssert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json deleted file mode 100644 index 5065055eb5eb..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/options.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json deleted file mode 100644 index 966dec7cb644..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-escaped-assert/output.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "type": "File", - "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, - "errors": [ - "SyntaxError: Missing semicolon. (1:12)", - "SyntaxError: Missing semicolon. (1:24)" - ], - "program": { - "type": "Program", - "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, - "extra": { - "rawValue": "foo", - "raw": "\"foo\"" - }, - "value": "foo" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24}}, - "expression": { - "type": "Identifier", - "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":25,"end":41,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":41,"index":41}}, - "body": [ - { - "type": "LabeledStatement", - "start":27,"end":39,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":39,"index":39}}, - "body": { - "type": "ExpressionStatement", - "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, - "expression": { - "type": "StringLiteral", - "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":27,"end":31,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":31,"index":31},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - }, - { - "type": "EmptyStatement", - "start":41,"end":42,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":42,"index":42}} - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json deleted file mode 100644 index ac19d36b8567..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/options.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json deleted file mode 100644 index 7f73183b8a8e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-export-without-from/output.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "type": "File", - "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, - "errors": [ - "SyntaxError: Missing semicolon. (2:14)", - "SyntaxError: Missing semicolon. (2:21)" - ], - "program": { - "type": "Program", - "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "VariableDeclaration", - "start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, - "declarations": [ - { - "type": "VariableDeclarator", - "start":6,"end":13,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":13,"index":13}}, - "id": { - "type": "Identifier", - "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, - "name": "foo" - }, - "init": { - "type": "NumericLiteral", - "start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, - "extra": { - "rawValue": 1, - "raw": "1" - }, - "value": 1 - } - } - ], - "kind": "const" - }, - { - "type": "ExportNamedDeclaration", - "start":15,"end":29,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":14,"index":29}}, - "specifiers": [ - { - "type": "ExportSpecifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27}}, - "local": { - "type": "Identifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, - "name": "foo" - }, - "exported": { - "type": "Identifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, - "name": "foo" - } - } - ], - "source": null, - "declaration": null, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36}}, - "expression": { - "type": "Identifier", - "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":37,"end":53,"loc":{"start":{"line":2,"column":22,"index":37},"end":{"line":2,"column":38,"index":53}}, - "body": [ - { - "type": "LabeledStatement", - "start":39,"end":51,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":36,"index":51}}, - "body": { - "type": "ExpressionStatement", - "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, - "expression": { - "type": "StringLiteral", - "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":39,"end":43,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":28,"index":43},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - }, - { - "type": "EmptyStatement", - "start":53,"end":54,"loc":{"start":{"line":2,"column":38,"index":53},"end":{"line":2,"column":39,"index":54}} - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json deleted file mode 100644 index dd7456506eef..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-spread-element-import-call/output.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "type": "File", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "errors": [ - "SyntaxError: `...` is not allowed in `import()`. (1:21)" - ], - "program": { - "type": "Program", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "expression": { - "type": "CallExpression", - "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, - "extra": { - "rawValue": "./foo.json", - "raw": "\"./foo.json\"" - }, - "value": "./foo.json" - }, - { - "type": "SpreadElement", - "start":21,"end":26,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":26,"index":26}}, - "argument": { - "type": "ArrayExpression", - "start":24,"end":26,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":26,"index":26}}, - "elements": [] - } - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js deleted file mode 100644 index a6db9b5aacbe..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/input.js +++ /dev/null @@ -1 +0,0 @@ -export { x } from "foo" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json deleted file mode 100644 index 12a6493c7c4d..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-export-without-attributes-identifier/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [[["importAttributes", { "deprecatedAssertSyntax": true }]]], - "sourceType": "module", - "throws": "Unexpected token (1:30)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js deleted file mode 100644 index ce0c366a9c9a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "foo" -assert { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json deleted file mode 100644 index 7001818ec913..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-import-linebreak-asserts/output.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "type": "File", - "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, - "errors": [ - "SyntaxError: Missing semicolon. (2:6)" - ], - "program": { - "type": "Program", - "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, - "extra": { - "rawValue": "foo", - "raw": "\"foo\"" - }, - "value": "foo" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19}}, - "expression": { - "type": "Identifier", - "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":20,"end":36,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":23,"index":36}}, - "body": [ - { - "type": "LabeledStatement", - "start":22,"end":34,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":21,"index":34}}, - "body": { - "type": "ExpressionStatement", - "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, - "expression": { - "type": "StringLiteral", - "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":22,"end":26,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":13,"index":26},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js deleted file mode 100644 index e2920266c8ff..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/input.js +++ /dev/null @@ -1 +0,0 @@ -import "x" assert; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json deleted file mode 100644 index 441eba531e76..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/invalid-syntax-without-attributes-identifier/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module", - "throws": "Unexpected token (1:17)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json deleted file mode 100644 index 85aa77c49fdc..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["importAttributes", { "deprecatedAssertSyntax": true }]], - "sourceType": "module" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json deleted file mode 100644 index e484d6873f0f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/trailing-comma-dynamic/output.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "type": "File", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, - "program": { - "type": "Program", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":18,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":18,"index":18}}, - "expression": { - "type": "CallExpression", - "start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "extra": { - "trailingComma": 15 - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, - "extra": { - "rawValue": "foo.js", - "raw": "\"foo.js\"" - }, - "value": "foo.js" - } - ] - } - }, - { - "type": "ExpressionStatement", - "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, - "expression": { - "type": "CallExpression", - "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, - "callee": { - "type": "Import", - "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} - }, - "extra": { - "trailingComma": 66 - }, - "arguments": [ - { - "type": "StringLiteral", - "start":26,"end":36,"loc":{"start":{"line":2,"column":7,"index":26},"end":{"line":2,"column":17,"index":36}}, - "extra": { - "rawValue": "foo.json", - "raw": "\"foo.json\"" - }, - "value": "foo.json" - }, - { - "type": "ObjectExpression", - "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, - "properties": [ - { - "type": "ObjectProperty", - "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, - "method": false, - "key": { - "type": "Identifier", - "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, - "name": "assert" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "ObjectExpression", - "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, - "properties": [ - { - "type": "ObjectProperty", - "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, - "method": false, - "key": { - "type": "Identifier", - "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, - "name": "type" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "StringLiteral", - "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - } - ] - } - } - ] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js deleted file mode 100644 index f97e9ee25718..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-as-with-attributes/input.js +++ /dev/null @@ -1 +0,0 @@ -export * as foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js deleted file mode 100644 index b8a5d6580862..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-star-with-attributes/input.js +++ /dev/null @@ -1 +0,0 @@ -export * from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js deleted file mode 100644 index a3830551716f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-and-attributes-multiple-lines/input.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as x } from "foo" assert -{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js deleted file mode 100644 index 567f6335c84c..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes-and-value/input.js +++ /dev/null @@ -1,2 +0,0 @@ -export { "default" as x } from "foo" assert { type: "json" } -[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js deleted file mode 100644 index 08775ba22ed4..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-attributes/input.js +++ /dev/null @@ -1 +0,0 @@ -export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json deleted file mode 100644 index f4dfaf194d1c..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-invalid-value/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:64)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js deleted file mode 100644 index 5dbd2c429901..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-no-type-attribute/input.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js deleted file mode 100644 index 8acdf464a395..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-export-with-object-method-attribute/input.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js deleted file mode 100644 index 4f1ee63fb3a6..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-and-value/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "x" assert { type: "json" } -[0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js deleted file mode 100644 index 92c0d33eddd0..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-attributes-multiple-lines/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "x" assert -{ type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json deleted file mode 100644 index 24f89b10b845..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-invalid-value/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - ["importAttributes", { "deprecatedAssertSyntax": true }] - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:56)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js deleted file mode 100644 index bdcedd93bb26..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-no-type-attribute/input.js +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" assert { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js deleted file mode 100644 index 828d93472261..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/valid-syntax-with-object-method-attribute/input.js +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js deleted file mode 100644 index 7b43091236b9..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/input.js +++ /dev/null @@ -1 +0,0 @@ -import foo from "foo.json" assert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json deleted file mode 100644 index ef8b957b9903..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes-deprecatedAssertSyntax/without-plugin/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [], - "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:27)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js index 481c52e1c75f..baa60fc43c5f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/input.js @@ -1 +1 @@ -import("foo.json", { assert: { type: "json" } }) +import("foo.json", { with: { type: "json" } }) diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/options.json new file mode 100644 index 000000000000..2753de058a93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:46)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json deleted file mode 100644 index 6a600725554a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/dynamic-import-with-valid-syntax/output.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "type": "File", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "program": { - "type": "Program", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "expression": { - "type": "CallExpression", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":17,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":17,"index":17}}, - "extra": { - "rawValue": "foo.json", - "raw": "\"foo.json\"" - }, - "value": "foo.json" - }, - { - "type": "ObjectExpression", - "start":19,"end":47,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":47,"index":47}}, - "properties": [ - { - "type": "ObjectProperty", - "start":21,"end":45,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":45,"index":45}}, - "method": false, - "key": { - "type": "Identifier", - "start":21,"end":27,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":27,"index":27},"identifierName":"assert"}, - "name": "assert" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "ObjectExpression", - "start":29,"end":45,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":45,"index":45}}, - "properties": [ - { - "type": "ObjectProperty", - "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, - "method": false, - "key": { - "type": "Identifier", - "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, - "name": "type" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "StringLiteral", - "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - } - ] - } - } - ] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js deleted file mode 100644 index 5b6c5fa3373a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "x" -assert ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json deleted file mode 100644 index dff75e218c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-assert-call-expression/output.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "type": "File", - "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, - "program": { - "type": "Program", - "start":0,"end":23,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":12,"index":23}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, - "extra": { - "rawValue": "x", - "raw": "\"x\"" - }, - "value": "x" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":11,"end":23,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":12,"index":23}}, - "expression": { - "type": "CallExpression", - "start":11,"end":22,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":11,"index":22}}, - "callee": { - "type": "Identifier", - "start":11,"end":17,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":6,"index":17},"identifierName":"assert"}, - "name": "assert" - }, - "arguments": [ - { - "type": "ObjectExpression", - "start":19,"end":21,"loc":{"start":{"line":2,"column":8,"index":19},"end":{"line":2,"column":10,"index":21}}, - "properties": [] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/input.js new file mode 100644 index 000000000000..bfa86f1acde6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +with ({}); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/output.json new file mode 100644 index 000000000000..daa1d649fb2a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/import-with-call-expression/output.json @@ -0,0 +1,43 @@ +{ + "type": "File", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "errors": [ + "SyntaxError: 'with' in strict mode. (2:0)" + ], + "program": { + "type": "Program", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + } + }, + { + "type": "WithStatement", + "start":11,"end":21,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":10,"index":21}}, + "object": { + "type": "ObjectExpression", + "start":17,"end":19,"loc":{"start":{"line":2,"column":6,"index":17},"end":{"line":2,"column":8,"index":19}}, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start":20,"end":21,"loc":{"start":{"line":2,"column":9,"index":20},"end":{"line":2,"column":10,"index":21}} + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js index 0863c2ee4884..7f6df49300e8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/input.js @@ -1,2 +1,2 @@ import(); -import("./foo.json", { assert: { type: "json"} }, "unsupported"); +import("./foo.json", { with: { type: "json"} }, "unsupported"); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json index 1075711b669a..37f157047780 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/incorrect-arity/output.json @@ -1,13 +1,13 @@ { "type": "File", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":63,"index":73}}, "errors": [ - "SyntaxError: `import()` requires exactly one or two arguments. (1:0)", - "SyntaxError: `import()` requires exactly one or two arguments. (2:0)" + "SyntaxError: `import()` requires exactly one argument. (1:0)", + "SyntaxError: `import()` requires exactly one argument. (2:0)" ], "program": { "type": "Program", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":65,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":63,"index":73}}, "sourceType": "module", "interpreter": null, "body": [ @@ -26,10 +26,10 @@ }, { "type": "ExpressionStatement", - "start":10,"end":75,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":65,"index":75}}, + "start":10,"end":73,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":63,"index":73}}, "expression": { "type": "CallExpression", - "start":10,"end":74,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":64,"index":74}}, + "start":10,"end":72,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":62,"index":72}}, "callee": { "type": "Import", "start":10,"end":16,"loc":{"start":{"line":2,"column":0,"index":10},"end":{"line":2,"column":6,"index":16}} @@ -46,37 +46,37 @@ }, { "type": "ObjectExpression", - "start":31,"end":58,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":48,"index":58}}, + "start":31,"end":56,"loc":{"start":{"line":2,"column":21,"index":31},"end":{"line":2,"column":46,"index":56}}, "properties": [ { "type": "ObjectProperty", - "start":33,"end":56,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":46,"index":56}}, + "start":33,"end":54,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":44,"index":54}}, "method": false, "key": { "type": "Identifier", - "start":33,"end":39,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":29,"index":39},"identifierName":"assert"}, - "name": "assert" + "start":33,"end":37,"loc":{"start":{"line":2,"column":23,"index":33},"end":{"line":2,"column":27,"index":37},"identifierName":"with"}, + "name": "with" }, "computed": false, "shorthand": false, "value": { "type": "ObjectExpression", - "start":41,"end":56,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":46,"index":56}}, + "start":39,"end":54,"loc":{"start":{"line":2,"column":29,"index":39},"end":{"line":2,"column":44,"index":54}}, "properties": [ { "type": "ObjectProperty", - "start":43,"end":55,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":45,"index":55}}, + "start":41,"end":53,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":43,"index":53}}, "method": false, "key": { "type": "Identifier", - "start":43,"end":47,"loc":{"start":{"line":2,"column":33,"index":43},"end":{"line":2,"column":37,"index":47},"identifierName":"type"}, + "start":41,"end":45,"loc":{"start":{"line":2,"column":31,"index":41},"end":{"line":2,"column":35,"index":45},"identifierName":"type"}, "name": "type" }, "computed": false, "shorthand": false, "value": { "type": "StringLiteral", - "start":49,"end":55,"loc":{"start":{"line":2,"column":39,"index":49},"end":{"line":2,"column":45,"index":55}}, + "start":47,"end":53,"loc":{"start":{"line":2,"column":37,"index":47},"end":{"line":2,"column":43,"index":53}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -91,7 +91,7 @@ }, { "type": "StringLiteral", - "start":60,"end":73,"loc":{"start":{"line":2,"column":50,"index":60},"end":{"line":2,"column":63,"index":73}}, + "start":58,"end":71,"loc":{"start":{"line":2,"column":48,"index":58},"end":{"line":2,"column":61,"index":71}}, "extra": { "rawValue": "unsupported", "raw": "\"unsupported\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js deleted file mode 100644 index cfa5d6ec452c..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/input.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" assert { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json deleted file mode 100644 index 079a016c4661..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-assert-entry-no-colon/options.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - [ - "importAttributes" - ] - ], - "sourceType": "module", - "throws": "Unexpected token, expected \":\" (1:26)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js deleted file mode 100644 index e316ef9d4abe..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/input.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" \u{61}ssert { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json deleted file mode 100644 index 966dec7cb644..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-escaped-assert/output.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "type": "File", - "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, - "errors": [ - "SyntaxError: Missing semicolon. (1:12)", - "SyntaxError: Missing semicolon. (1:24)" - ], - "program": { - "type": "Program", - "start":0,"end":42,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":42,"index":42}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, - "extra": { - "rawValue": "foo", - "raw": "\"foo\"" - }, - "value": "foo" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24}}, - "expression": { - "type": "Identifier", - "start":13,"end":24,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":24,"index":24},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":25,"end":41,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":41,"index":41}}, - "body": [ - { - "type": "LabeledStatement", - "start":27,"end":39,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":39,"index":39}}, - "body": { - "type": "ExpressionStatement", - "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, - "expression": { - "type": "StringLiteral", - "start":33,"end":39,"loc":{"start":{"line":1,"column":33,"index":33},"end":{"line":1,"column":39,"index":39}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":27,"end":31,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":31,"index":31},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - }, - { - "type": "EmptyStatement", - "start":41,"end":42,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":42,"index":42}} - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js index cf94fe6e3cf3..fe8bb1d93d4d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/input.js @@ -1,2 +1,2 @@ const foo = 1; -export { foo } assert { type: "json" }; +export { foo } with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json index 7b13c05e4000..302206c7125f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/options.json @@ -1,8 +1,3 @@ { - "plugins": [ - [ - "importAttributes" - ] - ], - "sourceType": "module" -} \ No newline at end of file + "throws": "Unexpected token, expected \"(\" (2:20)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json deleted file mode 100644 index 7f73183b8a8e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-export-without-from/output.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "type": "File", - "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, - "errors": [ - "SyntaxError: Missing semicolon. (2:14)", - "SyntaxError: Missing semicolon. (2:21)" - ], - "program": { - "type": "Program", - "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":39,"index":54}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "VariableDeclaration", - "start":0,"end":14,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":14,"index":14}}, - "declarations": [ - { - "type": "VariableDeclarator", - "start":6,"end":13,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":13,"index":13}}, - "id": { - "type": "Identifier", - "start":6,"end":9,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":9,"index":9},"identifierName":"foo"}, - "name": "foo" - }, - "init": { - "type": "NumericLiteral", - "start":12,"end":13,"loc":{"start":{"line":1,"column":12,"index":12},"end":{"line":1,"column":13,"index":13}}, - "extra": { - "rawValue": 1, - "raw": "1" - }, - "value": 1 - } - } - ], - "kind": "const" - }, - { - "type": "ExportNamedDeclaration", - "start":15,"end":29,"loc":{"start":{"line":2,"column":0,"index":15},"end":{"line":2,"column":14,"index":29}}, - "specifiers": [ - { - "type": "ExportSpecifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27}}, - "local": { - "type": "Identifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, - "name": "foo" - }, - "exported": { - "type": "Identifier", - "start":24,"end":27,"loc":{"start":{"line":2,"column":9,"index":24},"end":{"line":2,"column":12,"index":27},"identifierName":"foo"}, - "name": "foo" - } - } - ], - "source": null, - "declaration": null, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36}}, - "expression": { - "type": "Identifier", - "start":30,"end":36,"loc":{"start":{"line":2,"column":15,"index":30},"end":{"line":2,"column":21,"index":36},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":37,"end":53,"loc":{"start":{"line":2,"column":22,"index":37},"end":{"line":2,"column":38,"index":53}}, - "body": [ - { - "type": "LabeledStatement", - "start":39,"end":51,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":36,"index":51}}, - "body": { - "type": "ExpressionStatement", - "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, - "expression": { - "type": "StringLiteral", - "start":45,"end":51,"loc":{"start":{"line":2,"column":30,"index":45},"end":{"line":2,"column":36,"index":51}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":39,"end":43,"loc":{"start":{"line":2,"column":24,"index":39},"end":{"line":2,"column":28,"index":43},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - }, - { - "type": "EmptyStatement", - "start":53,"end":54,"loc":{"start":{"line":2,"column":38,"index":53},"end":{"line":2,"column":39,"index":54}} - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/options.json new file mode 100644 index 000000000000..aa2ef11e2d24 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json deleted file mode 100644 index dd7456506eef..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-spread-element-import-call/output.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "type": "File", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "errors": [ - "SyntaxError: `...` is not allowed in `import()`. (1:21)" - ], - "program": { - "type": "Program", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":28,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":28,"index":28}}, - "expression": { - "type": "CallExpression", - "start":0,"end":27,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":27,"index":27}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, - "extra": { - "rawValue": "./foo.json", - "raw": "\"./foo.json\"" - }, - "value": "./foo.json" - }, - { - "type": "SpreadElement", - "start":21,"end":26,"loc":{"start":{"line":1,"column":21,"index":21},"end":{"line":1,"column":26,"index":26}}, - "argument": { - "type": "ArrayExpression", - "start":24,"end":26,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":26,"index":26}}, - "elements": [] - } - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js index 1e421736cffd..2559fb8f1aa8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/input.js @@ -1 +1 @@ -export { default as foo } from "foo.json" assert { type: "json", type: "html" }; +export { default as foo } from "foo.json" with { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json index 70cab9f66df6..7c8bed5fcfca 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-with-repeated-type/output.json @@ -1,18 +1,18 @@ { "type": "File", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:65)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:63)" ], "program": { "type": "Program", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":80,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":80,"index":80}}, + "start":0,"end":78,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":78,"index":78}}, "specifiers": [ { "type": "ExportSpecifier", @@ -39,18 +39,18 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "start":49,"end":61,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":61,"index":61}}, "key": { "type": "Identifier", - "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "start":49,"end":53,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":53,"index":53},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "start":55,"end":61,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":61,"index":61}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -60,15 +60,15 @@ }, { "type": "ImportAttribute", - "start":65,"end":77,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":77,"index":77}}, + "start":63,"end":75,"loc":{"start":{"line":1,"column":63,"index":63},"end":{"line":1,"column":75,"index":75}}, "key": { "type": "Identifier", - "start":65,"end":69,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":69,"index":69},"identifierName":"type"}, + "start":63,"end":67,"loc":{"start":{"line":1,"column":63,"index":63},"end":{"line":1,"column":67,"index":67},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":71,"end":77,"loc":{"start":{"line":1,"column":71,"index":71},"end":{"line":1,"column":77,"index":77}}, + "start":69,"end":75,"loc":{"start":{"line":1,"column":69,"index":69},"end":{"line":1,"column":75,"index":75}}, "extra": { "rawValue": "html", "raw": "\"html\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js index a6db9b5aacbe..4465bae1500e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/input.js @@ -1 +1 @@ -export { x } from "foo" assert; +export { x } from "foo" with; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json index 0626123e4168..162ec22ec51b 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-export-without-attributes-identifier/options.json @@ -1,5 +1,3 @@ { - "plugins": [["importAttributes"]], - "sourceType": "module", - "throws": "Unexpected token (1:30)" + "throws": "Unexpected token, expected \"{\" (1:28)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js deleted file mode 100644 index ce0c366a9c9a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/input.js +++ /dev/null @@ -1,2 +0,0 @@ -import "foo" -assert { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json deleted file mode 100644 index 7001818ec913..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-import-linebreak-asserts/output.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "type": "File", - "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, - "errors": [ - "SyntaxError: Missing semicolon. (2:6)" - ], - "program": { - "type": "Program", - "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":23,"index":36}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ImportDeclaration", - "start":0,"end":12,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":12,"index":12}}, - "specifiers": [], - "source": { - "type": "StringLiteral", - "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, - "extra": { - "rawValue": "foo", - "raw": "\"foo\"" - }, - "value": "foo" - }, - "assertions": [] - }, - { - "type": "ExpressionStatement", - "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19}}, - "expression": { - "type": "Identifier", - "start":13,"end":19,"loc":{"start":{"line":2,"column":0,"index":13},"end":{"line":2,"column":6,"index":19},"identifierName":"assert"}, - "name": "assert" - } - }, - { - "type": "BlockStatement", - "start":20,"end":36,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":23,"index":36}}, - "body": [ - { - "type": "LabeledStatement", - "start":22,"end":34,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":21,"index":34}}, - "body": { - "type": "ExpressionStatement", - "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, - "expression": { - "type": "StringLiteral", - "start":28,"end":34,"loc":{"start":{"line":2,"column":15,"index":28},"end":{"line":2,"column":21,"index":34}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - }, - "label": { - "type": "Identifier", - "start":22,"end":26,"loc":{"start":{"line":2,"column":9,"index":22},"end":{"line":2,"column":13,"index":26},"identifierName":"type"}, - "name": "type" - } - } - ], - "directives": [] - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js index 2330d9eaed15..8959e2b5bbfa 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import foo from "foo.json" with { "type": "json", type: "html", "type": "js" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json index a41fd7dfce8f..d35a44ec2db6 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type-string/output.json @@ -1,19 +1,19 @@ { "type": "File", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:52)", - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:66)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)", + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:64)" ], "program": { "type": "Program", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, + "start":0,"end":79,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":79,"index":79}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -34,13 +34,13 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":50,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":50,"index":50}}, + "start":34,"end":48,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":48,"index":48}}, "key": { "type": "StringLiteral", - "start":36,"end":42,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":42,"index":42}}, + "start":34,"end":40,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":40,"index":40}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -49,7 +49,7 @@ }, "value": { "type": "StringLiteral", - "start":44,"end":50,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":50,"index":50}}, + "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -59,15 +59,15 @@ }, { "type": "ImportAttribute", - "start":52,"end":64,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":64,"index":64}}, + "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, "key": { "type": "Identifier", - "start":52,"end":56,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":56,"index":56},"identifierName":"type"}, + "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":58,"end":64,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":64,"index":64}}, + "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, "extra": { "rawValue": "html", "raw": "\"html\"" @@ -77,10 +77,10 @@ }, { "type": "ImportAttribute", - "start":66,"end":78,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":78,"index":78}}, + "start":64,"end":76,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":76,"index":76}}, "key": { "type": "StringLiteral", - "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "start":64,"end":70,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":70,"index":70}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -89,7 +89,7 @@ }, "value": { "type": "StringLiteral", - "start":74,"end":78,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":78,"index":78}}, + "start":72,"end":76,"loc":{"start":{"line":1,"column":72,"index":72},"end":{"line":1,"column":76,"index":76}}, "extra": { "rawValue": "js", "raw": "\"js\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js index 7fcebc0d4fe6..e78284007f9d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json", type: "html" }; +import foo from "foo.json" with { type: "json", type: "html" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json index fa45e8188e72..ddfd540e2fd9 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-with-repeated-type/output.json @@ -1,18 +1,18 @@ { "type": "File", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "errors": [ - "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:50)" + "SyntaxError: Duplicate key \"type\" is not allowed in module attributes. (1:48)" ], "program": { "type": "Program", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":65,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":65,"index":65}}, + "start":0,"end":63,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":63,"index":63}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -33,18 +33,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -54,15 +54,15 @@ }, { "type": "ImportAttribute", - "start":50,"end":62,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":62,"index":62}}, + "start":48,"end":60,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":60,"index":60}}, "key": { "type": "Identifier", - "start":50,"end":54,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":54,"index":54},"identifierName":"type"}, + "start":48,"end":52,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":52,"index":52},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":56,"end":62,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":62,"index":62}}, + "start":54,"end":60,"loc":{"start":{"line":1,"column":54,"index":54},"end":{"line":1,"column":60,"index":60}}, "extra": { "rawValue": "html", "raw": "\"html\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js index e2920266c8ff..af54005dade7 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/input.js @@ -1 +1 @@ -import "x" assert; +import "x" with; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json index cbefdaa6edd8..78ef8d224620 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-syntax-without-attributes-identifier/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAttributes" - ] - ], - "sourceType": "module", - "throws": "Unexpected token (1:17)" -} \ No newline at end of file + "throws": "Unexpected token, expected \"{\" (1:15)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/input.js new file mode 100644 index 000000000000..a2083b0faf65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/input.js @@ -0,0 +1 @@ +import "foo" with { type, "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/options.json new file mode 100644 index 000000000000..31e1035d1bbf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/invalid-with-entry-no-colon/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (1:24)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/input.js new file mode 100644 index 000000000000..2320cac464a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/input.js @@ -0,0 +1,2 @@ +import "foo" +with { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/output.json new file mode 100644 index 000000000000..aced338989cc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/linebreak-before-with/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, + "program": { + "type": "Program", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":21,"index":34}}, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start":7,"end":12,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":12,"index":12}}, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "attributes": [ + { + "type": "ImportAttribute", + "start":20,"end":32,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":19,"index":32}}, + "key": { + "type": "Identifier", + "start":20,"end":24,"loc":{"start":{"line":2,"column":7,"index":20},"end":{"line":2,"column":11,"index":24},"identifierName":"type"}, + "name": "type" + }, + "value": { + "type": "StringLiteral", + "start":26,"end":32,"loc":{"start":{"line":2,"column":13,"index":26},"end":{"line":2,"column":19,"index":32}}, + "extra": { + "rawValue": "json", + "raw": "\"json\"" + }, + "value": "json" + } + } + ] + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js index 1c1e4b79e789..8af887a3cc06 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/input.js @@ -1,2 +1,2 @@ -import foo from "foo.json" assert { for: "for" } -export { foo } from "foo.json" assert { for: "for" } +import foo from "foo.json" with { for: "for" } +export { foo } from "foo.json" with { for: "for" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json index bb201929becd..9477e4bcc226 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/string-literal/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "start":0,"end":97,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":97}}, "program": { "type": "Program", - "start":0,"end":101,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":52,"index":101}}, + "start":0,"end":97,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":97}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":48,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":48,"index":48}}, + "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":46,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":46,"index":46}}, + "start":34,"end":44,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":44,"index":44}}, "key": { "type": "Identifier", - "start":36,"end":39,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":39,"index":39},"identifierName":"for"}, + "start":34,"end":37,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":37,"index":37},"identifierName":"for"}, "name": "for" }, "value": { "type": "StringLiteral", - "start":41,"end":46,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":46,"index":46}}, + "start":39,"end":44,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":44,"index":44}}, "extra": { "rawValue": "for", "raw": "\"for\"" @@ -53,26 +53,26 @@ }, { "type": "ExportNamedDeclaration", - "start":49,"end":101,"loc":{"start":{"line":2,"column":0,"index":49},"end":{"line":2,"column":52,"index":101}}, + "start":47,"end":97,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":50,"index":97}}, "specifiers": [ { "type": "ExportSpecifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61}}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59}}, "local": { "type": "Identifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59},"identifierName":"foo"}, "name": "foo" }, "exported": { "type": "Identifier", - "start":58,"end":61,"loc":{"start":{"line":2,"column":9,"index":58},"end":{"line":2,"column":12,"index":61},"identifierName":"foo"}, + "start":56,"end":59,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":12,"index":59},"identifierName":"foo"}, "name": "foo" } } ], "source": { "type": "StringLiteral", - "start":69,"end":79,"loc":{"start":{"line":2,"column":20,"index":69},"end":{"line":2,"column":30,"index":79}}, + "start":67,"end":77,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":30,"index":77}}, "extra": { "rawValue": "foo.json", "raw": "\"foo.json\"" @@ -80,18 +80,18 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":89,"end":99,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":50,"index":99}}, + "start":85,"end":95,"loc":{"start":{"line":2,"column":38,"index":85},"end":{"line":2,"column":48,"index":95}}, "key": { "type": "Identifier", - "start":89,"end":92,"loc":{"start":{"line":2,"column":40,"index":89},"end":{"line":2,"column":43,"index":92},"identifierName":"for"}, + "start":85,"end":88,"loc":{"start":{"line":2,"column":38,"index":85},"end":{"line":2,"column":41,"index":88},"identifierName":"for"}, "name": "for" }, "value": { "type": "StringLiteral", - "start":94,"end":99,"loc":{"start":{"line":2,"column":45,"index":94},"end":{"line":2,"column":50,"index":99}}, + "start":90,"end":95,"loc":{"start":{"line":2,"column":43,"index":90},"end":{"line":2,"column":48,"index":95}}, "extra": { "rawValue": "for", "raw": "\"for\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js index b448aa280c34..0be461789922 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/input.js @@ -1,2 +1,2 @@ import("foo.js",); -import("foo.json", { assert: { type: "json" } },); +import("foo.json", { with: { type: "json" } },); diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/options.json new file mode 100644 index 000000000000..8e819aac0027 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (2:47)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json deleted file mode 100644 index e484d6873f0f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma-dynamic/output.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "type": "File", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, - "program": { - "type": "Program", - "start":0,"end":69,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":50,"index":69}}, - "sourceType": "module", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":18,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":18,"index":18}}, - "expression": { - "type": "CallExpression", - "start":0,"end":17,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":17,"index":17}}, - "callee": { - "type": "Import", - "start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}} - }, - "extra": { - "trailingComma": 15 - }, - "arguments": [ - { - "type": "StringLiteral", - "start":7,"end":15,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":15,"index":15}}, - "extra": { - "rawValue": "foo.js", - "raw": "\"foo.js\"" - }, - "value": "foo.js" - } - ] - } - }, - { - "type": "ExpressionStatement", - "start":19,"end":69,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":50,"index":69}}, - "expression": { - "type": "CallExpression", - "start":19,"end":68,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":49,"index":68}}, - "callee": { - "type": "Import", - "start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}} - }, - "extra": { - "trailingComma": 66 - }, - "arguments": [ - { - "type": "StringLiteral", - "start":26,"end":36,"loc":{"start":{"line":2,"column":7,"index":26},"end":{"line":2,"column":17,"index":36}}, - "extra": { - "rawValue": "foo.json", - "raw": "\"foo.json\"" - }, - "value": "foo.json" - }, - { - "type": "ObjectExpression", - "start":38,"end":66,"loc":{"start":{"line":2,"column":19,"index":38},"end":{"line":2,"column":47,"index":66}}, - "properties": [ - { - "type": "ObjectProperty", - "start":40,"end":64,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":45,"index":64}}, - "method": false, - "key": { - "type": "Identifier", - "start":40,"end":46,"loc":{"start":{"line":2,"column":21,"index":40},"end":{"line":2,"column":27,"index":46},"identifierName":"assert"}, - "name": "assert" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "ObjectExpression", - "start":48,"end":64,"loc":{"start":{"line":2,"column":29,"index":48},"end":{"line":2,"column":45,"index":64}}, - "properties": [ - { - "type": "ObjectProperty", - "start":50,"end":62,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":43,"index":62}}, - "method": false, - "key": { - "type": "Identifier", - "start":50,"end":54,"loc":{"start":{"line":2,"column":31,"index":50},"end":{"line":2,"column":35,"index":54},"identifierName":"type"}, - "name": "type" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "StringLiteral", - "start":56,"end":62,"loc":{"start":{"line":2,"column":37,"index":56},"end":{"line":2,"column":43,"index":62}}, - "extra": { - "rawValue": "json", - "raw": "\"json\"" - }, - "value": "json" - } - } - ] - } - } - ] - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js index 077d150d81ae..10bc32278776 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/input.js @@ -1,2 +1,2 @@ -import foo from "foo" assert { type: "json", } -export { default as foo } from "foo" assert { type: "json", } +import foo from "foo" with { type: "json", } +export { default as foo } from "foo" with { type: "json", } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json index 77f11f2c63a2..3150a0048129 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/trailing-comma/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "start":0,"end":104,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":59,"index":104}}, "program": { "type": "Program", - "start":0,"end":108,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":61,"index":108}}, + "start":0,"end":104,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":59,"index":104}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":46,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":46,"index":46}}, + "start":0,"end":44,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":44,"index":44}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":31,"end":43,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":43,"index":43}}, + "start":29,"end":41,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":41,"index":41}}, "key": { "type": "Identifier", - "start":31,"end":35,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":35,"index":35},"identifierName":"type"}, + "start":29,"end":33,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":33,"index":33},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":37,"end":43,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":43,"index":43}}, + "start":35,"end":41,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":41,"index":41}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -53,26 +53,26 @@ }, { "type": "ExportNamedDeclaration", - "start":47,"end":108,"loc":{"start":{"line":2,"column":0,"index":47},"end":{"line":2,"column":61,"index":108}}, + "start":45,"end":104,"loc":{"start":{"line":2,"column":0,"index":45},"end":{"line":2,"column":59,"index":104}}, "specifiers": [ { "type": "ExportSpecifier", - "start":56,"end":70,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":23,"index":70}}, + "start":54,"end":68,"loc":{"start":{"line":2,"column":9,"index":54},"end":{"line":2,"column":23,"index":68}}, "local": { "type": "Identifier", - "start":56,"end":63,"loc":{"start":{"line":2,"column":9,"index":56},"end":{"line":2,"column":16,"index":63},"identifierName":"default"}, + "start":54,"end":61,"loc":{"start":{"line":2,"column":9,"index":54},"end":{"line":2,"column":16,"index":61},"identifierName":"default"}, "name": "default" }, "exported": { "type": "Identifier", - "start":67,"end":70,"loc":{"start":{"line":2,"column":20,"index":67},"end":{"line":2,"column":23,"index":70},"identifierName":"foo"}, + "start":65,"end":68,"loc":{"start":{"line":2,"column":20,"index":65},"end":{"line":2,"column":23,"index":68},"identifierName":"foo"}, "name": "foo" } } ], "source": { "type": "StringLiteral", - "start":78,"end":83,"loc":{"start":{"line":2,"column":31,"index":78},"end":{"line":2,"column":36,"index":83}}, + "start":76,"end":81,"loc":{"start":{"line":2,"column":31,"index":76},"end":{"line":2,"column":36,"index":81}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" @@ -80,18 +80,18 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":93,"end":105,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":58,"index":105}}, + "start":89,"end":101,"loc":{"start":{"line":2,"column":44,"index":89},"end":{"line":2,"column":56,"index":101}}, "key": { "type": "Identifier", - "start":93,"end":97,"loc":{"start":{"line":2,"column":46,"index":93},"end":{"line":2,"column":50,"index":97},"identifierName":"type"}, + "start":89,"end":93,"loc":{"start":{"line":2,"column":44,"index":89},"end":{"line":2,"column":48,"index":93},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":99,"end":105,"loc":{"start":{"line":2,"column":52,"index":99},"end":{"line":2,"column":58,"index":105}}, + "start":95,"end":101,"loc":{"start":{"line":2,"column":50,"index":95},"end":{"line":2,"column":56,"index":101}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js deleted file mode 100644 index 758659de4037..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/input.js +++ /dev/null @@ -1,4 +0,0 @@ -import foo, { bar } from "foo" assert {}; -import * as ns from "foo" assert {}; -export { quux } from "foo" assert {}; -export * as ns2 from "foo" assert {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/input.js new file mode 100644 index 000000000000..8bde57a92d52 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" with {}; +import * as ns from "foo" with {}; +export { quux } from "foo" with {}; +export * as ns2 from "foo" with {}; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/output.json similarity index 61% rename from packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/output.json index 7bb565c095bc..ed172f70aeff 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-assertion/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-empty-attribute/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "start":0,"end":146,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":35,"index":146}}, "program": { "type": "Program", - "start":0,"end":154,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":37,"index":154}}, + "start":0,"end":146,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":4,"column":35,"index":146}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":41,"index":41}}, + "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -44,55 +44,55 @@ }, "value": "foo" }, - "assertions": [] + "attributes": [] }, { "type": "ImportDeclaration", - "start":42,"end":78,"loc":{"start":{"line":2,"column":0,"index":42},"end":{"line":2,"column":36,"index":78}}, + "start":40,"end":74,"loc":{"start":{"line":2,"column":0,"index":40},"end":{"line":2,"column":34,"index":74}}, "specifiers": [ { "type": "ImportNamespaceSpecifier", - "start":49,"end":56,"loc":{"start":{"line":2,"column":7,"index":49},"end":{"line":2,"column":14,"index":56}}, + "start":47,"end":54,"loc":{"start":{"line":2,"column":7,"index":47},"end":{"line":2,"column":14,"index":54}}, "local": { "type": "Identifier", - "start":54,"end":56,"loc":{"start":{"line":2,"column":12,"index":54},"end":{"line":2,"column":14,"index":56},"identifierName":"ns"}, + "start":52,"end":54,"loc":{"start":{"line":2,"column":12,"index":52},"end":{"line":2,"column":14,"index":54},"identifierName":"ns"}, "name": "ns" } } ], "source": { "type": "StringLiteral", - "start":62,"end":67,"loc":{"start":{"line":2,"column":20,"index":62},"end":{"line":2,"column":25,"index":67}}, + "start":60,"end":65,"loc":{"start":{"line":2,"column":20,"index":60},"end":{"line":2,"column":25,"index":65}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" }, "value": "foo" }, - "assertions": [] + "attributes": [] }, { "type": "ExportNamedDeclaration", - "start":79,"end":116,"loc":{"start":{"line":3,"column":0,"index":79},"end":{"line":3,"column":37,"index":116}}, + "start":75,"end":110,"loc":{"start":{"line":3,"column":0,"index":75},"end":{"line":3,"column":35,"index":110}}, "specifiers": [ { "type": "ExportSpecifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92}}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88}}, "local": { "type": "Identifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88},"identifierName":"quux"}, "name": "quux" }, "exported": { "type": "Identifier", - "start":88,"end":92,"loc":{"start":{"line":3,"column":9,"index":88},"end":{"line":3,"column":13,"index":92},"identifierName":"quux"}, + "start":84,"end":88,"loc":{"start":{"line":3,"column":9,"index":84},"end":{"line":3,"column":13,"index":88},"identifierName":"quux"}, "name": "quux" } } ], "source": { "type": "StringLiteral", - "start":100,"end":105,"loc":{"start":{"line":3,"column":21,"index":100},"end":{"line":3,"column":26,"index":105}}, + "start":96,"end":101,"loc":{"start":{"line":3,"column":21,"index":96},"end":{"line":3,"column":26,"index":101}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" @@ -100,32 +100,32 @@ "value": "foo" }, "declaration": null, - "assertions": [] + "attributes": [] }, { "type": "ExportNamedDeclaration", - "start":117,"end":154,"loc":{"start":{"line":4,"column":0,"index":117},"end":{"line":4,"column":37,"index":154}}, + "start":111,"end":146,"loc":{"start":{"line":4,"column":0,"index":111},"end":{"line":4,"column":35,"index":146}}, "specifiers": [ { "type": "ExportNamespaceSpecifier", - "start":124,"end":132,"loc":{"start":{"line":4,"column":7,"index":124},"end":{"line":4,"column":15,"index":132}}, + "start":118,"end":126,"loc":{"start":{"line":4,"column":7,"index":118},"end":{"line":4,"column":15,"index":126}}, "exported": { "type": "Identifier", - "start":129,"end":132,"loc":{"start":{"line":4,"column":12,"index":129},"end":{"line":4,"column":15,"index":132},"identifierName":"ns2"}, + "start":123,"end":126,"loc":{"start":{"line":4,"column":12,"index":123},"end":{"line":4,"column":15,"index":126},"identifierName":"ns2"}, "name": "ns2" } } ], "source": { "type": "StringLiteral", - "start":138,"end":143,"loc":{"start":{"line":4,"column":21,"index":138},"end":{"line":4,"column":26,"index":143}}, + "start":132,"end":137,"loc":{"start":{"line":4,"column":21,"index":132},"end":{"line":4,"column":26,"index":137}}, "extra": { "rawValue": "foo", "raw": "\"foo\"" }, "value": "foo" }, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json index aca45ad21ed1..f3d5a6da191c 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-class/output.json @@ -12,7 +12,6 @@ "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "ClassDeclaration", "start":7,"end":19,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":19,"index":19}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json index 0ee5e9db8111..8644fb8db119 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-function/output.json @@ -12,7 +12,6 @@ "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "FunctionDeclaration", "start":7,"end":24,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":24,"index":24}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json index c653fb95cd93..79a96b788df5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-variable/output.json @@ -12,7 +12,6 @@ "start":0,"end":22,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":22,"index":22}}, "specifiers": [], "source": null, - "assertions": [], "declaration": { "type": "VariableDeclaration", "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json index 8e9b3109b83e..03a1202728af 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-export-without-from/output.json @@ -52,8 +52,7 @@ } ], "source": null, - "declaration": null, - "assertions": [] + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js deleted file mode 100644 index dcc37efe8067..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/input.js +++ /dev/null @@ -1 +0,0 @@ -import "foo" assert { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/input.js new file mode 100644 index 000000000000..74070b3d002e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/input.js @@ -0,0 +1 @@ +import "foo" with { "type": "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/output.json similarity index 58% rename from packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json rename to packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/output.json index b89ace5ec3fa..12924620911d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-assertion-key/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-string-attribute-key/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "program": { "type": "Program", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":39,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":39,"index":39}}, + "start":0,"end":37,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":37,"index":37}}, "specifiers": [], "source": { "type": "StringLiteral", @@ -20,13 +20,13 @@ }, "value": "foo" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":22,"end":36,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":36,"index":36}}, + "start":20,"end":34,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":34,"index":34}}, "key": { "type": "StringLiteral", - "start":22,"end":28,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":28,"index":28}}, + "start":20,"end":26,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":26,"index":26}}, "extra": { "rawValue": "type", "raw": "\"type\"" @@ -35,7 +35,7 @@ }, "value": { "type": "StringLiteral", - "start":30,"end":36,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":36,"index":36}}, + "start":28,"end":34,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":34,"index":34}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js index f97e9ee25718..4e9fbefb8919 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/input.js @@ -1 +1 @@ -export * as foo from "foo.json" assert { type: "json" }; +export * as foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json index 65d77c809f2c..0bc31dfbd1b5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-as-with-attributes/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "program": { "type": "Program", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":56,"index":56}}, + "start":0,"end":54,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":54,"index":54}}, "specifiers": [ { "type": "ExportNamespaceSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":41,"end":53,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":53,"index":53}}, + "start":39,"end":51,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":51,"index":51}}, "key": { "type": "Identifier", - "start":41,"end":45,"loc":{"start":{"line":1,"column":41,"index":41},"end":{"line":1,"column":45,"index":45},"identifierName":"type"}, + "start":39,"end":43,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":43,"index":43},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":47,"end":53,"loc":{"start":{"line":1,"column":47,"index":47},"end":{"line":1,"column":53,"index":53}}, + "start":45,"end":51,"loc":{"start":{"line":1,"column":45,"index":45},"end":{"line":1,"column":51,"index":51}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js index b8a5d6580862..70566cfaf1f3 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/input.js @@ -1 +1 @@ -export * from "foo.json" assert { type: "json" }; +export * from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json index 9b526a568057..7d2294b4a354 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-star-with-attributes/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, "program": { "type": "Program", - "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportAllDeclaration", - "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, + "start":0,"end":47,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":47,"index":47}}, "source": { "type": "StringLiteral", "start":14,"end":24,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":24,"index":24}}, @@ -19,18 +19,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, + "start":32,"end":44,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":44,"index":44}}, "key": { "type": "Identifier", - "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, + "start":32,"end":36,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":36,"index":36},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, + "start":38,"end":44,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":44,"index":44}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js index a3830551716f..e8a58d263541 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -1,2 +1,2 @@ -export { default as x } from "foo" assert +export { default as x } from "foo" with { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json index 88f1415f189c..a5ede1e3b955 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "program": { "type": "Program", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":58}}, + "start":0,"end":56,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":56}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,18 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":14,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":2,"column":2,"index":42},"end":{"line":2,"column":14,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":2,"column":2,"index":44},"end":{"line":2,"column":6,"index":48},"identifierName":"type"}, + "start":42,"end":46,"loc":{"start":{"line":2,"column":2,"index":42},"end":{"line":2,"column":6,"index":46},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":2,"column":8,"index":50},"end":{"line":2,"column":14,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":2,"column":8,"index":48},"end":{"line":2,"column":14,"index":54}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js index 567f6335c84c..458d863897b5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/input.js @@ -1,2 +1,2 @@ -export { "default" as x } from "foo" assert { type: "json" } +export { "default" as x } from "foo" with { type: "json" } [0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json index c947ca3ee8d4..21b9d8e6fae6 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes-and-value/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":62}}, "program": { "type": "Program", - "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":64}}, + "start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":62}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":60,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":60,"index":60}}, + "start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":58,"index":58}}, "specifiers": [ { "type": "ExportSpecifier", @@ -40,18 +40,18 @@ "value": "foo" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":46,"end":58,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":58,"index":58}}, + "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, "key": { "type": "Identifier", - "start":46,"end":50,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":50,"index":50},"identifierName":"type"}, + "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":52,"end":58,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":58,"index":58}}, + "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -63,14 +63,14 @@ }, { "type": "ExpressionStatement", - "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "start":59,"end":62,"loc":{"start":{"line":2,"column":0,"index":59},"end":{"line":2,"column":3,"index":62}}, "expression": { "type": "ArrayExpression", - "start":61,"end":64,"loc":{"start":{"line":2,"column":0,"index":61},"end":{"line":2,"column":3,"index":64}}, + "start":59,"end":62,"loc":{"start":{"line":2,"column":0,"index":59},"end":{"line":2,"column":3,"index":62}}, "elements": [ { "type": "NumericLiteral", - "start":62,"end":63,"loc":{"start":{"line":2,"column":1,"index":62},"end":{"line":2,"column":2,"index":63}}, + "start":60,"end":61,"loc":{"start":{"line":2,"column":1,"index":60},"end":{"line":2,"column":2,"index":61}}, "extra": { "rawValue": 0, "raw": "0" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js index 08775ba22ed4..8d791f4fe480 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/input.js @@ -1 +1 @@ -export { default as foo } from "foo.json" assert { type: "json" }; +export { default as foo } from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json index ef4f180d3be1..b3f7ab928398 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-attributes/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "program": { "type": "Program", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":66,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":66,"index":66}}, + "start":0,"end":64,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":64,"index":64}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,18 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":51,"end":63,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":63,"index":63}}, + "start":49,"end":61,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":61,"index":61}}, "key": { "type": "Identifier", - "start":51,"end":55,"loc":{"start":{"line":1,"column":51,"index":51},"end":{"line":1,"column":55,"index":55},"identifierName":"type"}, + "start":49,"end":53,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":53,"index":53},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":57,"end":63,"loc":{"start":{"line":1,"column":57,"index":57},"end":{"line":1,"column":63,"index":63}}, + "start":55,"end":61,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":61,"index":61}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js index 23710fef0b6d..7a70c7f04630 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/input.js @@ -1 +1 @@ -export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; +export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json index c370bb9870ad..3b039e9a62e8 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAttributes" - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:64)" + "throws": "Only string literals are allowed as module attribute values. (1:62)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js index 5dbd2c429901..4553d256b1cb 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/input.js @@ -1 +1 @@ -export { default } from "foo.json" assert { lazy: "true" }; +export { default } from "foo.json" with { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json index 3342a818b5fb..9c1d13f1237d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-no-type-attribute/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "program": { "type": "Program", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":59,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":59,"index":59}}, + "start":0,"end":57,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":57,"index":57}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,18 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":54,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"lazy"}, + "start":42,"end":46,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":46,"index":46},"identifierName":"lazy"}, "name": "lazy" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":54,"index":54}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js index 8acdf464a395..0e8993714a3f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/input.js @@ -1 +1 @@ -export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; +export { default } from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json index 4a4a18b389c0..375950a3df51 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-with-object-method-attribute/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "program": { "type": "Program", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ExportNamedDeclaration", - "start":0,"end":83,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":83,"index":83}}, + "start":0,"end":81,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":81,"index":81}}, "specifiers": [ { "type": "ExportSpecifier", @@ -36,18 +36,18 @@ "value": "foo.json" }, "declaration": null, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":44,"end":56,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":56,"index":56}}, + "start":42,"end":54,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":54,"index":54}}, "key": { "type": "Identifier", - "start":44,"end":48,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":48,"index":48},"identifierName":"type"}, + "start":42,"end":46,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":46,"index":46},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":50,"end":56,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":56,"index":56}}, + "start":48,"end":54,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":54,"index":54}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -57,15 +57,15 @@ }, { "type": "ImportAttribute", - "start":58,"end":80,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":80,"index":80}}, + "start":56,"end":78,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":78,"index":78}}, "key": { "type": "Identifier", - "start":58,"end":72,"loc":{"start":{"line":1,"column":58,"index":58},"end":{"line":1,"column":72,"index":72},"identifierName":"hasOwnProperty"}, + "start":56,"end":70,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":70,"index":70},"identifierName":"hasOwnProperty"}, "name": "hasOwnProperty" }, "value": { "type": "StringLiteral", - "start":74,"end":80,"loc":{"start":{"line":1,"column":74,"index":74},"end":{"line":1,"column":80,"index":80}}, + "start":72,"end":78,"loc":{"start":{"line":1,"column":72,"index":72},"end":{"line":1,"column":78,"index":78}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json index d1a3c1dde93b..65a4f9f1ed38 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-export-without-attributes/output.json @@ -36,7 +36,7 @@ "value": "foo.json" }, "declaration": null, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js index 4f1ee63fb3a6..b9907829ef29 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/input.js @@ -1,2 +1,2 @@ -import "x" assert { type: "json" } +import "x" with { type: "json" } [0] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json index da75c3198d9f..7bbeab6f8b80 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-and-value/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":36}}, "program": { "type": "Program", - "start":0,"end":38,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":38}}, + "start":0,"end":36,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":3,"index":36}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":34,"index":34}}, + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":32,"index":32}}, "specifiers": [], "source": { "type": "StringLiteral", @@ -20,18 +20,18 @@ }, "value": "x" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":20,"end":32,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":32,"index":32}}, + "start":18,"end":30,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":30,"index":30}}, "key": { "type": "Identifier", - "start":20,"end":24,"loc":{"start":{"line":1,"column":20,"index":20},"end":{"line":1,"column":24,"index":24},"identifierName":"type"}, + "start":18,"end":22,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":22,"index":22},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":26,"end":32,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":32,"index":32}}, + "start":24,"end":30,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":30,"index":30}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -43,14 +43,14 @@ }, { "type": "ExpressionStatement", - "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "start":33,"end":36,"loc":{"start":{"line":2,"column":0,"index":33},"end":{"line":2,"column":3,"index":36}}, "expression": { "type": "ArrayExpression", - "start":35,"end":38,"loc":{"start":{"line":2,"column":0,"index":35},"end":{"line":2,"column":3,"index":38}}, + "start":33,"end":36,"loc":{"start":{"line":2,"column":0,"index":33},"end":{"line":2,"column":3,"index":36}}, "elements": [ { "type": "NumericLiteral", - "start":36,"end":37,"loc":{"start":{"line":2,"column":1,"index":36},"end":{"line":2,"column":2,"index":37}}, + "start":34,"end":35,"loc":{"start":{"line":2,"column":1,"index":34},"end":{"line":2,"column":2,"index":35}}, "extra": { "rawValue": 0, "raw": "0" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js index 92c0d33eddd0..e78e2c90f72d 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js @@ -1,2 +1,2 @@ -import "x" assert +import "x" with { type: "json" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json index c11f4c7ce6cf..15988e0c945b 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes-multiple-lines/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, "program": { "type": "Program", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":34,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":34}}, + "start":0,"end":32,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":16,"index":32}}, "specifiers": [], "source": { "type": "StringLiteral", @@ -20,18 +20,18 @@ }, "value": "x" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":20,"end":32,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":14,"index":32}}, + "start":18,"end":30,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":14,"index":30}}, "key": { "type": "Identifier", - "start":20,"end":24,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":2,"column":6,"index":24},"identifierName":"type"}, + "start":18,"end":22,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":6,"index":22},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":26,"end":32,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":14,"index":32}}, + "start":24,"end":30,"loc":{"start":{"line":2,"column":8,"index":24},"end":{"line":2,"column":14,"index":30}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js index 7b43091236b9..83c51c971889 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json index 264361dead53..de2bdc0bfb5f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-attributes/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "program": { "type": "Program", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "json", "raw": "\"json\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js index 01425ab2e2e7..3f350904e07f 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; +import foo from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json index 63ec3761f53d..9326901e4d93 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-invalid-value/options.json @@ -1,9 +1,3 @@ { - "plugins": [ - [ - "importAttributes" - ] - ], - "sourceType": "module", - "throws": "Only string literals are allowed as module attribute values. (1:56)" -} \ No newline at end of file + "throws": "Only string literals are allowed as module attribute values. (1:54)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js index bdcedd93bb26..1858e49c2022 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { lazy: "true" }; +import foo from "foo.json" with { lazy: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json index 7f5e6b799987..97e5d13bd9e5 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-no-type-attribute/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "program": { "type": "Program", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":51,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":51,"index":51}}, + "start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":49,"index":49}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"lazy"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"lazy"}, "name": "lazy" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js index 828d93472261..2ec8345c8e15 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; +import foo from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json index c15b8c2d4f45..bc507378678e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-with-object-method-attribute/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "program": { "type": "Program", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":75,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":75,"index":75}}, + "start":0,"end":73,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":73,"index":73}}, "specifiers": [ { "type": "ImportDefaultSpecifier", @@ -30,18 +30,18 @@ }, "value": "foo.json" }, - "assertions": [ + "attributes": [ { "type": "ImportAttribute", - "start":36,"end":48,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":48,"index":48}}, + "start":34,"end":46,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":46,"index":46}}, "key": { "type": "Identifier", - "start":36,"end":40,"loc":{"start":{"line":1,"column":36,"index":36},"end":{"line":1,"column":40,"index":40},"identifierName":"type"}, + "start":34,"end":38,"loc":{"start":{"line":1,"column":34,"index":34},"end":{"line":1,"column":38,"index":38},"identifierName":"type"}, "name": "type" }, "value": { "type": "StringLiteral", - "start":42,"end":48,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":48,"index":48}}, + "start":40,"end":46,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":46,"index":46}}, "extra": { "rawValue": "json", "raw": "\"json\"" @@ -51,15 +51,15 @@ }, { "type": "ImportAttribute", - "start":50,"end":72,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":72,"index":72}}, + "start":48,"end":70,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":70,"index":70}}, "key": { "type": "Identifier", - "start":50,"end":64,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":64,"index":64},"identifierName":"hasOwnProperty"}, + "start":48,"end":62,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":62,"index":62},"identifierName":"hasOwnProperty"}, "name": "hasOwnProperty" }, "value": { "type": "StringLiteral", - "start":66,"end":72,"loc":{"start":{"line":1,"column":66,"index":66},"end":{"line":1,"column":72,"index":72}}, + "start":64,"end":70,"loc":{"start":{"line":1,"column":64,"index":64},"end":{"line":1,"column":70,"index":70}}, "extra": { "rawValue": "true", "raw": "\"true\"" diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json index 8f00ebbb3e89..de12941db425 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/valid-syntax-without-attributes/output.json @@ -30,7 +30,7 @@ }, "value": "foo.json" }, - "assertions": [] + "attributes": [] } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js index 7b43091236b9..83c51c971889 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/input.js @@ -1 +1 @@ -import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" with { type: "json" }; diff --git a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json index ef8b957b9903..a1899f538d7e 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-attributes/without-plugin/options.json @@ -1,5 +1,5 @@ { "plugins": [], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:27)" + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" } diff --git a/packages/babel-parser/test/fixtures/experimental/import-reflection/invalid-assertions/output.json b/packages/babel-parser/test/fixtures/experimental/import-reflection/invalid-assertions/output.json index d659444d99bf..2ac285477626 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-reflection/invalid-assertions/output.json +++ b/packages/babel-parser/test/fixtures/experimental/import-reflection/invalid-assertions/output.json @@ -34,6 +34,9 @@ }, "value": "./module.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/options.json b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/options.json index 44ff060e42a7..eefe547dd31b 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/options.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/options.json @@ -1,4 +1,7 @@ { - "plugins": ["importAssertions", "exportDefaultFrom"], + "plugins": [ + "importAssertions", + "exportDefaultFrom" + ], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/output.json index db2af548e9f8..9e085a4ca095 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-exports/output.json @@ -67,7 +67,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-imports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-imports/output.json index c249ab738bcf..092c6d60a6bc 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-imports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-default-and-named-imports/output.json @@ -47,6 +47,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-exports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-exports/output.json index 0967435867ab..aa36267e85a1 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-exports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-exports/output.json @@ -58,7 +58,10 @@ "value": "json" } } - ] + ], + "extra": { + "usesAssertKeyword": true + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-imports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-imports/output.json index 51eb315165af..3875b362f4ae 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-imports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/invalid-named-imports/output.json @@ -38,6 +38,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-all-exports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-all-exports/output.json index ef41ee07b33c..f75145cd3c79 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-all-exports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-all-exports/output.json @@ -19,6 +19,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/options.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/options.json index 44ff060e42a7..eefe547dd31b 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/options.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/options.json @@ -1,4 +1,7 @@ { - "plugins": ["importAssertions", "exportDefaultFrom"], + "plugins": [ + "importAssertions", + "exportDefaultFrom" + ], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/output.json index f62519cc3122..dc18fbbfb91e 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-exports/output.json @@ -39,6 +39,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-imports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-imports/output.json index c3b74bde7926..72cb3de4563c 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-imports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-default-and-namespace-imports/output.json @@ -39,6 +39,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-exports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-exports/output.json index 8d6700a299cc..a5e9f8401c89 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-exports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-exports/output.json @@ -30,6 +30,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-imports/output.json b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-imports/output.json index ea6e41eb2c15..027453114628 100644 --- a/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-imports/output.json +++ b/packages/babel-parser/test/fixtures/experimental/json-modules/valid-namespace-imports/output.json @@ -30,6 +30,9 @@ }, "value": "./fixture.json" }, + "extra": { + "usesAssertKeyword": true + }, "assertions": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/import-with-statement/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/import-with-statement/output.json index a6e08864ec35..532a054d9fb2 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/import-with-statement/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/import-with-statement/output.json @@ -1,38 +1,37 @@ { "type": "File", - "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":10}}, "errors": [ "SyntaxError: 'with' in strict mode. (2:0)" ], "program": { "type": "Program", - "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":10,"index":21}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":10}}, "sourceType": "module", "interpreter": null, "body": [ { "type": "ImportDeclaration", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, "specifiers": [], "source": { "type": "Literal", - "start":7,"end":10,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":10,"index":10}}, + "start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}}, "value": "x", "raw": "\"x\"" - }, - "attributes": [] + } }, { "type": "WithStatement", - "start":11,"end":21,"loc":{"start":{"line":2,"column":0,"index":11},"end":{"line":2,"column":10,"index":21}}, + "start":11,"end":21,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":10}}, "object": { "type": "ObjectExpression", - "start":17,"end":19,"loc":{"start":{"line":2,"column":6,"index":17},"end":{"line":2,"column":8,"index":19}}, + "start":17,"end":19,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":8}}, "properties": [] }, "body": { "type": "EmptyStatement", - "start":20,"end":21,"loc":{"start":{"line":2,"column":9,"index":20},"end":{"line":2,"column":10,"index":21}} + "start":20,"end":21,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10}} } } ] diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json index 12dd873d4537..5cb229abadf1 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: \"moduleAttributes\". (1:27)", - "plugins": [] + "plugins": [], + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" } From 4f5f295d69a6bb4c6b5615c689a7a86bb1463d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 18:50:44 +0200 Subject: [PATCH 04/17] Add types and generator support --- .../babel-generator/src/generators/modules.ts | 50 +++++++++---------- .../import-attributes/assertions/input.js | 2 + .../import-attributes/assertions/options.json | 3 ++ .../import-attributes/assertions/output.js | 2 + .../import-attributes/attributes/input.js | 2 + .../import-attributes/attributes/options.json | 3 ++ .../import-attributes/attributes/output.js | 2 + packages/babel-parser/src/parser/statement.ts | 1 + .../output.json | 3 ++ .../output.json | 3 ++ .../valid-syntax-with-attributes/output.json | 3 ++ .../output.json | 3 ++ .../output.json | 3 ++ .../output.json | 3 ++ .../src/ast-types/generated/index.ts | 3 ++ packages/babel-types/src/definitions/core.ts | 24 +++++++++ packages/babel-types/src/definitions/utils.ts | 4 +- 17 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/import-attributes/assertions/input.js create mode 100644 packages/babel-generator/test/fixtures/import-attributes/assertions/options.json create mode 100644 packages/babel-generator/test/fixtures/import-attributes/assertions/output.js create mode 100644 packages/babel-generator/test/fixtures/import-attributes/attributes/input.js create mode 100644 packages/babel-generator/test/fixtures/import-attributes/attributes/options.json create mode 100644 packages/babel-generator/test/fixtures/import-attributes/attributes/output.js diff --git a/packages/babel-generator/src/generators/modules.ts b/packages/babel-generator/src/generators/modules.ts index b34eb14f0139..338813dfb674 100644 --- a/packages/babel-generator/src/generators/modules.ts +++ b/packages/babel-generator/src/generators/modules.ts @@ -66,17 +66,25 @@ export function ExportNamespaceSpecifier( this.print(node.exported, node); } -export function _printAssertions( +export function _printAttributes( this: Printer, - node: Extract, + node: Extract, ) { - this.word("assert"); - this.space(); - this.token("{"); - this.space(); - this.printList(node.assertions, node); + if (!node.attributes || node.extra?.usesAssertKeyword) { + this.word("assert"); + } else { + this.word("with"); + } this.space(); - this.token("}"); + if (!node.extra?.useLegacyModuleAttributes) { + this.token("{"); + this.space(); + } + this.printList(node.attributes || node.assertions, node); + if (!node.extra?.useLegacyModuleAttributes) { + this.space(); + this.token("}"); + } } export function ExportAllDeclaration( @@ -93,12 +101,12 @@ export function ExportAllDeclaration( this.space(); this.word("from"); this.space(); - // @ts-expect-error Fixme: assertions is not defined in DeclareExportAllDeclaration - if (node.assertions?.length) { + // @ts-expect-error Fixme: attributes is not defined in DeclareExportAllDeclaration + if (node.attributes?.length || node.assertions?.length) { this.print(node.source, node, true); this.space(); - // @ts-expect-error Fixme: assertions is not defined in DeclareExportAllDeclaration - this._printAssertions(node); + // @ts-expect-error Fixme: attributes is not defined in DeclareExportAllDeclaration + this._printAttributes(node); } else { this.print(node.source, node); } @@ -173,10 +181,10 @@ export function ExportNamedDeclaration( this.space(); this.word("from"); this.space(); - if (node.assertions?.length) { + if (node.attributes?.length || node.assertions?.length) { this.print(node.source, node, true); this.space(); - this._printAssertions(node); + this._printAttributes(node); } else { this.print(node.source, node); } @@ -251,23 +259,13 @@ export function ImportDeclaration(this: Printer, node: t.ImportDeclaration) { this.space(); } - if (node.assertions?.length) { + if (node.attributes?.length || node.assertions?.length) { this.print(node.source, node, true); this.space(); - this._printAssertions(node); + this._printAttributes(node); } else { this.print(node.source, node); } - if (!process.env.BABEL_8_BREAKING) { - // @ts-ignore(Babel 7 vs Babel 8) Babel 7 supports module attributes - if (node.attributes?.length) { - this.space(); - this.word("with"); - this.space(); - // @ts-ignore(Babel 7 vs Babel 8) Babel 7 supports module attributes - this.printList(node.attributes, node); - } - } this.semicolon(); } diff --git a/packages/babel-generator/test/fixtures/import-attributes/assertions/input.js b/packages/babel-generator/test/fixtures/import-attributes/assertions/input.js new file mode 100644 index 000000000000..5472427ce3e3 --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/assertions/input.js @@ -0,0 +1,2 @@ +import "a" with { type: "json" }; +import "b" assert { type: "json" }; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/import-attributes/assertions/options.json b/packages/babel-generator/test/fixtures/import-attributes/assertions/options.json new file mode 100644 index 000000000000..a3a80a8b1511 --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/assertions/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["importAssertions"] +} diff --git a/packages/babel-generator/test/fixtures/import-attributes/assertions/output.js b/packages/babel-generator/test/fixtures/import-attributes/assertions/output.js new file mode 100644 index 000000000000..5472427ce3e3 --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/assertions/output.js @@ -0,0 +1,2 @@ +import "a" with { type: "json" }; +import "b" assert { type: "json" }; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/import-attributes/attributes/input.js b/packages/babel-generator/test/fixtures/import-attributes/attributes/input.js new file mode 100644 index 000000000000..5472427ce3e3 --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/attributes/input.js @@ -0,0 +1,2 @@ +import "a" with { type: "json" }; +import "b" assert { type: "json" }; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/import-attributes/attributes/options.json b/packages/babel-generator/test/fixtures/import-attributes/attributes/options.json new file mode 100644 index 000000000000..e177690b2c2a --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/attributes/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["importAttributes", { "deprecatedAssertSyntax": true }]] +} diff --git a/packages/babel-generator/test/fixtures/import-attributes/attributes/output.js b/packages/babel-generator/test/fixtures/import-attributes/attributes/output.js new file mode 100644 index 000000000000..5472427ce3e3 --- /dev/null +++ b/packages/babel-generator/test/fixtures/import-attributes/attributes/output.js @@ -0,0 +1,2 @@ +import "a" with { type: "json" }; +import "b" assert { type: "json" }; \ No newline at end of file diff --git a/packages/babel-parser/src/parser/statement.ts b/packages/babel-parser/src/parser/statement.ts index a06feab5835c..0888bdc3a019 100644 --- a/packages/babel-parser/src/parser/statement.ts +++ b/packages/babel-parser/src/parser/statement.ts @@ -3097,6 +3097,7 @@ export default abstract class StatementParser extends ExpressionParser { if (!process.env.BABEL_8_BREAKING) { if (this.hasPlugin("moduleAttributes")) { attributes = this.parseModuleAttributes(); + this.addExtra(node, "useLegacyModuleAttributes", true); } else { this.expectImportAttributesPlugin(); attributes = this.parseImportAttributes(); diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/invalid-syntax-with-attributes-multiple-lines/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/invalid-syntax-with-attributes-multiple-lines/output.json index a6025598b15d..8e74f882075f 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/invalid-syntax-with-attributes-multiple-lines/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/invalid-syntax-with-attributes-multiple-lines/output.json @@ -20,6 +20,9 @@ }, "value": "x" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes-and-value/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes-and-value/output.json index f2f045a1ce16..4fa3738af308 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes-and-value/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes-and-value/output.json @@ -20,6 +20,9 @@ }, "value": "x" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes/output.json index d703ad791d5d..8af10a8c77e6 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-attributes/output.json @@ -30,6 +30,9 @@ }, "value": "foo.json" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-no-type-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-no-type-attribute/output.json index 8d896fffafb3..a38a91f2cabf 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-no-type-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-no-type-attribute/output.json @@ -33,6 +33,9 @@ }, "value": "foo.json" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-object-method-attribute/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-object-method-attribute/output.json index cb134f6730f5..5c00a184e704 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-object-method-attribute/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-object-method-attribute/output.json @@ -33,6 +33,9 @@ }, "value": "foo.json" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-repeated-type/output.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-repeated-type/output.json index a6fc78b5400d..3cf42b1d0ac1 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-repeated-type/output.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/valid-syntax-with-repeated-type/output.json @@ -33,6 +33,9 @@ }, "value": "foo.json" }, + "extra": { + "useLegacyModuleAttributes": true + }, "attributes": [ { "type": "ImportAttribute", diff --git a/packages/babel-types/src/ast-types/generated/index.ts b/packages/babel-types/src/ast-types/generated/index.ts index ba045b24d0d0..ad57ce065a00 100644 --- a/packages/babel-types/src/ast-types/generated/index.ts +++ b/packages/babel-types/src/ast-types/generated/index.ts @@ -811,6 +811,7 @@ export interface ExportAllDeclaration extends BaseNode { type: "ExportAllDeclaration"; source: StringLiteral; assertions?: Array | null; + attributes?: Array | null; exportKind?: "type" | "value" | null; } @@ -832,6 +833,7 @@ export interface ExportNamedDeclaration extends BaseNode { >; source?: StringLiteral | null; assertions?: Array | null; + attributes?: Array | null; exportKind?: "type" | "value" | null; } @@ -857,6 +859,7 @@ export interface ImportDeclaration extends BaseNode { >; source: StringLiteral; assertions?: Array | null; + attributes?: Array | null; importKind?: "type" | "typeof" | "value" | null; module?: boolean | null; } diff --git a/packages/babel-types/src/definitions/core.ts b/packages/babel-types/src/definitions/core.ts index fcf2c130ef05..49a64300b04c 100644 --- a/packages/babel-types/src/definitions/core.ts +++ b/packages/babel-types/src/definitions/core.ts @@ -1495,6 +1495,14 @@ defineType("ExportAllDeclaration", { validate: assertNodeType("StringLiteral"), }, exportKind: validateOptional(assertOneOf("type", "value")), + attributes: { + optional: true, + validate: chain( + assertValueType("array"), + assertEach(assertNodeType("ImportAttribute")), + ), + }, + // TODO(Babel 8): Deprecated assertions: { optional: true, validate: chain( @@ -1566,6 +1574,14 @@ defineType("ExportNamedDeclaration", { }, ), }, + attributes: { + optional: true, + validate: chain( + assertValueType("array"), + assertEach(assertNodeType("ImportAttribute")), + ), + }, + // TODO(Babel 8): Deprecated assertions: { optional: true, validate: chain( @@ -1677,6 +1693,14 @@ defineType("ImportDeclaration", { visitor: ["specifiers", "source"], aliases: ["Statement", "Declaration", "ImportOrExportDeclaration"], fields: { + attributes: { + optional: true, + validate: chain( + assertValueType("array"), + assertEach(assertNodeType("ImportAttribute")), + ), + }, + // TODO(Babel 8): Deprecated assertions: { optional: true, validate: chain( diff --git a/packages/babel-types/src/definitions/utils.ts b/packages/babel-types/src/definitions/utils.ts index 7cbf0c701115..152d901fb3aa 100644 --- a/packages/babel-types/src/definitions/utils.ts +++ b/packages/babel-types/src/definitions/utils.ts @@ -56,6 +56,7 @@ export type Validator = ( export type FieldOptions = { default?: string | number | boolean | []; optional?: boolean; + deprecated?: boolean; validate?: Validator; }; @@ -277,7 +278,7 @@ const validTypeOpts = [ "visitor", "validate", ]; -const validFieldKeys = ["default", "optional", "validate"]; +const validFieldKeys = ["default", "optional", "deprecated", "validate"]; const store = {} as Record; @@ -317,6 +318,7 @@ export default function defineType(type: string, opts: DefineTypeOpts = {}) { fields[key] = { default: Array.isArray(def) ? [] : def, optional: field.optional, + deprecated: field.deprecated, validate: field.validate, }; } From 913ffe107258340a6546c1a8bf3edbc01740d6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 19:13:58 +0200 Subject: [PATCH 05/17] Create `@babel/plugin-syntax-import-attributes` --- .../src/parser/util/missing-plugin-helper.ts | 13 ++++-- .../.npmignore | 2 + .../README.md | 19 ++++++++ .../package.json | 44 +++++++++++++++++++ .../src/index.ts | 29 ++++++++++++ tsconfig.json | 4 ++ 6 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 packages/babel-plugin-syntax-import-attributes/.npmignore create mode 100644 packages/babel-plugin-syntax-import-attributes/README.md create mode 100644 packages/babel-plugin-syntax-import-attributes/package.json create mode 100644 packages/babel-plugin-syntax-import-attributes/src/index.ts diff --git a/packages/babel-core/src/parser/util/missing-plugin-helper.ts b/packages/babel-core/src/parser/util/missing-plugin-helper.ts index f4eee3891e49..a89b18d13138 100644 --- a/packages/babel-core/src/parser/util/missing-plugin-helper.ts +++ b/packages/babel-core/src/parser/util/missing-plugin-helper.ts @@ -84,10 +84,10 @@ const pluginNameMap: Record< url: "https://github.com/babel/babel/tree/main/packages/babel-preset-react", }, }, - importAssertions: { + importAttributes: { syntax: { - name: "@babel/plugin-syntax-import-assertions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions", + name: "@babel/plugin-syntax-import-attributes", + url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes", }, }, pipelineOperator: { @@ -207,6 +207,13 @@ if (!process.env.BABEL_8_BREAKING) { url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-namespace-from", }, }, + // Will be removed + importAssertions: { + syntax: { + name: "@babel/plugin-syntax-import-assertions", + url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions", + }, + }, importMeta: { syntax: { name: "@babel/plugin-syntax-import-meta", diff --git a/packages/babel-plugin-syntax-import-attributes/.npmignore b/packages/babel-plugin-syntax-import-attributes/.npmignore new file mode 100644 index 000000000000..281df3934ba3 --- /dev/null +++ b/packages/babel-plugin-syntax-import-attributes/.npmignore @@ -0,0 +1,2 @@ +src +test diff --git a/packages/babel-plugin-syntax-import-attributes/README.md b/packages/babel-plugin-syntax-import-attributes/README.md new file mode 100644 index 000000000000..2215629030c2 --- /dev/null +++ b/packages/babel-plugin-syntax-import-attributes/README.md @@ -0,0 +1,19 @@ +# @babel/plugin-syntax-import-assertions + +> Allow parsing of the module assertion attributes in the import statement + +See our website [@babel/plugin-syntax-import-assertions](https://babeljs.io/docs/en/babel-plugin-syntax-import-assertions) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/plugin-syntax-import-assertions +``` + +or using yarn: + +```sh +yarn add @babel/plugin-syntax-import-assertions --dev +``` diff --git a/packages/babel-plugin-syntax-import-attributes/package.json b/packages/babel-plugin-syntax-import-attributes/package.json new file mode 100644 index 000000000000..32a6effda248 --- /dev/null +++ b/packages/babel-plugin-syntax-import-attributes/package.json @@ -0,0 +1,44 @@ +{ + "name": "@babel/plugin-syntax-import-attributes", + "version": "7.20.0", + "description": "Allow parsing of the module attributes in the import statement", + "repository": { + "type": "git", + "url": "https://github.com/babel/babel.git", + "directory": "packages/babel-plugin-syntax-import-attributes" + }, + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "main": "./lib/index.js", + "keywords": [ + "babel-plugin" + ], + "dependencies": { + "@babel/helper-plugin-utils": "workspace:^" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + }, + "devDependencies": { + "@babel/core": "workspace:^" + }, + "engines": { + "node": ">=6.9.0" + }, + "author": "The Babel Team (https://babel.dev/team)", + "conditions": { + "USE_ESM": [ + { + "type": "module" + }, + null + ] + }, + "exports": { + ".": "./lib/index.js", + "./package.json": "./package.json" + }, + "type": "commonjs" +} diff --git a/packages/babel-plugin-syntax-import-attributes/src/index.ts b/packages/babel-plugin-syntax-import-attributes/src/index.ts new file mode 100644 index 000000000000..fb563ad3c7c1 --- /dev/null +++ b/packages/babel-plugin-syntax-import-attributes/src/index.ts @@ -0,0 +1,29 @@ +import { declare } from "@babel/helper-plugin-utils"; + +interface Options { + deprecatedAssertSyntax?: boolean; +} + +export default declare((api, { deprecatedAssertSyntax }: Options) => { + api.assertVersion(7); + + if ( + deprecatedAssertSyntax != null && + typeof deprecatedAssertSyntax !== "boolean" + ) { + throw new Error( + "'deprecatedAssertSyntax' must be a boolean, if specified.", + ); + } + + return { + name: "syntax-import-attributes", + + manipulateOptions(opts, parserOpts) { + parserOpts.plugins.push([ + "importAttributes", + { deprecatedAssertSyntax: Boolean(deprecatedAssertSyntax) }, + ]); + }, + }; +}); diff --git a/tsconfig.json b/tsconfig.json index a362623d5daf..ae1810915644 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -81,6 +81,7 @@ "./packages/babel-plugin-syntax-function-bind/src/**/*.ts", "./packages/babel-plugin-syntax-function-sent/src/**/*.ts", "./packages/babel-plugin-syntax-import-assertions/src/**/*.ts", + "./packages/babel-plugin-syntax-import-attributes/src/**/*.ts", "./packages/babel-plugin-syntax-import-reflection/src/**/*.ts", "./packages/babel-plugin-syntax-jsx/src/**/*.ts", "./packages/babel-plugin-syntax-module-blocks/src/**/*.ts", @@ -409,6 +410,9 @@ "@babel/plugin-syntax-import-assertions": [ "./packages/babel-plugin-syntax-import-assertions/src" ], + "@babel/plugin-syntax-import-attributes": [ + "./packages/babel-plugin-syntax-import-attributes/src" + ], "@babel/plugin-syntax-import-reflection": [ "./packages/babel-plugin-syntax-import-reflection/src" ], From f37bcc5fbba58027cf638404248a009a84ec8ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 19:15:20 +0200 Subject: [PATCH 06/17] Use in preset-env and standalone --- .../src/index.ts | 2 +- packages/babel-preset-env/package.json | 1 + packages/babel-preset-env/src/available-plugins.ts | 3 +++ packages/babel-preset-env/src/index.ts | 8 +++++++- .../babel-preset-env/src/plugins-compat-data.ts | 4 ++++ packages/babel-preset-env/src/shipped-proposals.ts | 5 ++++- .../stdout.txt | 2 +- .../entry-corejs2-shippedProposals/stdout.txt | 2 +- .../entry-corejs3-all-chrome-71/stdout.txt | 2 +- .../debug-babel-7/entry-corejs3-all/stdout.txt | 2 +- .../entry-corejs3-babel-polyfill/stdout.txt | 2 +- .../entry-corejs3-es-chrome-71/stdout.txt | 2 +- .../entry-corejs3-es-proposals-chrome-71/stdout.txt | 2 +- .../entry-corejs3-es-proposals/stdout.txt | 2 +- .../debug-babel-7/entry-corejs3-es/stdout.txt | 2 +- .../entry-corejs3-runtime-only-chrome-71/stdout.txt | 2 +- .../entry-corejs3-runtime-only/stdout.txt | 2 +- .../stdout.txt | 2 +- .../entry-corejs3-specific-entries/stdout.txt | 2 +- .../entry-corejs3-stable-chrome-71/stdout.txt | 2 +- .../entry-corejs3-stable-samsung-8.2/stdout.txt | 2 +- .../debug-babel-7/entry-corejs3-stable/stdout.txt | 2 +- .../entry-corejs3-stage-chrome-71/stdout.txt | 2 +- .../debug-babel-7/entry-corejs3-stage/stdout.txt | 2 +- .../entry-corejs3-web-chrome-71/stdout.txt | 2 +- .../debug-babel-7/entry-corejs3-web/stdout.txt | 2 +- .../entry-no-corejs-shippedProposals/stdout.txt | 2 +- .../shippedProposals-chrome-80/stdout.txt | 2 +- .../shippedProposals-chrome-84/stdout.txt | 2 +- .../usage-corejs2-shippedProposals-1/stdout.txt | 2 +- .../usage-corejs2-shippedProposals-2/stdout.txt | 2 +- .../usage-corejs3-shippedProposals-1/stdout.txt | 2 +- .../usage-corejs3-shippedProposals-2/stdout.txt | 2 +- .../stdout.txt | 2 +- .../debug/entry-corejs2-shippedProposals/stdout.txt | 2 +- .../debug/entry-corejs3-all-chrome-71/stdout.txt | 2 +- .../fixtures/debug/entry-corejs3-all/stdout.txt | 2 +- .../debug/entry-corejs3-babel-polyfill/stdout.txt | 2 +- .../debug/entry-corejs3-es-chrome-71/stdout.txt | 2 +- .../entry-corejs3-es-proposals-chrome-71/stdout.txt | 2 +- .../debug/entry-corejs3-es-proposals/stdout.txt | 2 +- .../test/fixtures/debug/entry-corejs3-es/stdout.txt | 2 +- .../entry-corejs3-runtime-only-chrome-71/stdout.txt | 2 +- .../debug/entry-corejs3-runtime-only/stdout.txt | 2 +- .../stdout.txt | 2 +- .../debug/entry-corejs3-specific-entries/stdout.txt | 2 +- .../debug/entry-corejs3-stable-chrome-71/stdout.txt | 2 +- .../entry-corejs3-stable-samsung-8.2/stdout.txt | 2 +- .../fixtures/debug/entry-corejs3-stable/stdout.txt | 2 +- .../debug/entry-corejs3-stage-chrome-71/stdout.txt | 2 +- .../fixtures/debug/entry-corejs3-stage/stdout.txt | 2 +- .../debug/entry-corejs3-web-chrome-71/stdout.txt | 2 +- .../fixtures/debug/entry-corejs3-web/stdout.txt | 2 +- .../entry-no-corejs-shippedProposals/stdout.txt | 2 +- .../debug/shippedProposals-chrome-80/stdout.txt | 2 +- .../debug/shippedProposals-chrome-84/stdout.txt | 2 +- .../usage-corejs2-shippedProposals-1/stdout.txt | 2 +- .../usage-corejs2-shippedProposals-2/stdout.txt | 2 +- .../usage-corejs3-shippedProposals-1/stdout.txt | 2 +- .../usage-corejs3-shippedProposals-2/stdout.txt | 2 +- packages/babel-standalone/package.json | 1 + packages/babel-standalone/scripts/pluginConfig.json | 1 + packages/babel-standalone/src/generated/plugins.ts | 3 +++ yarn.lock | 13 +++++++++++++ 64 files changed, 92 insertions(+), 57 deletions(-) diff --git a/packages/babel-plugin-syntax-import-attributes/src/index.ts b/packages/babel-plugin-syntax-import-attributes/src/index.ts index fb563ad3c7c1..ccbac35f776a 100644 --- a/packages/babel-plugin-syntax-import-attributes/src/index.ts +++ b/packages/babel-plugin-syntax-import-attributes/src/index.ts @@ -1,6 +1,6 @@ import { declare } from "@babel/helper-plugin-utils"; -interface Options { +export interface Options { deprecatedAssertSyntax?: boolean; } diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index f106ed0949dc..3756c217313c 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -43,6 +43,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/plugin-syntax-export-namespace-from": "^7.8.3", "@babel/plugin-syntax-import-assertions": "workspace:^", + "@babel/plugin-syntax-import-attributes": "workspace:^", "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-syntax-json-strings": "^7.8.3", "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", diff --git a/packages/babel-preset-env/src/available-plugins.ts b/packages/babel-preset-env/src/available-plugins.ts index ffe3e4db68a6..de40af9f27a0 100644 --- a/packages/babel-preset-env/src/available-plugins.ts +++ b/packages/babel-preset-env/src/available-plugins.ts @@ -6,6 +6,7 @@ import syntaxClassStaticBlock from "@babel/plugin-syntax-class-static-block"; import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import"; import syntaxExportNamespaceFrom from "@babel/plugin-syntax-export-namespace-from"; import syntaxImportAssertions from "@babel/plugin-syntax-import-assertions"; +import syntaxImportAttributes from "@babel/plugin-syntax-import-attributes"; import syntaxImportMeta from "@babel/plugin-syntax-import-meta"; import syntaxJsonStrings from "@babel/plugin-syntax-json-strings"; import syntaxLogicalAssignmentOperators from "@babel/plugin-syntax-logical-assignment-operators"; @@ -90,6 +91,7 @@ export default { "syntax-dynamic-import": () => syntaxDynamicImport, "syntax-export-namespace-from": () => syntaxExportNamespaceFrom, "syntax-import-assertions": () => syntaxImportAssertions, + "syntax-import-attributes": () => syntaxImportAttributes, "syntax-import-meta": () => syntaxImportMeta, "syntax-json-strings": () => syntaxJsonStrings, "syntax-logical-assignment-operators": () => syntaxLogicalAssignmentOperators, @@ -156,6 +158,7 @@ export default { export const minVersions = { "bugfix/transform-safari-id-destructuring-collision-in-function-expression": "7.16.0", + "syntax-import-attributes": "7.21.0", "transform-class-static-block": "7.12.0", "transform-private-property-in-object": "7.10.0", }; diff --git a/packages/babel-preset-env/src/index.ts b/packages/babel-preset-env/src/index.ts index f1bfa788a6d7..1e39e16cb697 100644 --- a/packages/babel-preset-env/src/index.ts +++ b/packages/babel-preset-env/src/index.ts @@ -392,11 +392,11 @@ option \`forceAllTransforms: true\` instead. getOptionSpecificExcludesFor({ loose }), pluginSyntaxMap, ); - removeUnnecessaryItems(pluginNames, overlappingPlugins); removeUnsupportedItems(pluginNames, api.version); if (shippedProposals) { addProposalSyntaxPlugins(pluginNames, proposalSyntaxPlugins); } + removeUnnecessaryItems(pluginNames, overlappingPlugins); const polyfillPlugins = getPolyfillPlugins({ useBuiltIns, @@ -427,6 +427,12 @@ option \`forceAllTransforms: true\` instead. }, ]; } + if (pluginName === "syntax-import-attributes") { + // For backward compatibility with the import-assertions plugin, we + // allow the deprecated `assert` keyword. + // TODO(Babel 8): Revisit this. + return [getPlugin(pluginName), { deprecatedAssertSyntax: true }]; + } return [ getPlugin(pluginName), { spec, loose, useBuiltIns: pluginUseBuiltIns }, diff --git a/packages/babel-preset-env/src/plugins-compat-data.ts b/packages/babel-preset-env/src/plugins-compat-data.ts index 40d16f0f8de9..1a40f5f07b76 100644 --- a/packages/babel-preset-env/src/plugins-compat-data.ts +++ b/packages/babel-preset-env/src/plugins-compat-data.ts @@ -9,6 +9,10 @@ export const plugins = filterAvailable(originalPlugins); export const pluginsBugfixes = filterAvailable(originalPluginsBugfixes); export const overlappingPlugins = filterAvailable(originalOverlappingPlugins); +// @ts-expect-error: we extend this here, since it's a syntax plugin and thus +// doesn't make sense to store it in a compat-data package. +overlappingPlugins["syntax-import-attributes"] = ["syntax-import-assertions"]; + function filterAvailable( data: Data, ): { [Name in keyof Data & keyof typeof availablePlugins]: Data[Name] } { diff --git a/packages/babel-preset-env/src/shipped-proposals.ts b/packages/babel-preset-env/src/shipped-proposals.ts index 504db4060289..9f2df21cca1a 100644 --- a/packages/babel-preset-env/src/shipped-proposals.ts +++ b/packages/babel-preset-env/src/shipped-proposals.ts @@ -7,7 +7,10 @@ const proposalPlugins = new Set(); // proposal syntax plugins enabled by the `shippedProposals` option. // Unlike proposalPlugins above, they are independent of compiler targets. -const proposalSyntaxPlugins = ["syntax-import-assertions"] as const; +const proposalSyntaxPlugins = [ + "syntax-import-assertions", + "syntax-import-attributes", +] as const; // use intermediary object to enforce alphabetical key order const pluginSyntaxObject = { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals-chrome-71/stdout.txt index ef0b1a95bcb8..fdf06324f9d3 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals/stdout.txt index 37e68ced83ab..0339e8a6f771 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs2-shippedProposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all-chrome-71/stdout.txt index 4b096af4f8df..b7de1c0c63b0 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all/stdout.txt index c49867769876..fb2045bfb65a 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-all/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-babel-polyfill/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-babel-polyfill/stdout.txt index 807a771ea653..2a7dea3cea65 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-babel-polyfill/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-babel-polyfill/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-chrome-71/stdout.txt index a25a2f8d6dd0..bed0580b3406 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals-chrome-71/stdout.txt index c602fc2d02a1..5546f36cc4f2 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals/stdout.txt index 4a63d697a001..8278ff217aa4 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es-proposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es/stdout.txt index f551abcd58a8..1a515ce1dc66 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-es/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only-chrome-71/stdout.txt index 545d5d134787..9a58c0301414 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only/stdout.txt index fef19750d8fb..0482acd59246 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-runtime-only/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries-chrome-71/stdout.txt index 16a222809803..5acce9cfa67d 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries/stdout.txt index 59bdde15376e..47913e026b5a 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-specific-entries/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-chrome-71/stdout.txt index f540dc5e7872..72c7491a9ed4 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-samsung-8.2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-samsung-8.2/stdout.txt index 827522296ded..5d73da5c01af 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-samsung-8.2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable-samsung-8.2/stdout.txt @@ -26,7 +26,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable/stdout.txt index 3d33157fad69..999e4fe90c10 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stable/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage-chrome-71/stdout.txt index a106fbcde82d..6fa578a0a70d 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage/stdout.txt index 94320e9ae9d4..992a9697e75c 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-stage/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web-chrome-71/stdout.txt index 69394e51f61d..7249c5ae30e1 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web/stdout.txt index 5edc4432aa10..80c96ef439e6 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-corejs3-web/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-no-corejs-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-no-corejs-shippedProposals/stdout.txt index 52103c9d7e8a..bb64d8632690 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-no-corejs-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/entry-no-corejs-shippedProposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-80/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-80/stdout.txt index 279d9c080ffd..d5e00d41d51e 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-80/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-80/stdout.txt @@ -24,6 +24,6 @@ Using plugins: transform-dynamic-import transform-export-namespace-from { } syntax-import-meta - syntax-import-assertions + syntax-import-attributes Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set. diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-84/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-84/stdout.txt index 4fefb21a42dc..e246ec862a45 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-84/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/shippedProposals-chrome-84/stdout.txt @@ -23,6 +23,6 @@ Using plugins: transform-dynamic-import transform-export-namespace-from { } syntax-import-meta - syntax-import-assertions + syntax-import-attributes Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set. diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-1/stdout.txt index bc4189b903fe..6d66feaab8db 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-1/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-2/stdout.txt index 883f5b3d5f4d..935ffc546980 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs2-shippedProposals-2/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-1/stdout.txt index 1f65273fe95a..d02c15a9c3b9 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-1/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-2/stdout.txt index 142423001863..4ec223f1faa8 100644 --- a/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug-babel-7/usage-corejs3-shippedProposals-2/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/stdout.txt index faadf83e0795..aa3ca867729b 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt index d8d3f2373202..680bbcba1cfb 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all-chrome-71/stdout.txt index 6b47aab75244..c8a58466143f 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt index 9cfc9ae7961b..09b3228a238d 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt index a2ec90a9e866..0d9771f98e2b 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-chrome-71/stdout.txt index 9f9ff1ac6396..b0e4377ff727 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals-chrome-71/stdout.txt index 261b6acb38d4..fc3732d5b58a 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt index 315879505d76..d9b0b9a4a814 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt index 1536870027f9..71a6973a0bc0 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only-chrome-71/stdout.txt index bcd3ffd33efe..e18e23da3ae9 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only/stdout.txt index 7fd65d97774c..078c77261b43 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-runtime-only/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries-chrome-71/stdout.txt index 327e110e2844..778d972fb08a 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt index 3fa4327e160a..16c3841a5115 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-chrome-71/stdout.txt index df275307dd7d..db6a7c5ed4b0 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-samsung-8.2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-samsung-8.2/stdout.txt index a02de20aa5f7..a2e5c139dd44 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-samsung-8.2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable-samsung-8.2/stdout.txt @@ -26,7 +26,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt index e816fef524cf..c166e6b66f32 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage-chrome-71/stdout.txt index 5a5804d053ee..382e56765274 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt index 88ad9309a88d..6d23754b1b51 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web-chrome-71/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web-chrome-71/stdout.txt index 9cdf52cacea1..426d86202d56 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web-chrome-71/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web-chrome-71/stdout.txt @@ -24,7 +24,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt index c094d38007d1..608ffb7d661f 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt index 25589909f5fb..dc48947bc755 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt @@ -53,7 +53,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-80/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-80/stdout.txt index bedcedd8d751..39d7ba3cef14 100644 --- a/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-80/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-80/stdout.txt @@ -25,6 +25,6 @@ Using plugins: transform-dynamic-import transform-export-namespace-from { } syntax-import-meta - syntax-import-assertions + syntax-import-attributes Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set. diff --git a/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-84/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-84/stdout.txt index a15f6006d6cd..6c7351185283 100644 --- a/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-84/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/shippedProposals-chrome-84/stdout.txt @@ -24,6 +24,6 @@ Using plugins: transform-dynamic-import transform-export-namespace-from { } syntax-import-meta - syntax-import-assertions + syntax-import-attributes Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set. diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt index 1b7ae3729a83..48311c961e28 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt index 8cb6fc429942..fee517bb22f9 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs2: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt index 8b0050dc136a..56309708c91e 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt index 74296b1c6617..4be6d1d9fe23 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt @@ -51,7 +51,7 @@ Using plugins: transform-modules-commonjs transform-dynamic-import syntax-import-meta - syntax-import-assertions + syntax-import-attributes corejs3: `DEBUG` option Using targets: { diff --git a/packages/babel-standalone/package.json b/packages/babel-standalone/package.json index 2e9ae54db80a..14d15fac6ffe 100644 --- a/packages/babel-standalone/package.json +++ b/packages/babel-standalone/package.json @@ -49,6 +49,7 @@ "@babel/plugin-syntax-function-bind": "workspace:^", "@babel/plugin-syntax-function-sent": "workspace:^", "@babel/plugin-syntax-import-assertions": "workspace:^", + "@babel/plugin-syntax-import-attributes": "workspace:^", "@babel/plugin-syntax-import-reflection": "workspace:^", "@babel/plugin-syntax-jsx": "workspace:^", "@babel/plugin-syntax-module-blocks": "workspace:^", diff --git a/packages/babel-standalone/scripts/pluginConfig.json b/packages/babel-standalone/scripts/pluginConfig.json index 815d03edd31c..07dd2ed7862c 100644 --- a/packages/babel-standalone/scripts/pluginConfig.json +++ b/packages/babel-standalone/scripts/pluginConfig.json @@ -30,6 +30,7 @@ "syntax-function-bind", "syntax-function-sent", "syntax-import-assertions", + "syntax-import-attributes", "syntax-import-reflection", "syntax-module-blocks", "syntax-jsx", diff --git a/packages/babel-standalone/src/generated/plugins.ts b/packages/babel-standalone/src/generated/plugins.ts index 285f8946c40c..58c7810405c4 100644 --- a/packages/babel-standalone/src/generated/plugins.ts +++ b/packages/babel-standalone/src/generated/plugins.ts @@ -14,6 +14,7 @@ import syntaxFlow from "@babel/plugin-syntax-flow"; import syntaxFunctionBind from "@babel/plugin-syntax-function-bind"; import syntaxFunctionSent from "@babel/plugin-syntax-function-sent"; import syntaxImportAssertions from "@babel/plugin-syntax-import-assertions"; +import syntaxImportAttributes from "@babel/plugin-syntax-import-attributes"; import syntaxImportReflection from "@babel/plugin-syntax-import-reflection"; import syntaxModuleBlocks from "@babel/plugin-syntax-module-blocks"; import syntaxJsx from "@babel/plugin-syntax-jsx"; @@ -117,6 +118,7 @@ export { syntaxFunctionBind, syntaxFunctionSent, syntaxImportAssertions, + syntaxImportAttributes, syntaxImportReflection, syntaxModuleBlocks, syntaxJsx, @@ -221,6 +223,7 @@ export const all: { [k: string]: any } = { "syntax-function-bind": syntaxFunctionBind, "syntax-function-sent": syntaxFunctionSent, "syntax-import-assertions": syntaxImportAssertions, + "syntax-import-attributes": syntaxImportAttributes, "syntax-import-reflection": syntaxImportReflection, "syntax-module-blocks": syntaxModuleBlocks, "syntax-jsx": syntaxJsx, diff --git a/yarn.lock b/yarn.lock index 74721454ca85..0ba60a2812dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2017,6 +2017,17 @@ __metadata: languageName: unknown linkType: soft +"@babel/plugin-syntax-import-attributes@workspace:^, @babel/plugin-syntax-import-attributes@workspace:packages/babel-plugin-syntax-import-attributes": + version: 0.0.0-use.local + resolution: "@babel/plugin-syntax-import-attributes@workspace:packages/babel-plugin-syntax-import-attributes" + dependencies: + "@babel/core": "workspace:^" + "@babel/helper-plugin-utils": "workspace:^" + peerDependencies: + "@babel/core": ^7.0.0-0 + languageName: unknown + linkType: soft + "@babel/plugin-syntax-import-meta@npm:^7.10.4, @babel/plugin-syntax-import-meta@npm:^7.8.3": version: 7.10.4 resolution: "@babel/plugin-syntax-import-meta@npm:7.10.4" @@ -3474,6 +3485,7 @@ __metadata: "@babel/plugin-syntax-dynamic-import": ^7.8.3 "@babel/plugin-syntax-export-namespace-from": ^7.8.3 "@babel/plugin-syntax-import-assertions": "workspace:^" + "@babel/plugin-syntax-import-attributes": "workspace:^" "@babel/plugin-syntax-import-meta": ^7.10.4 "@babel/plugin-syntax-json-strings": ^7.8.3 "@babel/plugin-syntax-logical-assignment-operators": ^7.10.4 @@ -3707,6 +3719,7 @@ __metadata: "@babel/plugin-syntax-function-bind": "workspace:^" "@babel/plugin-syntax-function-sent": "workspace:^" "@babel/plugin-syntax-import-assertions": "workspace:^" + "@babel/plugin-syntax-import-attributes": "workspace:^" "@babel/plugin-syntax-import-reflection": "workspace:^" "@babel/plugin-syntax-jsx": "workspace:^" "@babel/plugin-syntax-module-blocks": "workspace:^" From 004dcb09c7acfaea3d48e4394bd3646690cb641f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Mar 2023 19:26:55 +0200 Subject: [PATCH 07/17] new-version-checklist --- Makefile.js | 2 +- Makefile.source.mjs | 8 +++++--- .../babel-plugin-syntax-import-attributes/src/index.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile.js b/Makefile.js index 60ac2b5c9fe6..89930e4e1143 100644 --- a/Makefile.js +++ b/Makefile.js @@ -1,3 +1,3 @@ /* eslint-disable */ // prettier-ignore -"use strict";var e=require("os"),t=require("fs"),r=require("path"),n=require("events"),i=require("assert"),o=require("util"),s=require("child_process");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),u=c(t),l=c(r),f=c(n),p=c(i),h=c(o),d=c(s),v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y=function(e){return e&&e.Math==Math&&e},m=y("object"==typeof globalThis&&globalThis)||y("object"==typeof window&&window)||y("object"==typeof self&&self)||y("object"==typeof v&&v)||function(){return this}()||Function("return this")(),E={},b=function(e){try{return!!e()}catch(e){return!0}},w=!b((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),O=!b((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),S=O,R=Function.prototype.call,I=S?R.bind(R):function(){return R.apply(R,arguments)},A={},j={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,k=x&&!j.call({1:2},1);A.f=k?function(e){var t=x(this,e);return!!t&&t.enumerable}:j;var L,_,T=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},N=O,P=Function.prototype,F=P.call,D=N&&P.bind.bind(F,F),C=N?D:function(e){return function(){return F.apply(e,arguments)}},M=C,G=M({}.toString),$=M("".slice),U=function(e){return $(G(e),8,-1)},B=U,X=C,q=function(e){if("Function"===B(e))return X(e)},W=b,V=U,H=Object,z=q("".split),Y=W((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?z(e,""):H(e)}:H,K=function(e){return null==e},J=K,Q=TypeError,Z=function(e){if(J(e))throw Q("Can't call method on "+e);return e},ee=Y,te=Z,re=function(e){return ee(te(e))},ne="object"==typeof document&&document.all,ie={all:ne,IS_HTMLDDA:void 0===ne&&void 0!==ne},oe=ie.all,se=ie.IS_HTMLDDA?function(e){return"function"==typeof e||e===oe}:function(e){return"function"==typeof e},ce=se,ae=ie.all,ue=ie.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ce(e)||e===ae}:function(e){return"object"==typeof e?null!==e:ce(e)},le=m,fe=se,pe=function(e){return fe(e)?e:void 0},he=function(e,t){return arguments.length<2?pe(le[e]):le[e]&&le[e][t]},de=q({}.isPrototypeOf),ve=he("navigator","userAgent")||"",ge=m,ye=ve,me=ge.process,Ee=ge.Deno,be=me&&me.versions||Ee&&Ee.version,we=be&&be.v8;we&&(_=(L=we.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!_&&ye&&(!(L=ye.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ye.match(/Chrome\/(\d+)/))&&(_=+L[1]);var Oe=_,Se=Oe,Re=b,Ie=!!Object.getOwnPropertySymbols&&!Re((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Se&&Se<41})),Ae=Ie&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,je=he,xe=se,ke=de,Le=Object,_e=Ae?function(e){return"symbol"==typeof e}:function(e){var t=je("Symbol");return xe(t)&&ke(t.prototype,Le(e))},Te=String,Ne=function(e){try{return Te(e)}catch(e){return"Object"}},Pe=se,Fe=Ne,De=TypeError,Ce=function(e){if(Pe(e))return e;throw De(Fe(e)+" is not a function")},Me=Ce,Ge=K,$e=function(e,t){var r=e[t];return Ge(r)?void 0:Me(r)},Ue=I,Be=se,Xe=ue,qe=TypeError,We={exports:{}},Ve=m,He=Object.defineProperty,ze=function(e,t){try{He(Ve,e,{value:t,configurable:!0,writable:!0})}catch(r){Ve[e]=t}return t},Ye=ze,Ke=m["__core-js_shared__"]||Ye("__core-js_shared__",{}),Je=Ke;(We.exports=function(e,t){return Je[e]||(Je[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Qe=We.exports,Ze=Z,et=Object,tt=function(e){return et(Ze(e))},rt=tt,nt=q({}.hasOwnProperty),it=Object.hasOwn||function(e,t){return nt(rt(e),t)},ot=q,st=0,ct=Math.random(),at=ot(1..toString),ut=function(e){return"Symbol("+(void 0===e?"":e)+")_"+at(++st+ct,36)},lt=m,ft=it,pt=ut,ht=Ie,dt=Ae,vt=Qe("wks"),gt=lt.Symbol,yt=gt&>.for,mt=dt?gt:gt&>.withoutSetter||pt,Et=function(e){if(!ft(vt,e)||!ht&&"string"!=typeof vt[e]){var t="Symbol."+e;ht&&ft(gt,e)?vt[e]=gt[e]:vt[e]=dt&&yt?yt(t):mt(t)}return vt[e]},bt=I,wt=ue,Ot=_e,St=$e,Rt=function(e,t){var r,n;if("string"===t&&Be(r=e.toString)&&!Xe(n=Ue(r,e)))return n;if(Be(r=e.valueOf)&&!Xe(n=Ue(r,e)))return n;if("string"!==t&&Be(r=e.toString)&&!Xe(n=Ue(r,e)))return n;throw qe("Can't convert object to primitive value")},It=TypeError,At=Et("toPrimitive"),jt=function(e,t){if(!wt(e)||Ot(e))return e;var r,n=St(e,At);if(n){if(void 0===t&&(t="default"),r=bt(n,e,t),!wt(r)||Ot(r))return r;throw It("Can't convert object to primitive value")}return void 0===t&&(t="number"),Rt(e,t)},xt=_e,kt=function(e){var t=jt(e,"string");return xt(t)?t:t+""},Lt=ue,_t=m.document,Tt=Lt(_t)&&Lt(_t.createElement),Nt=function(e){return Tt?_t.createElement(e):{}},Pt=Nt,Ft=!w&&!b((function(){return 7!=Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a})),Dt=w,Ct=I,Mt=A,Gt=T,$t=re,Ut=kt,Bt=it,Xt=Ft,qt=Object.getOwnPropertyDescriptor;E.f=Dt?qt:function(e,t){if(e=$t(e),t=Ut(t),Xt)try{return qt(e,t)}catch(e){}if(Bt(e,t))return Gt(!Ct(Mt.f,e,t),e[t])};var Wt={},Vt=w&&b((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Ht=ue,zt=String,Yt=TypeError,Kt=function(e){if(Ht(e))return e;throw Yt(zt(e)+" is not an object")},Jt=w,Qt=Ft,Zt=Vt,er=Kt,tr=kt,rr=TypeError,nr=Object.defineProperty,ir=Object.getOwnPropertyDescriptor;Wt.f=Jt?Zt?function(e,t,r){if(er(e),t=tr(t),er(r),"function"==typeof e&&"prototype"===t&&"value"in r&&"writable"in r&&!r.writable){var n=ir(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:"configurable"in r?r.configurable:n.configurable,enumerable:"enumerable"in r?r.enumerable:n.enumerable,writable:!1})}return nr(e,t,r)}:nr:function(e,t,r){if(er(e),t=tr(t),er(r),Qt)try{return nr(e,t,r)}catch(e){}if("get"in r||"set"in r)throw rr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var or=Wt,sr=T,cr=w?function(e,t,r){return or.f(e,t,sr(1,r))}:function(e,t,r){return e[t]=r,e},ar={exports:{}},ur=w,lr=it,fr=Function.prototype,pr=ur&&Object.getOwnPropertyDescriptor,hr=lr(fr,"name"),dr={EXISTS:hr,PROPER:hr&&"something"===function(){}.name,CONFIGURABLE:hr&&(!ur||ur&&pr(fr,"name").configurable)},vr=se,gr=Ke,yr=q(Function.toString);vr(gr.inspectSource)||(gr.inspectSource=function(e){return yr(e)});var mr,Er,br,wr=gr.inspectSource,Or=se,Sr=m.WeakMap,Rr=Or(Sr)&&/native code/.test(String(Sr)),Ir=ut,Ar=Qe("keys"),jr=function(e){return Ar[e]||(Ar[e]=Ir(e))},xr={},kr=Rr,Lr=m,_r=ue,Tr=cr,Nr=it,Pr=Ke,Fr=jr,Dr=xr,Cr=Lr.TypeError,Mr=Lr.WeakMap;if(kr||Pr.state){var Gr=Pr.state||(Pr.state=new Mr);Gr.get=Gr.get,Gr.has=Gr.has,Gr.set=Gr.set,mr=function(e,t){if(Gr.has(e))throw Cr("Object already initialized");return t.facade=e,Gr.set(e,t),t},Er=function(e){return Gr.get(e)||{}},br=function(e){return Gr.has(e)}}else{var $r=Fr("state");Dr[$r]=!0,mr=function(e,t){if(Nr(e,$r))throw Cr("Object already initialized");return t.facade=e,Tr(e,$r,t),t},Er=function(e){return Nr(e,$r)?e[$r]:{}},br=function(e){return Nr(e,$r)}}var Ur={set:mr,get:Er,has:br,enforce:function(e){return br(e)?Er(e):mr(e,{})},getterFor:function(e){return function(t){var r;if(!_r(t)||(r=Er(t)).type!==e)throw Cr("Incompatible receiver, "+e+" required");return r}}},Br=b,Xr=se,qr=it,Wr=w,Vr=dr.CONFIGURABLE,Hr=wr,zr=Ur.enforce,Yr=Ur.get,Kr=Object.defineProperty,Jr=Wr&&!Br((function(){return 8!==Kr((function(){}),"length",{value:8}).length})),Qr=String(String).split("String"),Zr=ar.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!qr(e,"name")||Vr&&e.name!==t)&&(Wr?Kr(e,"name",{value:t,configurable:!0}):e.name=t),Jr&&r&&qr(r,"arity")&&e.length!==r.arity&&Kr(e,"length",{value:r.arity});try{r&&qr(r,"constructor")&&r.constructor?Wr&&Kr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=zr(e);return qr(n,"source")||(n.source=Qr.join("string"==typeof t?t:"")),e};Function.prototype.toString=Zr((function(){return Xr(this)&&Yr(this).source||Hr(this)}),"toString");var en=ar.exports,tn=se,rn=Wt,nn=en,on=ze,sn=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(tn(r)&&nn(r,o,n),n.global)i?e[t]=r:on(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=r:rn.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},cn={},an=Math.ceil,un=Math.floor,ln=Math.trunc||function(e){var t=+e;return(t>0?un:an)(t)},fn=function(e){var t=+e;return t!=t||0===t?0:ln(t)},pn=fn,hn=Math.max,dn=Math.min,vn=function(e,t){var r=pn(e);return r<0?hn(r+t,0):dn(r,t)},gn=fn,yn=Math.min,mn=function(e){return e>0?yn(gn(e),9007199254740991):0},En=mn,bn=function(e){return En(e.length)},wn=re,On=vn,Sn=bn,Rn=function(e){return function(t,r,n){var i,o=wn(t),s=Sn(o),c=On(n,s);if(e&&r!=r){for(;s>c;)if((i=o[c++])!=i)return!0}else for(;s>c;c++)if((e||c in o)&&o[c]===r)return e||c||0;return!e&&-1}},In={includes:Rn(!0),indexOf:Rn(!1)},An=it,jn=re,xn=In.indexOf,kn=xr,Ln=q([].push),_n=function(e,t){var r,n=jn(e),i=0,o=[];for(r in n)!An(kn,r)&&An(n,r)&&Ln(o,r);for(;t.length>i;)An(n,r=t[i++])&&(~xn(o,r)||Ln(o,r));return o},Tn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Nn=_n,Pn=Tn.concat("length","prototype");cn.f=Object.getOwnPropertyNames||function(e){return Nn(e,Pn)};var Fn={};Fn.f=Object.getOwnPropertySymbols;var Dn=he,Cn=cn,Mn=Fn,Gn=Kt,$n=q([].concat),Un=Dn("Reflect","ownKeys")||function(e){var t=Cn.f(Gn(e)),r=Mn.f;return r?$n(t,r(e)):t},Bn=it,Xn=Un,qn=E,Wn=Wt,Vn=function(e,t,r){for(var n=Xn(t),i=Wn.f,o=qn.f,s=0;ss;)Oi.f(e,r=i[s++],n[r]);return e};var Ai,ji=he("document","documentElement"),xi=Kt,ki=gi,Li=Tn,_i=xr,Ti=ji,Ni=Nt,Pi=jr("IE_PROTO"),Fi=function(){},Di=function(e){return"