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

fix: `@napi-rs/magic-string` can't handle `\x00` #17

Closed SukkaW closed 9 months ago

SukkaW commented 9 months ago

The @rollup/plugin-commonjs introduces virtual modules when transpiling commonjs modules. In rollup, virtual modules start with \0 (something like import virtual from '\x00something').

@napi-rs/magic-string can't handle \0 properly, causing SyntaxError: Unterminated string constant (1:33).

The PR fixes that by replacing @napi-rs/magic-string with magic-string.

@h-a-n-a Would you like to look into this, too?

SukkaW commented 9 months ago

@huozhi This is the issue I came up recently when running unit tests of bunchee. So I digged a little bit into this and created this PR.

huozhi commented 9 months ago

Nice, I bumped to it as well. It would fix this issue