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
Support “Arbitrary module namespace identifier names” #40594
Comments
|
Note that Babel now has support for this: babel/babel#12091 |
import { "😊" as yay } from "...";
yay();
export { yay as "🦈" };The above code should be supported. The minimum viable product should have tests for:
It is likely that we would never try to emit our own |
|
Is it planned for this to work with TypeScript types as well as values? For example, I'd expect the following to be valid as well: import type { 'a' as b } from 'foo'
import { type 'a' as b } from 'foo'
export type { a as 'b' }
export { type a as 'b' }
export { type 'a' } from 'foo'
export { type 'a' as b } from 'foo'
export { type a as 'b' } from 'foo'
export { type 'a' as 'b' } from 'foo' I'm wondering because esbuild supports both TypeScript and arbitrary module namespace identifier names, so it has to deal with this somehow. Right now I'm moving forward assuming that it will eventually be supported for types as well but it would be good to clarify this. |
|
@evanw I’m pretty sure your examples above will “just work” unless we explicitly disallow them, and I don’t see an immediate reason to do that. The syntax above would certainly parse. Just out of curiosity, what’s the impact of this on esbuild? |
|
@DanielRosenwasser should this actually be milestoned right now? It’s a bit hard to tell the status of the spec change, but it looks kinda stuck. |
|
Good call, I assumed it would be an open-and-shut normative PR but it looks like it hasn't been updated for a while; let's hold off until tc39/ecma262#2154 is actually merged. |
Note that this is already implemented in V8, SpiderMonkey, and JavaScriptCore; see tc39/ecma262#2154 (comment):
|
|
@andrewbranch @DanielRosenwasser |
|
@DanielRosenwasser do we want to make this Help Wanted for 4.6? Kind of surprised we don’t have a community PR already |
|
I suppose so - I would urge a bit of caution to external contributors because I'm sure an implementation needs to now handle a bunch of edge-cases around rename, find-all-refs, etc. Also, it might be worth erroring if the module target isn't high enough? Unclear to me right now. |
|
Issue body code block by @ExE-Boss
Emit: as;
foo;
from;
"./module.js";
export { foo as } from "some exports";
from;
"./module.js";
as;
"another exports";
from;
"./module.js";
from;
"./module.js";
as;
extra_imports;
from;
"./module.js";
export * as from "star exports";
from;
"./module.js";Historical Information
|
|
Let me try this but no guarantee I will make it |
|
Parser and SystemJS/CommonJS emit work now. Still have no idea how I should change the type system to support analyzing that. |
ExE-Boss commentedSep 16, 2020
•
edited
Search Terms
Suggestion
Implement support for tc39/ecma262#2154.
Use Cases
This is necessary for WASM module integration.
This would also allow typing
@types/webidl‑conversionswithout needing to useexport =.For transpiled modules, this can already be supported, since it’s just creation of arbitrary properties on the CommonJS
exportsobject, but native modules will requiremodule: "ESNext".Examples
See tc39/ecma262#2154
Workbench Repro
Checklist
My suggestion meets these guidelines:
Related issues
The text was updated successfully, but these errors were encountered: