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(build): declare moduleSideEffects for vite:modulepreload-polyfill #13099

Merged
merged 4 commits into from
May 8, 2023

Conversation

linl33
Copy link
Contributor

@linl33 linl33 commented May 5, 2023

Description

Add moduleSideEffects: true property to vite:modulepreload-polyfill. The polyfill is effectful so it needs be declared as such otherwise it could be removed by Rollup.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented May 5, 2023

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

@linl33 linl33 force-pushed the fix-modulepreload-polyfill-effects branch from cf92a99 to 88d64af Compare May 5, 2023 05:05
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.

Seems like this is only caused because you've configured rollup with rollupOptions.treeshake.moduleSideEffects: false, but I don't think this addition hurts so sounds fine to me.

Copy link
Member

Choose a reason for hiding this comment

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

it doesn't look like this file is used. Could we remove it?

Copy link
Contributor Author

@linl33 linl33 May 8, 2023

Choose a reason for hiding this comment

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

Just removed it, I forgot to delete it.

@bluwy bluwy added p2-nice-to-have Not breaking anything but nice to have (priority) feat: build labels May 8, 2023
@linl33
Copy link
Contributor Author

linl33 commented May 8, 2023

rollupOptions.treeshake.moduleSideEffects defaults to true but when it's set to false or an array (that doesn't include vite:modulepreload-polyfill) the polyfill gets removed by tree-shaking. (When it's set to a callback, modules whose name starts with '\0' are never considered side-effect free.)

@linl33 linl33 force-pushed the fix-modulepreload-polyfill-effects branch from 0587617 to cff99bf Compare May 8, 2023 07:49
@patak-dev patak-dev merged commit d63129b into vitejs:main May 8, 2023
@linl33 linl33 deleted the fix-modulepreload-polyfill-effects branch May 8, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: build p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants