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

Minification of some javascript is breaking some functionality. #750

Open
coravacav opened this issue Mar 24, 2024 · 4 comments
Open

Minification of some javascript is breaking some functionality. #750

coravacav opened this issue Mar 24, 2024 · 4 comments
Labels
disposition:close The tagged item can probably be closed

Comments

@coravacav
Copy link

Running into some issues adding javascript to an app. Without minification, you get
image
Which seems to be a result of minification.

I've created a relatively minimal reproduction here.

Changing

<script data-trunk src="treesitter/tree-sitter.js"></script>

to

<script data-trunk data-no-minify src="treesitter/tree-sitter.js"></script>

during a release build (otherwise modification in general is disabled) solves the problem.

@coravacav
Copy link
Author

A note from further testing: it seems that with serve, only the javascript of the tree-sitter must not be minified. However, when built, the tree-sitter wasm also needs to be minified. This seems to be a well-known issue for treesitter as seen here tree-sitter/tree-sitter#927, however it still seems notable to bring up here because the change in javascript behavior is still probably not ideal.

@ctron
Copy link
Collaborator

ctron commented Mar 26, 2024

I am not sure what the exact problem is. I do recall issues where the JS file was actually a module JS file. That can make a difference. For that you would need to set type="module" (also see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type).

Trunk uses https://github.com/wilsonzlin/minify-js for JS minification (we use 0.5.6, as 0.6.0 also had some issues). So it would make sense to open an issue on that project.

@ctron
Copy link
Collaborator

ctron commented Apr 23, 2024

I am not sure if there's something that trunk could do better? If so, please let me know.

@ctron ctron added the disposition:close The tagged item can probably be closed label Apr 23, 2024
@coravacav
Copy link
Author

Sorry for not replying sooner.

Adding type="module" changes the error to be

highlighting-b62b1cbd3f28dbb8.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'init')
    at highlighting-b62b1cbd3f28dbb8.js:1:19

I'll also open an issue over there when I find some time, but I am leaving this here for posterity's sake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition:close The tagged item can probably be closed
Projects
None yet
Development

No branches or pull requests

2 participants