Skip to content

this.addWatchFile() in the load() hook does not work #3474

@lemonmade

Description

@lemonmade

Describe the bug

When using a custom rollup plugin that replaces special module identifiers with out-of-band content generated on the basis of that identifier (e.g., import foo from 'special-loader:./module';, where special-loader:./module has a custom Rollup plugin that uses load() to runs a special build on the basis of ./module), Vite will never call the load() method of the plugin for that module again until the dev server is restarted, even if you use this.addWatchFiles() in the plugin to list files as out-of-band dependencies.

Reproduction

https://github.com/lemonmade/vite-example — README has instructions, but the basic gist is to run yarn && yarn dev, then edit worker.js, and note that the updates are never triggered in the actual built file.

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 11.3.1
    CPU: (8) arm64 Apple M1
    Memory: 2.27 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.4.0 - ~/.nvm/versions/node/v15.4.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v15.4.0/bin/yarn
    npm: 7.0.15 - ~/.nvm/versions/node/v15.4.0/bin/npm
  Browsers:
    Chrome: 90.0.4430.212
    Firefox Developer Edition: 87.0
    Safari: 14.1
    Safari Technology Preview: 14.2
  npmPackages:
    vite: ^2.3.3 => 2.3.3 

Used package manager: yarn


Before submitting the issue, please make sure you do the following

  • 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.
  • Provide a description in this issue that describes the bug.
  • 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 https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions