Closed himself65 closed 1 year ago
Hi, I couldn't tell much from the error trace here. Do you have a reproduction for this or can you provide more info about how you bumped to this? Thanks
I will do that later
I have reproduced the issue @himself65 @huozhi: https://github.com/SukkaW/rollup-plugin-swc-preserve-directives/commit/e05281fb400d87d82cb7d684b8e048a3a9376ad7
I will look into this.
Update: I have found the root cause of the issue.
When parsing the module, swc ignores the leading comments (/** Copyright (c)
), and starts calculating span at the position of "use strict"
. But the magic string operates at the start of the file.
See also: swc playground:
@huozhi I highly recommend dropping swc and pushing https://github.com/huozhi/rollup-plugin-swc-preserve-directives/pull/4 forward. swc's JS Parse API is literally not usable at this moment.
Sounds we should file an issue to swc to let swc fix it
@huozhi
Although https://github.com/swc-project/swc/issues/7845 has been closed, I suspect https://github.com/swc-project/swc/issues/7842 is also related to this.