Skip to content

feat: Bundle iframe and vat worker via kernel-browser-runtime - #531

Merged
rekmarks merged 10 commits into
mainfrom
rekm/browser-runtime-iframe
Jun 3, 2025
Merged

feat: Bundle iframe and vat worker via kernel-browser-runtime#531
rekmarks merged 10 commits into
mainfrom
rekm/browser-runtime-iframe

Conversation

@rekmarks

@rekmarksrekmarks commented Jun 2, 2025

Copy link
Copy Markdown
Member

Ref: #461

#522 introduced the kernel-browser-runtime package, which bundled the kernel Web Worker. Further experiments indicated that it would be salutary for this package to bundle the vat worker, i.e. vat iframe, as well.

To facilitate this, we replace esbuild with vite in kernel-browser-runtime, and extract all vat iframe-related functionality to this package. We also extract the extension's Vite plugins into a dedicated, private package so that they can be reused.

Finally, during development, it was discovered that Vite duplicates the @sqlite.org/sqlite.wasm WASM binaries. This was a preexisting issue in the extension, when we bundled the kernel worker there. Thankfully, the duplicate files are extraneous and can be deleted, which is done using an inline plugin in kernel-browser-runtime.

Many red herrings died in the creation of this PR.

"dist/"
],
"scripts": {
"build": "yarn clean && tsc --project tsconfig.build.json",

@rekmarksrekmarksJun 3, 2025

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts-bridge's CommonJS mode disagrees with Vite's types, so we fall back to tsc. (The main reason we use ts-bridge is to dual-publish our packages as CommonJS and ESM, which is of course not a concern for private packages.)

@rekmarks
rekmarks marked this pull request as ready for review June 3, 2025 01:20
@rekmarks
rekmarks requested a review from a team as a code ownerJune 3, 2025 01:20
Comment on lines +29 to +32
const preludePath = /^import ["']([^"']+)["']/iu.exec(prelude.content)[1];
if (!preludePath) {
throw new Error('No prelude path found in content');
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually use the prelude.content form in this package yet, but the tests Should Just WorkTM if we ever do.

@sirtimidsirtimid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rekmarks
rekmarks merged commit 1559111 into mainJun 3, 2025
@rekmarks
rekmarks deleted the rekm/browser-runtime-iframe branch June 3, 2025 15:51
Sign up for freeto 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.

2 participants

@rekmarks@sirtimid