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

build.modulePreload: false is not working as documented #11889

Closed
7 tasks done
kleinfreund opened this issue Feb 1, 2023 · 0 comments · Fixed by #12111
Closed
7 tasks done

build.modulePreload: false is not working as documented #11889

kleinfreund opened this issue Feb 1, 2023 · 0 comments · Fixed by #12111
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@kleinfreund
Copy link

Describe the bug

TL;DR: build.modulePreload set to false doesn’t work. As a workaround, one can set it to { resolveDependencies: () => [] } instead.

Related:

Reproduction

https://stackblitz.com/edit/vitejs-vite-wgn89w?file=vite.config.js

Steps to reproduce

  1. In a project that will be split into chunks on build and whose chunks are referenced in an entry point (the provided reproduction serves as an example of this), set build.modulePreload: false. According to https://vitejs.dev/config/build-options.html#build-modulepreload, this should turn off module preload.
  2. Build the project (e.g. yarn build in the provided reproduction).

Observe how the resulting index.html file contains <link rel=modulepreload ...> elements. This shouldn’t be the case.

Workaround: use { resolveDependencies: () => [] } instead of false

System Info

Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vite: ^4.0.4 => 4.0.4

Used Package Manager

yarn

Logs

No response

Validations

@benmccann benmccann added bug p2-edge-case Bug, but has workaround or limited in scope (priority) and removed pending triage labels Feb 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants