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: replace swc with acorn #4

Closed SukkaW closed 1 year ago

SukkaW commented 1 year ago

Closes #9.

This is just a PoC that we can replace swc with rollup's built-in this.parse if since the swc team has already decided to drop the parse JS API in swc's next major version, here I quote from https://github.com/swc-project/swc/issues/7845:

There's no good way to use source location from JS plugin, and JS plugin is going to be deprecated anyway.

huozhi commented 1 year ago

I feel like this change is kinda rebranding the plugin, I’m good with the direction but think if we land this the plugin should be renamed, If swc will be removed from the dependency eventually

huozhi commented 1 year ago

I've seeing error from https://github.com/huozhi/bunchee/actions/runs/6084629348/job/16507030569

(swc-render-directive plugin) [rollup-swc-preserve-directives]: failed to parse "/Users/huozhi/code/bunchee/test/fixtures/package/inde
x.ts" and extract the directives. make sure you have added "rollup-swc-preserve-directives" to the last of your plugins list, after swc/babe
l/esbuild/typescript or any other transform plugins.

As the [original issue of swc] is fixed in new versions of @swc/core, I gonna revert the changes, but will keep the tests.