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

__vite__mapDeps optimization breaks configuration depending on Vite bundling #17575

Closed
7 tasks done
skovhus opened this issue Jun 27, 2024 · 1 comment · Fixed by #17602
Closed
7 tasks done

__vite__mapDeps optimization breaks configuration depending on Vite bundling #17575

skovhus opened this issue Jun 27, 2024 · 1 comment · Fixed by #17602
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release

Comments

@skovhus
Copy link
Contributor

skovhus commented Jun 27, 2024

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

#16184 (comment)

Steps to reproduce

No response

System Info

n/a

Used Package Manager

pnpm

Logs

No response

Validations

@skovhus
Copy link
Contributor Author

skovhus commented Jun 27, 2024

@bluwy mentioned that @panstromek had an alternative at hand for this case: #16184 (comment)

@bluwy bluwy added p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release and removed pending triage labels Jun 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants