-
Notifications
You must be signed in to change notification settings - Fork 190
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
File writer refactor #427
File writer refactor #427
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
e0af361
to
13ee415
Compare
8759e04
to
5632883
Compare
add comments change plugin array order for clarity
Ooh this is exciting @jacksteamdev - does this mean a release is imminent? 😍 |
@saxoncameron I'm going to do a beta release later today! I gave it a test run with a Svelte project yesterday, I think things are mostly stable 🤞 |
Looks like the release failed (not sure if you saw) — happy to do a beta test after the release! |
Finally had some time to get this release done right! You can try it out on NPM 🚀 https://www.npmjs.com/package/@crxjs/vite-plugin/v/2.0.0-beta.1 This should fix some bugs, but there may be regressions I haven't caught yet. Beta testers, please create issues, thank you so much! |
It's time to wind up the creation phase of CRXJS, and the file writer needs a better design. I have an idea for an HMR-based file writer that excludes the need for Rollup, or any kind of watcher.
Currently, the file writer is the most obtuse part of the project, with a confusing event-based model. Because it produces a full build for every change, even with caching it uses more resources than necessary.
This rewrite won't change any exposed API details, and with the existing tests, it shouldn't cause any significant regressions.
Specs
file-writer-scripts
type ScriptModule = Promise<{type, viteUrl, filename}>
type ScriptType = 'loader'|'module'|'iife'|'dep'
start(server: ViteDevServer): Promise<void>
add(viteUrl: string, options?: {type: ScriptType}): ScriptModule
update(viteUrl: string, options: {type: ScriptType}): Promise<void>
reset(): Promise<void>
Removes all content scripts and deletes files.modules
Module graph asMap<ScriptModule>
viteUrlToFilename(viteUrl: string): string
Convert Vite URL to output filename/\?/g -> '__'
/\&/g -> '--'
.js
start(server)
to start file writeradd()
add
content scripts from manifestadd
content scripts from?script
importsadd
(sometimes no-op)update
fileupdate
(always rewrite file)add
file depsscript&loader
Use content script loader to gain HMRscript&module
Output raw ES module?module
?script&iife
Output IIFE formatNotes
Because this refactor won't use an internal instance of Rollup in watch mode, it may restore support for
vite build --watch
. Related #429