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

fix: ignore sideEffects for scripts imported from html #12786

Merged

Conversation

patak-dev
Copy link
Member

Fixes #10735

Description

It seems that adding moduleSideEffects: false to scripts imported from .HTML files pushes rollup to tree shake everything. Because "sideEffects": false is set in the package.json of the app, we end up doing this for every file.

This fix works for this reproduction: #10735 (comment)

I don't know if the fix should be more generic though. We could do this as a stop-gap if no one has a better idea here.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@stackblitz
Copy link

stackblitz bot commented Apr 7, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev added p4-important Violate documented behavior or significantly improves performance (priority) feat: build labels Apr 7, 2023
@patak-dev patak-dev mentioned this pull request Apr 7, 2023
7 tasks
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, but would be great to have tests 😬

@patak-dev
Copy link
Member Author

Done, thanks for the push ❤️

@patak-dev patak-dev requested a review from bluwy April 7, 2023 17:26
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@patak-dev patak-dev enabled auto-merge (squash) April 7, 2023 17:34
@patak-dev patak-dev merged commit f09551f into main Apr 7, 2023
18 checks passed
@patak-dev patak-dev deleted the fix/ignore-side-effects-for-scripts-imported-from-html branch April 7, 2023 17:36
@fregante
Copy link

fregante commented Apr 7, 2023

Let me know when this appears in a beta so I can add it to my PR.

thanks for working on this!

@patak-dev
Copy link
Member Author

@fregante released in vite@4.3.0-beta.4

@fregante
Copy link

fregante commented Apr 9, 2023

Success! 38KB

❯ nr demo:build
vite v4.3.0-beta.4 building for production...
✓ 10 modules transformed.
3:36:08 PM [vite-plugin-svelte] dom compile done.
package             	files	  time	   avg
github-url-detection	    1	94.5ms	94.5ms
dist/index.html                  0.85 kB │ gzip:  0.49 kB
dist/assets/index-7b93ea5e.css   0.63 kB │ gzip:  0.34 kB
dist/assets/index-8dab0bc5.js   38.73 kB │ gzip: 10.58 kB
✓ built in 430ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: build p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3.2.0 missing output
3 participants