Parse string export names by default (moduleStringNames) (#13195)
* Parse string epxort names by default (`moduleStringNames`) * Remove remaining references
This commit is contained in:
parent
ceaab0bae7
commit
57daba85aa
@ -2089,7 +2089,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
// https://tc39.es/ecma262/#prod-ModuleExportName
|
// https://tc39.es/ecma262/#prod-ModuleExportName
|
||||||
parseModuleExportName(): N.StringLiteral | N.Identifier {
|
parseModuleExportName(): N.StringLiteral | N.Identifier {
|
||||||
if (this.match(tt.string)) {
|
if (this.match(tt.string)) {
|
||||||
this.expectPlugin("moduleStringNames");
|
|
||||||
const result = this.parseLiteral<N.StringLiteral>(
|
const result = this.parseLiteral<N.StringLiteral>(
|
||||||
this.state.value,
|
this.state.value,
|
||||||
"StringLiteral",
|
"StringLiteral",
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"plugins": [
|
|
||||||
"moduleStringNames"
|
|
||||||
],
|
|
||||||
"throws": "A string literal cannot be used as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
|
"throws": "A string literal cannot be used as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
|
||||||
}
|
}
|
||||||
3
packages/babel-parser/test/fixtures/es2022/module-string-names/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/es2022/module-string-names/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"sourceType": "module"
|
||||||
|
}
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export { foo as "some exports" };
|
|
||||||
var foo;
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleStringNames' (1:16)",
|
|
||||||
"sourceType": "module",
|
|
||||||
"plugins": []
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
import { "foo" as bar, "default" as qux } from "module-a";
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleStringNames' (1:9)",
|
|
||||||
"sourceType": "module",
|
|
||||||
"plugins": []
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"sourceType": "module",
|
|
||||||
"plugins": ["moduleStringNames"]
|
|
||||||
}
|
|
||||||
@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"plugins": [
|
"plugins": ["flow"],
|
||||||
"moduleStringNames",
|
|
||||||
"flow"
|
|
||||||
],
|
|
||||||
"throws": "A string literal cannot be used as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
|
"throws": "A string literal cannot be used as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"plugins": ["flow", "moduleStringNames"]
|
"plugins": ["flow"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,7 +176,6 @@ describe("path/introspection", function () {
|
|||||||
it('rejects the "export called *" trick', function () {
|
it('rejects the "export called *" trick', function () {
|
||||||
const program = getPath(`import * as ns from "source"; ns["*"].nested;`, {
|
const program = getPath(`import * as ns from "source"; ns["*"].nested;`, {
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
plugins: ["moduleStringNames"],
|
|
||||||
});
|
});
|
||||||
const reference = program.get("body.1.expression");
|
const reference = program.get("body.1.expression");
|
||||||
expect(reference.referencesImport("source", "nested")).toBe(false);
|
expect(reference.referencesImport("source", "nested")).toBe(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user