Support import defer and import source in meriyah (#19721)
This commit is contained in:
1 parent
2c700bc611
commit
9df49a5516
18 files changed
+55
-160
No files matched your search
@@ -58,10 +58,7 @@ const disabledTests = new Map(
|
||||
acorn: [
|
||||
"js/explicit-resource-management/valid-await-using-asi-assignment.js",
|
||||
],
|
||||
meriyah: [
|
||||
// Parsing to different ASTs
|
||||
"js/decorators/member-expression.js",
|
||||
],
|
||||
meriyah: [],
|
||||
"babel-ts": [
|
||||
"typescript/conformance/types/moduleDeclaration/kind-detection.ts",
|
||||
// https://github.com/babel/babel/pull/17659
|
||||
|
||||
@@ -119,6 +119,13 @@ function installPrettier(packageDirectory) {
|
||||
runNpmClient(["install", packed, "--engine-strict"]);
|
||||
break;
|
||||
case "pnpm":
|
||||
runNpmClient([
|
||||
"config",
|
||||
"set",
|
||||
"blockExoticSubdeps",
|
||||
"false",
|
||||
"--location=project",
|
||||
]);
|
||||
// fails engine mismatch
|
||||
runNpmClient(["add", packed, "--engine-strict"]);
|
||||
break;
|
||||
|
||||
+8
-8
@@ -51,11 +51,11 @@ import defer x from "x";
|
||||
`;
|
||||
|
||||
exports[`no-default.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
"'import defer' must be followed by a namespace import (1:14)
|
||||
> 1 | import defer x from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import"
|
||||
`;
|
||||
|
||||
exports[`no-default.js format[oxc] 1`] = `
|
||||
@@ -145,11 +145,11 @@ import defer { x } from "x";
|
||||
`;
|
||||
|
||||
exports[`no-named.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
"'import defer' must be followed by a namespace import (1:14)
|
||||
> 1 | import defer { x } from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import"
|
||||
`;
|
||||
|
||||
exports[`no-named.js format[oxc] 1`] = `
|
||||
@@ -233,10 +233,10 @@ import defer { x } from "x";
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
"'import defer' must be followed by a namespace import (1:14)
|
||||
> 1 | import defer { x } from "x";
|
||||
| ^
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import"
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 format[oxc] 1`] = `
|
||||
@@ -315,10 +315,10 @@ import defer x from "x";
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
"'import defer' must be followed by a namespace import (1:14)
|
||||
> 1 | import defer x from "x";
|
||||
| ^
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import"
|
||||
`;
|
||||
|
||||
exports[`snippet: #1 format[oxc] 1`] = `
|
||||
|
||||
@@ -598,14 +598,6 @@ exports[`deferred-import-evaluation.js format[espree] 1`] = `
|
||||
Cause: Unexpected token *"
|
||||
`;
|
||||
|
||||
exports[`deferred-import-evaluation.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
> 1 | import defer * as ns from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`destructuring-private.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
@@ -2481,15 +2473,6 @@ exports[`source-phase-imports.js format[espree] 1`] = `
|
||||
Cause: Unexpected token fooSource"
|
||||
`;
|
||||
|
||||
exports[`source-phase-imports.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
> 1 | import source fooSource from "foo";
|
||||
| ^^^^^^^^^
|
||||
2 | import.source("x");
|
||||
3 |
|
||||
Cause: [1:14-1:23]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`throw-expressions.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "babel-ts", "babel-flow"]
|
||||
|
||||
@@ -67,8 +67,6 @@ runFormatTest(import.meta, ["babel", "babel-ts", "babel-flow"], {
|
||||
"v8intrinsic.js",
|
||||
"module-blocks.js",
|
||||
"async-do-expressions.js",
|
||||
"source-phase-imports.js",
|
||||
"deferred-import-evaluation.js",
|
||||
"optional-chaining-assignment.js",
|
||||
"discard-binding.js",
|
||||
],
|
||||
|
||||
@@ -50,14 +50,6 @@ import.defer("foo");
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`dynamic-import.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.defer("foo");
|
||||
| ^^^^^
|
||||
2 |
|
||||
Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`dynamic-import-attributes-expression.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "typescript", "flow"]
|
||||
@@ -108,14 +100,6 @@ import.defer("x", { with: { attr: "val" } });
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`dynamic-import-attributes-expression.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.defer("x", { with: { attr: "val" } });
|
||||
| ^^^^^
|
||||
2 |
|
||||
Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`import-defer.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "typescript", "flow"]
|
||||
@@ -163,14 +147,6 @@ import defer * as ns from "x";
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`import-defer.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
> 1 | import defer * as ns from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`import-defer-attributes-declaration.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "typescript", "flow"]
|
||||
@@ -217,11 +193,3 @@ Cause: 'from' expected (1:13)
|
||||
import defer * as ns from "x" with { attr: "val" };
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`import-defer-attributes-declaration.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:14)
|
||||
> 1 | import defer * as ns from "x" with { attr: "val" };
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:13-1:14]: Expected 'from'"
|
||||
`;
|
||||
@@ -9,7 +9,6 @@ runFormatTest(import.meta, ["babel", "typescript", "flow"], {
|
||||
errors: {
|
||||
acorn: importDeferTests,
|
||||
espree: importDeferTests,
|
||||
meriyah: importDeferTests,
|
||||
flow: importDeferTests,
|
||||
hermes: importDeferTests,
|
||||
},
|
||||
|
||||
@@ -83,16 +83,6 @@ import.source(\`data:text/javascript,
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`import-phase.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.source(\`data:text/javascript,
|
||||
| ^^^^^^
|
||||
2 | console.log("RUN");
|
||||
3 | \`)
|
||||
4 |
|
||||
Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`template-literal.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
|
||||
@@ -4,6 +4,5 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], {
|
||||
hermes: ["template-literal.js", "import-phase.js"],
|
||||
acorn: ["import-phase.js"],
|
||||
espree: ["import-phase.js"],
|
||||
meriyah: ["import-phase.js"],
|
||||
},
|
||||
});
|
||||
@@ -66,16 +66,6 @@ import.defer("./a/long/long/long/long/long/long/long/long/long/long/long/long/pa
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`import-defer.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.defer("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
||||
| ^^^^^
|
||||
2 | import.defer(
|
||||
3 | // Comment
|
||||
4 | "./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module"
|
||||
Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`import-expression.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
@@ -165,13 +155,3 @@ note: start of member expression (1:0)
|
||||
import.source("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
||||
^"
|
||||
`;
|
||||
|
||||
exports[`import-source.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.source("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
||||
| ^^^^^^
|
||||
2 | import.source(
|
||||
3 | // Comment
|
||||
4 | "./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module"
|
||||
Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
@@ -2,7 +2,6 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], {
|
||||
errors: {
|
||||
acorn: ["import-defer.js", "import-source.js"],
|
||||
espree: ["import-defer.js", "import-source.js"],
|
||||
meriyah: ["import-defer.js", "import-source.js"],
|
||||
flow: ["import-defer.js", "import-source.js"],
|
||||
hermes: ["import-defer.js", "import-source.js"],
|
||||
},
|
||||
|
||||
@@ -42,14 +42,6 @@ exports[`import-source.js format[espree] 1`] = `
|
||||
Cause: Unexpected token x"
|
||||
`;
|
||||
|
||||
exports[`import-source.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
> 1 | import source x from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:14-1:15]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`import-source-attributes-declaration.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
@@ -79,14 +71,6 @@ exports[`import-source-attributes-declaration.js format[espree] 1`] = `
|
||||
Cause: Unexpected token s"
|
||||
`;
|
||||
|
||||
exports[`import-source-attributes-declaration.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
> 1 | import source s from "x" with { attr: "val" };
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:14-1:15]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`import-source-attributes-expression.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
@@ -116,14 +100,6 @@ exports[`import-source-attributes-expression.js format[espree] 1`] = `
|
||||
Cause: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`import-source-attributes-expression.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.source("x", { with: { attr: "val" } });
|
||||
| ^^^^^^
|
||||
2 |
|
||||
Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`import-source-binding-from.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
@@ -153,14 +129,6 @@ exports[`import-source-binding-from.js format[espree] 1`] = `
|
||||
Cause: Unexpected token from"
|
||||
`;
|
||||
|
||||
exports[`import-source-binding-from.js format[meriyah] 1`] = `
|
||||
"Import source must be string (1:20)
|
||||
> 1 | import source from from "x";
|
||||
| ^^^^
|
||||
2 |
|
||||
Cause: [1:19-1:23]: Import source must be string"
|
||||
`;
|
||||
|
||||
exports[`import-source-binding-source.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
@@ -190,14 +158,6 @@ exports[`import-source-binding-source.js format[espree] 1`] = `
|
||||
Cause: Unexpected token source"
|
||||
`;
|
||||
|
||||
exports[`import-source-binding-source.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
> 1 | import source source from "x";
|
||||
| ^^^^^^
|
||||
2 |
|
||||
Cause: [1:14-1:20]: Expected 'from'"
|
||||
`;
|
||||
|
||||
exports[`import-source-dynamic-import.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel"]
|
||||
@@ -227,14 +187,6 @@ exports[`import-source-dynamic-import.js format[espree] 1`] = `
|
||||
Cause: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`import-source-dynamic-import.js format[meriyah] 1`] = `
|
||||
"The only valid meta property for import is 'import.meta' (1:8)
|
||||
> 1 | import.source("foo");
|
||||
| ^^^^^^
|
||||
2 |
|
||||
Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'"
|
||||
`;
|
||||
|
||||
exports[`no-named.js format[__babel_estree] 1`] = `
|
||||
"Only \`import source x from "./module"\` is valid. (1:17)
|
||||
> 1 | import source { x } from "x";
|
||||
@@ -268,11 +220,11 @@ Cause: Unexpected token {"
|
||||
`;
|
||||
|
||||
exports[`no-named.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
"'import source' must be followed by a default import (1:15)
|
||||
> 1 | import source { x } from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:14-1:15]: Expected 'from'"
|
||||
Cause: [1:14-1:15]: 'import source' must be followed by a default import"
|
||||
`;
|
||||
|
||||
exports[`no-named.js format[oxc] 1`] = `
|
||||
@@ -322,11 +274,11 @@ Cause: Unexpected token *"
|
||||
`;
|
||||
|
||||
exports[`no-namespace.js format[meriyah] 1`] = `
|
||||
"Expected 'from' (1:15)
|
||||
"'import source' must be followed by a default import (1:15)
|
||||
> 1 | import source * as x from "x";
|
||||
| ^
|
||||
2 |
|
||||
Cause: [1:14-1:15]: Expected 'from'"
|
||||
Cause: [1:14-1:15]: 'import source' must be followed by a default import"
|
||||
`;
|
||||
|
||||
exports[`no-namespace.js format[oxc] 1`] = `
|
||||
|
||||
@@ -12,7 +12,7 @@ runFormatTest(import.meta, ["babel"], {
|
||||
errors: {
|
||||
acorn: [...importSourceTests, ...invalidSyntaxTests],
|
||||
espree: [...importSourceTests, ...invalidSyntaxTests],
|
||||
meriyah: [...importSourceTests, ...invalidSyntaxTests],
|
||||
meriyah: invalidSyntaxTests,
|
||||
oxc: invalidSyntaxTests,
|
||||
"oxc-ts": invalidSyntaxTests,
|
||||
yuku: invalidSyntaxTests,
|
||||
|
||||
Reference in new issue
Block a user