Parse string export names by default (moduleStringNames) (#13195)

* Parse string epxort names by default (`moduleStringNames`)

* Remove remaining references
This commit is contained in:
Nicolò Ribaudo 2021-04-23 09:07:58 +02:00
parent ceaab0bae7
commit 57daba85aa
30 changed files with 6 additions and 28 deletions

View File

@ -2089,7 +2089,6 @@ export default class StatementParser extends ExpressionParser {
// https://tc39.es/ecma262/#prod-ModuleExportName
parseModuleExportName(): N.StringLiteral | N.Identifier {
if (this.match(tt.string)) {
this.expectPlugin("moduleStringNames");
const result = this.parseLiteral<N.StringLiteral>(
this.state.value,
"StringLiteral",

View File

@ -1,7 +1,4 @@
{
"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)"
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "module"
}

View File

@ -1,2 +0,0 @@
export { foo as "some exports" };
var foo;

View File

@ -1,5 +0,0 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleStringNames' (1:16)",
"sourceType": "module",
"plugins": []
}

View File

@ -1 +0,0 @@
import { "foo" as bar, "default" as qux } from "module-a";

View File

@ -1,5 +0,0 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'moduleStringNames' (1:9)",
"sourceType": "module",
"plugins": []
}

View File

@ -1,4 +0,0 @@
{
"sourceType": "module",
"plugins": ["moduleStringNames"]
}

View File

@ -1,8 +1,5 @@
{
"sourceType": "module",
"plugins": [
"moduleStringNames",
"flow"
],
"plugins": ["flow"],
"throws": "A string literal cannot be used as an imported binding.\n- Did you mean `import { \"foo\" as foo }`? (1:9)"
}

View File

@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["flow", "moduleStringNames"]
"plugins": ["flow"]
}

View File

@ -176,7 +176,6 @@ describe("path/introspection", function () {
it('rejects the "export called *" trick', function () {
const program = getPath(`import * as ns from "source"; ns["*"].nested;`, {
sourceType: "module",
plugins: ["moduleStringNames"],
});
const reference = program.get("body.1.expression");
expect(reference.referencesImport("source", "nested")).toBe(false);