huozhi / rollup-preserve-directives

This is a rollup plugin that helps preserve shebang and string directives.
https://npmjs.com/package/rollup-preserve-directives
34 stars 4 forks source link

refactor: re-implement rollup built-in parse API #13

Closed SukkaW closed 9 months ago

SukkaW commented 9 months ago

Re-land rollup parse API.

The reason that keeps breaking is we're using a pretty unsafe operation to delete code based on swc node's span as it's already not recommended, which is only for getting rid of the roll warnings.

Since we are using rollup's built-in parse API, the node span is now safe and correct.

I will also send another PR to bunchee to fix https://github.com/huozhi/rollup-plugin-swc-preserve-directives/pull/4#issuecomment-1706551223.