Skip to content

Commit 0f333da

Browse files
JLHwungnicolo-ribaudoliuxingbaoyu
committed
Add createImportExpressions parser option (#15682)
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev> Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
1 parent b06dab5 commit 0f333da

File tree

260 files changed

+3990
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+3990
-393
lines changed

packages/babel-generator/src/generators/modules.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,15 @@ export function ImportNamespaceSpecifier(
312312
this.space();
313313
this.print(node.local, node);
314314
}
315+
316+
export function ImportExpression(this: Printer, node: t.ImportExpression) {
317+
this.word("import");
318+
this.token("(");
319+
this.print(node.source, node);
320+
if (node.options != null) {
321+
this.token(",");
322+
this.space();
323+
this.print(node.options, node);
324+
}
325+
this.token(")");
326+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*0*/import/*1*/(/*2*/"foo"/*3*/)/*4*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"parserOpts": {
3+
"createImportExpressions": true
4+
}
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*0*/import /*1*/( /*2*/"foo" /*3*/); /*4*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import("module.js");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "parserOpts": { "createImportExpressions": false } }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import("module.js");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "plugins": ["dynamicImport"] }
1+
{ "parserOpts": { "createImportExpressions": true } }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import("foo.json", { with: { type: "json" } });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [["importAttributes", { "importAttributesKeyword": "with" }]],
3+
"sourceType": "module",
4+
"parserOpts": { "createImportExpressions": false }
5+
}

0 commit comments

Comments
 (0)