New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String import/export specifier #12091
String import/export specifier #12091
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/29849/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 107444b:
|
bd69ecd
to
425637a
Compare
...abel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-string/output.mjs
Outdated
Show resolved
Hide resolved
d7f2778
to
c50c767
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SystemJS output looks great, and glad it fixed some bugs too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should introduce this behind a syntax plugin. Even if the spec PR has consensus, it will still take a while to be merged because it doesn't have tests.
Also, for example tc39/ecma262#1174 still took a few months after having consensus and tests.
c50c767
to
c63fd3c
Compare
7ba178b
to
6f141a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for a question (maybe small error) this looks good 👍
exported: Identifier; | ||
local?: Identifier; | ||
exported: Identifier | StringLiteral; | ||
local?: Identifier | StringLiteral; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can local
be a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export { "😄" as "😂" } from "emojis"
f71402b
to
6e0d7bf
Compare
Co-Authored-By: Kai Cataldo <kai@kaicataldo.com>
6e0d7bf
to
0b4dc58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just some 🚲shedding on error messages.
Co-authored-by: Brian Ng <bng412@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
* feat: parse moduleExportName * feat: add validators * Support string specifier name in commonjs transform * Support string specifier name in export-ns-from * test: add loose testcases * test: add testcases for amd and umd * feat: support systemjs * test: update fixtures fixed in #12110 * add plugin name typings * test: rename test layout * feat: implement under moduleStringNames flag * chore: add plugin syntax module string names * feat: support ModuleExportName as ModuleExportName * test: update test fixtures * fix flow errors * docs: update AST spec * feat: support { "some imports" as "some exports" } * feat: support { "some imports" as "some exports" } in systemjs * test: add test on `import { "foo" }` * Address review comments * add moduleStringNames to missing plugin helpers * Apply suggestions from code review * update test fixtures * Update packages/babel-parser/src/parser/error-message.js * update test fixtures Co-Authored-By: Kai Cataldo <kai@kaicataldo.com> Co-authored-by: Brian Ng <bng412@gmail.com>
@babel/helper-module-transforms
now depends on@babel/helper-validator-identifier
This PR implements support of Arbitrary module namespace identifier names behind
moduleStringNames
parser pluginBabel can now parse such code and transform it to CommonJS/AMD/UMD/SystemJS code. Take CommonJS as an output example
A new package
@babel/plugin-syntax-module-string-names
is introduced. See also https://github.com/babel/babel/pull/12091/files#diff-ef433cb06c064c1e7a5af0f448d98a78 for AST spec changes.Todo: