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

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

Closed
6 tasks done
lemonmade opened this issue May 20, 2021 · 1 comment · Fixed by #14967
Closed
6 tasks done

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

lemonmade opened this issue May 20, 2021 · 1 comment · Fixed by #14967
Labels

Comments

@lemonmade
Copy link

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.
@bluwy
Copy link
Member

bluwy commented Mar 9, 2022

I assume the fix for this would be similar as #7024, but nonetheless web workers support has been improved a lot since this issue, so the issue you had with workers may be resolved too.

@bluwy bluwy added enhancement New feature or request rollup plugin compat and removed pending triage labels Dec 29, 2022
@bluwy bluwy changed the title this.addWatchFile() in the load() method of a Rollup plugin does not trigger an update in the loaded module if that module is not a "real" file this.addWatchFile() in the load() hook does not work Nov 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants