Skip to content

Commit

Permalink
Parse string export names by default (moduleStringNames) (#13195)
Browse files Browse the repository at this point in the history
* Parse string epxort names by default (`moduleStringNames`)

* Remove remaining references
  • Loading branch information
nicolo-ribaudo committed Apr 23, 2021
1 parent bf053df commit a9f5e07
Show file tree
Hide file tree
Showing 30 changed files with 6 additions and 28 deletions.
1 change: 0 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -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",
Expand Down
@@ -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)"
}
}
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -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)"
}
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"plugins": ["flow", "moduleStringNames"]
"plugins": ["flow"]
}
1 change: 0 additions & 1 deletion packages/babel-traverse/test/introspection.js
Expand Up @@ -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);
Expand Down

0 comments on commit a9f5e07

Please sign in to comment.