Repository navigation
fix(md): run client scripts in builds without an .island. file - #681
Merged
Merged
Conversation
The Markdown client entry joined the client build only when a file with `.island.` in its name existed under `pages/`. Without one, a page's client script ran in dev but not after a production build, even when the page imported an island. Add the entry when a page the build keeps has client code, using the same file list and script extraction as the Markdown page scan. A script with only island imports, a `<script>` in a code block and a `.dev` page no longer count. The old check also matched these, so an app with a `.island.` file could build an empty entry that its pages with JavaScript loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8F8maan2SAVMkNT2gaiUH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A client script in a Markdown page ran in dev but not after a production build, unless a file with
.island.in its name existed underpages/. Without one,dist/client/.vite/manifest.jsonhad novirtual:void-md-cliententry, so the script never loaded.The
confighook invoidMarkdown()added that entry only whenhasMdFilesWithScript(pagesDir) && hasIslandFiles(pagesDir)was true.hasIslandFilesonly read file names underpages/, so:.island.file outsidepages/did not count.pages/_x.island.txt.Fix
The entry is now added when a page that the build keeps has client code. The check uses the same file list and
extractScript()asscanMdPages(), so it agrees with what the entry loads.This also replaces the
/^<script\b/mcheck. It matched a script with only island imports, a<script>in a code block and a.devpage, none of which has client code in a build. With a.island.file present, those apps built a 0-bytemd-clientchunk that their pages with JavaScript loaded. They now get no entry.The guide already describes this behavior, so the docs do not change.
Tests
packages/md/test/integration/client-script-build.test.ts(new): builds a React app with no.island.file underpages/and opens it in Chromium. A script-only page and a page that also imports an island both run their scripts, the island responds to a click, and a page without client code ships no<script>. Onmainit fails because the manifest has novirtual:void-md-client.packages/md/test/unit/plugin-source-dir.test.ts: covers which pages add the entry. Four cases fail onmain, and four fail if onlyhasIslandFilesis removed.Verification
vp test run: 765 files pass, 1 skipped (15,607 tests pass, 29 skipped).vp run check: 33/33 pass.vp build,vp preview(Cloudflare target) and Chromium: client scripts run, and an app without client code gets nomd-cliententry. Svelte and Solid used an absolute island import because of the first issue below, and the Solid island did not respond because of the second.