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

Incorrect javascript output when having an expression in the middle #494

Closed
perrin4869 opened this issue Jun 20, 2022 · 4 comments
Closed

Comments

@perrin4869
Copy link
Contributor

I've been trying to minify my project using this library, but ran into this minimal reproduction:

foo.js:

var foo = "bar";
({});
var get = { bar: () => foo() };

Running this on node will exit normally, however:

$ minify foo.js
var foo="bar",get;({},get={bar:()=>foo())}

Running this on node:

node_modules/tdewolff-minify/minify foo.js | node
[stdin]:1
var foo="bar",get;({},get={bar:()=>foo())}
                                        ^

SyntaxError: Unexpected token ')'
    at new Script (node:vm:100:7)
    at createScript (node:vm:257:10)
    at Object.runInThisContext (node:vm:305:10)
    at node:internal/process/execution:76:19
    at [stdin]-wrapper:6:22
    at evalScript (node:internal/process/execution:75:60)
    at node:internal/main/eval_stdin:29:5
    at Socket.<anonymous> (node:internal/process/execution:213:5)
    at Socket.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)

It fails to parse the resulting js.

@tdewolff
Copy link
Owner

Thanks for bringing this issue to the attention, I've fixed this and several other cases where it appeared! Please let me know if you find further issues.

@perrin4869
Copy link
Contributor Author

Thank you so much!!! Looking forward to giving it a spin :)
Can you publish a release? I'm using https://www.npmjs.com/package/tdewolff-minify right now

@tdewolff
Copy link
Owner

Yes, checkout v2.11.11!

@perrin4869
Copy link
Contributor Author

Thanks! It worked like a charm!

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

No branches or pull requests

2 participants