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(optimizer): re-optimize when changing config webCompatible #18221

Merged

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Sep 28, 2024

Description

When flipping webCompatible: boolean, it should re-optimize as it affects import { createRequire } from 'module' banner etc..., but it didn't as this flag wasn't included in config hash.

additional context

I was setting up module runner in web worker and started with forgetting to enable webCompatible: true https://github.com/hi-ogawa/vite-environment-examples/blob/f2d1d071bc47bf1c8e6aabc17f6d631537ddb152/examples/web-worker/vite.config.ts#L17, so optimizer injecting import { createRequire } from 'module' banner, which then fails on web worker.

module-runner.js?v=764857e6:1082 Uncaught (in promise) TypeError: Failed to resolve module specifier 'module'
    at ESModulesEvaluator.runExternalModule (module-runner.js?v=764857e6:1082:19)

Flipping webCompatible didn't re-optimize so keep getting errors. Also it's probably a difference issue, but running it with --force doesn't seem to trigger re-optimization of custom environments. (EDIT: it looks like --force only affects client, so I had to do environments.worker.dev.optimizeDeps.force: true)

Copy link

stackblitz bot commented Sep 28, 2024

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

@hi-ogawa hi-ogawa marked this pull request as ready for review September 28, 2024 02:16
@patak-dev patak-dev merged commit a44b0a2 into vitejs:main Sep 28, 2024
17 checks passed
@hi-ogawa hi-ogawa deleted the fix-include-webCompatible-optimizer-hash branch September 28, 2024 09:54
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 this pull request may close these issues.

2 participants