-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Closed
Copy link
Labels
p4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)regressionThe issue only appears after a new releaseThe issue only appears after a new release
Description
Describe the bug
#16184 caused a regression in our codebase when upgrading to 5.3.x. We use the renderBuiltUrl to update the asset URL based on some configuration.
Vite config:
experimental: {
renderBuiltUrl(filename: string, { hostType }) {
if (hostType === "js") {
return { runtime: `window.__toStaticUrl(${JSON.stringify(filename)})` };
} else {
return { relative: true };
}
},
},window.__toStaticUrl is depending on some configuration and is loaded in a file we call preload.ts before our main file entry.ts. Snippet from our index.html file:
<script type="module" src="/src/vite/preload.ts"></script>
<script type="module" src="/src/vite/entry.ts"></script>In prouduction vite bundles preload and entry into one chunk. This used to work fine, but the challenge with the change in this PR is that instead of lazy evaluating window.__toStaticUrl when building the mapDeps, we now expect the function to be defined beforehand. As the function is not defined we get a TypeError: window.__toStaticUrl is not a function.
Additional context in #16184 (comment)
Reproduction
Steps to reproduce
No response
System Info
n/aUsed Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)regressionThe issue only appears after a new releaseThe issue only appears after a new release