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

unplugin watch #773

Closed
5 tasks done
edemaine opened this issue Oct 11, 2023 · 9 comments
Closed
5 tasks done

unplugin watch #773

edemaine opened this issue Oct 11, 2023 · 9 comments
Labels
bug Something isn't working plugin/integration Integrating Civet with other tools

Comments

@edemaine
Copy link
Collaborator

edemaine commented Oct 11, 2023

The esbuild unplugin doesn't currently work with watch. I believe we need to return watchFiles.

Progress so far:

@edemaine edemaine added bug Something isn't working plugin/integration Integrating Civet with other tools labels Oct 11, 2023
@STRd6
Copy link
Contributor

STRd6 commented Oct 13, 2023

This probably requires a PR to https://github.com/unjs/unplugin/

https://github.com/unjs/unplugin/blob/39c0b22a30bdd7112962e377c39d2a24dcbc5847/src/esbuild/index.ts#L64 is setting the namespace to the plugin name and not file which is required by esbuild to watch paths.

https://esbuild.github.io/plugins/#on-resolve-results

@STRd6
Copy link
Contributor

STRd6 commented Oct 13, 2023

Additionally there is currently no way in unplugin to pass through watchFiles or watchDirs.

@edemaine
Copy link
Collaborator Author

unplugin claims support for this.addWatchFile but not yet for esbuild. Maybe we can easily add it (via a PR to unplugin) by storing them in an array and returning it from getWatchFiles.

@edemaine
Copy link
Collaborator Author

By the way, we could more easily fix this in esbuild-plugin. Or does it already support "watch"?

@STRd6
Copy link
Contributor

STRd6 commented Oct 13, 2023

Watch works in esbuild-plugin but it has some other bugs (something with sourcemaps, and #750). We may be able to update it to be at parity and it would help us understand the build process better as well.

@STRd6
Copy link
Contributor

STRd6 commented Oct 14, 2023

I think the core unplugin issue is that it sets namespace to be the name of the plugin instead of file which causes the files to not be visible to watch.

@edemaine
Copy link
Collaborator Author

edemaine commented Oct 15, 2023

I'm not sure removing the namespace setting from unplugin would fix the problem, because our resolveId callback (onResolve in esbuild terminology) adds a .tsx or .jsx extension to the filename, so it will no longer be a valid filename. (I assume this means watch is broken in all systems? Also it maybe explains the choice of namespace.) I'm hoping implementing and calling addWatchFile might be a better universal solution for all build systems.

@edemaine edemaine changed the title esbuild watch unplugin watch Oct 27, 2023
@edemaine
Copy link
Collaborator Author

edemaine commented Nov 5, 2023

Update: #780 fixed watch mode on Rollup and Webpack. esbuild is waiting on unjs/unplugin#345 gets merged. Vite still isn't working (on Windows or Linux).

@edemaine
Copy link
Collaborator Author

Vite dev mode was fixed by #860, and esbuild was fixed by #895. 0.6.61 should have a fully working watch mode!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin/integration Integrating Civet with other tools
Projects
None yet
Development

No branches or pull requests

2 participants