You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ES2022 introduced Arbitrary module namespace identifier names(tc39/ecma262#2154) feature that allows exporting non-legal identifiers. By taking advantage of this, we are now able to export variables with any names that is a valid "Well-Formed Code Unit Sequence".
With the previous example, we can generate the following code.
Add allowStringAliasedNamedExports: true option to dataToEsm that generates the code above.
The reason why I don't propose this to be a default behavior is because arbitrary module namespace identifier names is not transpilable (esbuild errors, swc skips).
If a breaking change is acceptable, I think the option can be merged with namedExports option.
namedExports: false: same with current false
namedExports: 'non-aliased': same with current true
namedExports: 'aliased': the proposed one
The text was updated successfully, but these errors were encountered:
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
pluginutils
Feature Use Case
Currently
dataToEsm
function of pluginutils skips named exports for non-legal identifiers.plugins/packages/pluginutils/src/dataToEsm.ts
Lines 84 to 96 in bc5cf91
For example,
dataToEsm({ foo: 0, 'foo.bar': 0 }, { namedExports: true })
generates the following code.ES2022 introduced Arbitrary module namespace identifier names(tc39/ecma262#2154) feature that allows exporting non-legal identifiers. By taking advantage of this, we are now able to export variables with any names that is a valid "Well-Formed Code Unit Sequence".
With the previous example, we can generate the following code.
Related: vitejs/vite#11359
Feature Proposal
Add
allowStringAliasedNamedExports: true
option todataToEsm
that generates the code above.The reason why I don't propose this to be a default behavior is because arbitrary module namespace identifier names is not transpilable (esbuild errors, swc skips).
If a breaking change is acceptable, I think the option can be merged with
namedExports
option.namedExports: false
: same with currentfalse
namedExports: 'non-aliased'
: same with currenttrue
namedExports: 'aliased'
: the proposed oneThe text was updated successfully, but these errors were encountered: