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

CLI's --minify-syntax breaks some code #648

Closed
AlexVasiluta opened this issue Jan 6, 2021 · 1 comment
Closed

CLI's --minify-syntax breaks some code #648

AlexVasiluta opened this issue Jan 6, 2021 · 1 comment

Comments

@AlexVasiluta
Copy link

Hey!

I've been trying to bundle the dependencies for my website in a single .js file. It has been an absolute breeze until now, but when I build for production (using the CLI with --minify), the code breaks. Using esbuild without --minify-syntax and adding the other 2 --minify-* flags, the code works perfectly. I created a minimal example with the only dependency that breaks (toastr.js v2.1.4, the latest version).

Here's the example.js file I made for this bug report:

import toastr from 'toastr';

export {toastr};

And the example html I use in browser to see that it breaks:

<head>
<!-- CSS added to actually see something if it works -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.css" />
<script src="./something.js"></script>
</head>
<body>
<script>
	bundled.toastr.info("Something", "Something else")
</script>
</body>

This command for bundling the example.js file makes everything work as intended (the toastr toast is correctly rendered without any errors):

esbuild example.js --bundle --minify-whitespace --minify-identifiers --outfile=something.js --global-name=bundled

While this one (the exact same as above, but adding --minify-syntax) does not:

esbuild example.js --bundle --minify-whitespace --minify-identifiers --minify-syntax --outfile=something.js --global-name=bundled

For the record:

$ esbuild --version
0.8.30

From what I see (but I might be wrong), the function that is not found is moved inside the wrong scope.
I wish I could help more, but I don't know any more specifics. I hope what I gave here is enough!

Anyways, thank you so much for your awesome project!

@evanw evanw closed this as completed in 90cb795 Jan 7, 2021
@evanw
Copy link
Owner

evanw commented Jan 7, 2021

Thanks for the clear report. I was able to fix the problem immediately. The fix will go out with the release later today. Sorry about the breakage.

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

Successfully merging a pull request may close this issue.

2 participants