-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
createImportExpressions
parser option (#15682)
Co-authored-by: Nicolò Ribaudo <[email protected]> Co-authored-by: liuxingbaoyu <[email protected]>
- Loading branch information
1 parent
b06dab5
commit 0f333da
Showing
260 changed files
with
3,990 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/comments/dynamic-import/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*0*/import/*1*/(/*2*/"foo"/*3*/)/*4*/ |
5 changes: 5 additions & 0 deletions
5
packages/babel-generator/test/fixtures/comments/dynamic-import/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"parserOpts": { | ||
"createImportExpressions": true | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/comments/dynamic-import/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*0*/import /*1*/( /*2*/"foo" /*3*/); /*4*/ |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/types/Import-createImportExpression-false/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("module.js"); |
1 change: 1 addition & 0 deletions
1
...ages/babel-generator/test/fixtures/types/Import-createImportExpression-false/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "parserOpts": { "createImportExpressions": false } } |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/types/Import-createImportExpression-false/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("module.js"); |
2 changes: 1 addition & 1 deletion
2
packages/babel-generator/test/fixtures/types/Import/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{ "plugins": ["dynamicImport"] } | ||
{ "parserOpts": { "createImportExpressions": true } } |
1 change: 1 addition & 0 deletions
1
...babel-generator/test/fixtures/types/ImportAttribute-createImportExpression-false/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo.json", { with: { type: "json" } }); |
5 changes: 5 additions & 0 deletions
5
...l-generator/test/fixtures/types/ImportAttribute-createImportExpression-false/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [["importAttributes", { "importAttributesKeyword": "with" }]], | ||
"sourceType": "module", | ||
"parserOpts": { "createImportExpressions": false } | ||
} |
5 changes: 5 additions & 0 deletions
5
...abel-generator/test/fixtures/types/ImportAttribute-createImportExpression-false/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import("foo.json", { | ||
with: { | ||
type: "json" | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/types/ImportAttribute/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("foo.json", { with: { type: "json" } }); |
5 changes: 5 additions & 0 deletions
5
packages/babel-generator/test/fixtures/types/ImportAttribute/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [["importAttributes", { "importAttributesKeyword": "with" }]], | ||
"sourceType": "module", | ||
"parserOpts": { "createImportExpressions": true } | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-generator/test/fixtures/types/ImportAttribute/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import("foo.json", { | ||
with: { | ||
type: "json" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...st/fixtures/es2020/dynamic-import-createImportExpression-false/direct-calls-only/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function failsParse() { | ||
return import.then(); | ||
} |
58 changes: 58 additions & 0 deletions
58
...fixtures/es2020/dynamic-import-createImportExpression-false/direct-calls-only/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":49}}, | ||
"errors": [ | ||
"SyntaxError: The only valid meta property for import is import.meta. (2:16)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":49}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":0,"end":49,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":49}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":9,"end":19,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":19,"index":19},"identifierName":"failsParse"}, | ||
"name": "failsParse" | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":22,"end":49,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":3,"column":1,"index":49}}, | ||
"body": [ | ||
{ | ||
"type": "ReturnStatement", | ||
"start":26,"end":47,"loc":{"start":{"line":2,"column":2,"index":26},"end":{"line":2,"column":23,"index":47}}, | ||
"argument": { | ||
"type": "CallExpression", | ||
"start":33,"end":46,"loc":{"start":{"line":2,"column":9,"index":33},"end":{"line":2,"column":22,"index":46}}, | ||
"callee": { | ||
"type": "MetaProperty", | ||
"start":33,"end":44,"loc":{"start":{"line":2,"column":9,"index":33},"end":{"line":2,"column":20,"index":44}}, | ||
"meta": { | ||
"type": "Identifier", | ||
"start":33,"end":39,"loc":{"start":{"line":2,"column":9,"index":33},"end":{"line":2,"column":15,"index":39},"identifierName":"import"}, | ||
"name": "import" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start":40,"end":44,"loc":{"start":{"line":2,"column":16,"index":40},"end":{"line":2,"column":20,"index":44},"identifierName":"then"}, | ||
"name": "then" | ||
} | ||
}, | ||
"arguments": [] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...arser/test/fixtures/es2020/dynamic-import-createImportExpression-false/generator/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function* a() { | ||
yield import('http'); | ||
} |
60 changes: 60 additions & 0 deletions
60
...er/test/fixtures/es2020/dynamic-import-createImportExpression-false/generator/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":41}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":41}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":41}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11},"identifierName":"a"}, | ||
"name": "a" | ||
}, | ||
"generator": true, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":14,"end":41,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":3,"column":1,"index":41}}, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":18,"end":39,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":23,"index":39}}, | ||
"expression": { | ||
"type": "YieldExpression", | ||
"start":18,"end":38,"loc":{"start":{"line":2,"column":2,"index":18},"end":{"line":2,"column":22,"index":38}}, | ||
"delegate": false, | ||
"argument": { | ||
"type": "CallExpression", | ||
"start":24,"end":38,"loc":{"start":{"line":2,"column":8,"index":24},"end":{"line":2,"column":22,"index":38}}, | ||
"callee": { | ||
"type": "Import", | ||
"start":24,"end":30,"loc":{"start":{"line":2,"column":8,"index":24},"end":{"line":2,"column":14,"index":30}} | ||
}, | ||
"arguments": [ | ||
{ | ||
"type": "StringLiteral", | ||
"start":31,"end":37,"loc":{"start":{"line":2,"column":15,"index":31},"end":{"line":2,"column":21,"index":37}}, | ||
"extra": { | ||
"rawValue": "http", | ||
"raw": "'http'" | ||
}, | ||
"value": "http" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...test/fixtures/es2020/dynamic-import-createImportExpression-false/inside-function/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function loadImport(file) { | ||
return import(`test/${file}.js`); | ||
} |
Oops, something went wrong.