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 rollup compatibility #3216

Closed
DylanPiercey opened this issue Apr 29, 2021 · 3 comments
Closed

this.addWatchFile rollup compatibility #3216

DylanPiercey opened this issue Apr 29, 2021 · 3 comments
Labels
contribution welcome p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) rollup plugin compat

Comments

@DylanPiercey
Copy link
Contributor

Clear and concise description of the problem

There is an API incompatibility with rollup for the addWatchFile api.
Specifically the first note after the addWatchFile documentation mentions the following:

Using this.addWatchFile from within the transform hook will make sure the transform hook is also reevaluated for this module if the watched file changes.

In Vite this.addWatchFile does nothing special in this case and just tracks the new file independently.

Suggested solution

Ideally we'd mirror the rollup behavior.

@dominikg
Copy link
Contributor

I recently added a workaround for that in vite-plugin-svelte by triggering virtual change events on the watcher. Could be useful here aswell? But i guess internally in vite it would be easier to just call the handler directly and skip the watch event.

https://github.com/sveltejs/vite-plugin-svelte/blob/main/packages/vite-plugin-svelte/src/utils/watch.ts

@github-actions
Copy link

Hello @DylanPiercey. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!

@mattcompiles
Copy link
Contributor

Just dropping in my use-case for this feature as requested.

Our CSS-in-JS library vanilla-extract runs JS/TS files (e.g. styles.css.ts) at build time to generate CSS files. The JS file you write is not sent to the client as it is only executed at build time. Each .css.ts file can import other files. e.g. styles.css.ts imports colors.ts. In this example, if the colors.ts file is updated, we want to re-run the transform for styles.css.ts.

Other prior art here is the webpack addDependency API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) rollup plugin compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants