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
When transforming EMS code to CJS with platform: 'node', using the export as syntax with the as side being a string literal that is not also a valid identifier name results in invalid output.
According to the ECMAScript spec, the right side of an export as statement is allowed to be an arbitrary string literal (an ExportSpecifier can be of the form ModuleExportName or ModuleExportName as ModuleExportName, where ModuleExportName can be either an IdentifierName or a StringLiteral).
This pattern was observed in the wild in v1.0.0 of the async-function package, specifically in the require.mjs file.
When transforming EMS code to CJS with
platform: 'node'
, using theexport as
syntax with theas
side being a string literal that is not also a valid identifier name results in invalid output.For example, this is perfectly valid ESM:
But the output of transforming this ends with
Which is not valid syntax.
According to the ECMAScript spec, the right side of an
export as
statement is allowed to be an arbitrary string literal (anExportSpecifier
can be of the formModuleExportName
orModuleExportName as ModuleExportName
, whereModuleExportName
can be either anIdentifierName
or aStringLiteral
).This pattern was observed in the wild in v1.0.0 of the async-function package, specifically in the
require.mjs
file.Playground reproduction link: https://esbuild.github.io/try/#dAAwLjI1LjAAewogIGZvcm1hdDogJ2NqcycsCiAgcGxhdGZvcm06ICdub2RlJwp9AGNvbnN0IHNvbWV0aGluZyA9ICJzdHViIjsKZXhwb3J0IGRlZmF1bHQgc29tZXRoaW5nOwpleHBvcnQgeyBzb21ldGhpbmcgYXMgImZvby5iYXIiIH07
The text was updated successfully, but these errors were encountered: