Skip to content

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

@kleinfreund

Description

@kleinfreund

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions