Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS plugin fails when strings contain comment markers #29

Open
mercurio opened this issue Apr 5, 2022 · 0 comments
Open

CommonJS plugin fails when strings contain comment markers #29

mercurio opened this issue Apr 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@mercurio
Copy link

mercurio commented Apr 5, 2022

Versions

  • node: 10.19.0

Reproduction

Attempt to import a minimized CommonJS module (I'm using zingchart-nodejs.min via @zingsoft/zingchart-svelte).

What is Expected?

It should be imported with no errors.

What is actually happening?

An error regarding an unterminated string is reported. The location given is for a comment marker // in the middle of a quoted string.

I took a look at the code (src/lib.ts). It looks as though you're stripping comments out without handling the case where the comment marker is inside a quoted string.

Perhaps the easiest way to fix this is to add an option to specify that the module you're importing is already minified and has no comments, and then don't call removeComments() if this option is enabled. Alternatively, you can just remove removeComments() completely, it doesn't matter if you convert a require into an import inside a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants