Skip to content

fix(vrowzer): give both Workers a default index.html when ready() gets none - #71

Merged
kazupon merged 4 commits into
mainfrom
fix/default-index-html
Oct 1, 2026
Merged

kazupon merged 4 commits into
mainfrom
fix/default-index-html

Conversation

@kazupon

@kazupon kazupon commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Closes #70

ready() without /index.html, as in the README usage example, now shows a preview: the runtime gives both Workers the same default /index.html.

Cause

The Web Worker wrote a default /index.html during setup. But the Service Worker, which serves the preview HTML from its own virtual filesystem, never got one. A ready() without /index.html therefore left the preview without HTML. Since #69, the preview reported one 404 load error and stayed blank.

The README usage example passes only /main.js, which writes into #app, so following it showed no preview.

Fix

  • initialize() adds a default /index.html to the files it copies from ready() when they have none, and sends it to both Workers. An /index.html given to ready() is used as before.
  • The default is minimal: an empty <div id="app"> and a module script that loads /main.js.
  • The Web Worker no longer writes its own default in setupVirtualFiles(), so the default lives in one place. The Web Worker receives the HTML from the Service Worker, and its default never reached a preview.
  • The README section of ready() and the JSDoc of VrowzerConfig.files describe the default. The API references are regenerated. The README examples are unchanged and now work as written.

The Web Worker's old default also had a global CSS reset (* { margin: 0; padding: 0; box-sizing: border-box; }), body padding and a "Loading..." placeholder. They are left out: they would clash with the user's CSS, and the old default never reached a preview.

Behavior change

A ready() without /index.html shows the default page, instead of a blank preview with a 404 load error. A preview always loads /index.html, so no working setup depended on its absence. Deleting /index.html after ready() still leads to a 404, as before.

Not included

Tests

  • Unit tests:

    • index-file-sync.test.ts: a ready() without /index.html sends the same default to both Workers, with #app and /main.js. The existing test that gives an /index.html passes unchanged, so a given /index.html is not replaced. The test from fix(vrowzer): write binary files given to ready() as bytes in both Workers #66 that compares the V_FS_INIT files now expects the default as well.
    • transformer.test.ts: setupWorker() no longer writes /index.html.

    The new checks failed before the change.

  • Integration test in the shared playground: opened with ?files=readme-example, the playground gives ready() only the /main.js of the README usage example. The test opens it in a new browser context, which has a Service Worker of its own, and checks that the preview shows "Hello!". Without the default, the preview stays blank and the test times out.

Validated locally with:

  • vp run test:unit: 119 files, 1,915 tests
  • vp run test:integration:vrowzer: 70 passed and 1 conditional skip, in three runs
  • vp run test:e2e: 46 passed, 6 existing test.skip
  • oxlint (no new warnings), knip, the format check of the changed files, and typecheck

…s none

The Web Worker wrote a default /index.html during setup, but the Service Worker, which serves the preview HTML, never got one. A ready() without /index.html, as in the README usage example, therefore left the preview without HTML: since #69 it reported one 404 load error and stayed blank.

initialize() now adds a default /index.html to the files it copies from ready() when they have none, and sends it to both Workers. The default is minimal: an empty #app element and a module script that loads /main.js. An /index.html given to ready() is used as before.
setupVirtualFiles() wrote a default /index.html in the Web Worker. The Service Worker serves the preview HTML and never had this default, so it was never served. The vrowzer runtime now sends the same default /index.html to both Workers when ready() gets none, so the Web Worker no longer writes its own. /public/.gitkeep is still written.
Opened with ?files=readme-example, the playground gives ready() only the /main.js of the README usage example. A new test opens it in a new browser context, which has a Service Worker of its own, and checks that the preview shows "Hello!", as the example expects.

Without the default /index.html, the preview stays blank and the test times out.
The README section of ready() and the JSDoc of VrowzerConfig.files say that, without /index.html, Vrowzer uses a default one: an empty #app element and a module script that loads /main.js. The API references are regenerated.
@kazupon
kazupon merged commit 74d6077 into main Oct 1, 2026
4 checks passed
@kazupon
kazupon deleted the fix/default-index-html branch October 1, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle ready() without /index.html, as in the README examples

1 participant