diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 38b97f76672d..abfbcd55b7f7 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -108,6 +108,14 @@ export default (superClass: Class): Class => node.expression = false; } + cloneStringLiteral(node: any): any { + const cloned = super.cloneStringLiteral(node); + cloned.type = "Literal"; + cloned.raw = cloned.extra.raw; + delete cloned.extra; + return cloned; + } + checkDeclaration(node: N.Pattern | N.ObjectProperty): void { if (node != null && this.isObjectProperty(node)) { this.checkDeclaration(((node: any): N.EstreeProperty).value); diff --git a/packages/babel-parser/test/fixtures/estree/module-string-names/mixed/options.json b/packages/babel-parser/test/fixtures/estree/module-string-names/mixed/options.json deleted file mode 100644 index 2104ca43283f..000000000000 --- a/packages/babel-parser/test/fixtures/estree/module-string-names/mixed/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "sourceType": "module" -} diff --git a/packages/babel-parser/test/fixtures/estree/module-string-names/options.json b/packages/babel-parser/test/fixtures/estree/module-string-names/options.json new file mode 100644 index 000000000000..5d922f20985e --- /dev/null +++ b/packages/babel-parser/test/fixtures/estree/module-string-names/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["flow", "jsx", "estree"] +} diff --git a/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/input.js b/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/input.js new file mode 100644 index 000000000000..16354b710dc8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/input.js @@ -0,0 +1 @@ +export { "foo" } from "module-a"; diff --git a/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/output.json b/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/output.json new file mode 100644 index 000000000000..d63f4d3445e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/estree/module-string-names/shorthand/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "program": { + "type": "Program", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "specifiers": [ + { + "type": "ExportSpecifier", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "local": { + "type": "Literal", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "value": "foo", + "raw": "\"foo\"" + }, + "exported": { + "type": "StringLiteral", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "value": "foo" + } + } + ], + "source": { + "type": "Literal", + "start":22,"end":32,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":32}}, + "value": "module-a", + "raw": "\"module-a\"" + }, + "declaration": null, + "exportKind": "value" + } + ] + } +} \ No newline at end of file