-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Describe the bug
SWC injects pure annotation right before the async polyfill call, however if async arrow function is been assigned, the PURE annotation appear in the wrong position.
Why does this matter
Because if Pure appears before the import statements, when this code is processed by webpack, if this module's dependencies are all concatenated, then the import statements are gone, and the code will be like this
/*#__PURE__*/
setSomeEffect()
As you can see the PURE annotation points that setSomeEffect call is pure which is not, and removes this call expression after minimization.
Input code
setSomeEffect()
// 123
const a = async () => {
};
function rightPlace() {
// 123
async () => {
};
}
Config
{
"jsc": {
"externalHelpers": true,
"parser": {
"tsx": true,
"syntax": "typescript",
},
"preserveAllComments": true,
"target": "es5"
},
}
Playground link
Expected behavior
Pure annotation should appear inside the assignment expr, like the one inside rightPlace function body
Actual behavior
Pure annotation appears at the top of the module
Version
1.3.71
Additional context
No response
danieltroger and ethanjiang7