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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid optimizing non-optimizable external deps #8860


Copy link


We discovered that Vite 3 will optimize deps added to ssr.noExternal, even when those deps are not optimizable. This change will check whether a dependency is optimizable before attempting to optimize.

  • if you include a non-optimizable dep in ssr.noExternal 馃憠 don't optimize, don't log a warning
  • if you include a non-optimizable dep in optimizeDeps.include 馃憠 don't optimize, DO log a warning

Additional context

  • adds non-optimizable dependency to the optimize-deps playground test
  • adds non-optimizable dependency to the ssr-deps playground test

鈽濓笍 Note: no unit tests were added to the .spec.ts files! This is because we're just checking whether your Vite config causes the test suite to bomb. By adding non-optimizable-dep to optimizeDeps.include, for example, we're implicitly checking whether Vite will (wrongly) attempt to optimize.

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 Commit 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.

Copy link

netlify bot commented Jun 29, 2022

Deploy Preview for vite-docs-main canceled.

Name Link
馃敤 Latest commit c87ad7c
馃攳 Latest deploy log

@bholmesdev bholmesdev changed the title Vite 3 - avoid optimizing non-optimizable external deps fix: avoid optimizing non-optimizable external deps Jun 29, 2022
Copy link

Thanks a lot @bholmesdev! Great explanation and test case too!
Welcome to Vite Core 鈿

@patak-dev patak-dev merged commit cd8d63b into vitejs:main Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants