[GH-ISSUE #796] Bun preload plugin fails on Windows due to forward-slash-only regex and missing solid-js/web rule #987

Open
opened 2026-03-14 09:12:19 +03:00 by kerem · 0 comments
Owner

Originally created by @counter2015 on GitHub (Mar 9, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/796

Description

The Bun preload plugin in @opentui/solid/scripts/solid-plugin.ts fails silently on Windows, causing solid-js to load its
server-side rendering (SSR) modules instead of the client-side ones. This results in runtime errors when rendering.

I try to run this locally, and find some problem, Claude Code help me to fix it by change local code, but I'm not familiar with ts and this project, need some help from mantainers to check whether this fix is right or not.

Here is the changed code and analysis from Claude Code.

Image

Root Cause

Two issues in solid-plugin.ts:

1. Regex filters only match forward slashes

The onLoad filters use forward slashes to match paths:

build.onLoad({ filter: /\/node_modules\/solid-js\/dist\/server\.js$/ }, ...)
build.onLoad({ filter: /\/node_modules\/solid-js\/store\/dist\/server\.js$/ }, ...)

On Windows, Bun resolves module paths with backslashes (e.g. D:\project\node_modules\solid-js\dist\server.js), so these regex patterns
never match and the redirect silently fails.

2. Missing rule for solid-js/web/dist/server.js

The plugin redirects solid-js/dist/server.js → solid.js and solid-js/store/dist/server.js → store.js, but there is no rule for
solid-js/web/dist/server.js → web.js.

Since solid-js/web/package.json maps the "node" export condition to dist/server.js, Bun (which matches "node" by default) loads the
SSR version of solid-js/web, leading to errors like:

at render (node_modules/@opentui/solid/index.js:357:17)

Suggested Fix

Use [/\] in regex filters to match both path separators, and add the missing solid-js/web rule:

  build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]dist[\/\\]server\.js$/ }, async (args) => {
    const path = args.path.replace("server.js", "solid.js")
    return { contents: await Bun.file(path).text(), loader: "js" }
  })
  build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]store[\/\\]dist[\/\\]server\.js$/ }, async (args) => {
    const path = args.path.replace("server.js", "store.js")
    return { contents: await Bun.file(path).text(), loader: "js" }
  })
  build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]web[\/\\]dist[\/\\]server\.js$/ }, async (args) => {
    const path = args.path.replace("server.js", "web.js")
    return { contents: await Bun.file(path).text(), loader: "js" }
  })

Environment

  • OS: Windows 11
  • Bun: 1.2.x
  • @opentui/solid: 0.1.76 (also verified unfixed in 0.1.86)
Originally created by @counter2015 on GitHub (Mar 9, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/796 ## Description The Bun preload plugin in `@opentui/solid/scripts/solid-plugin.ts` fails silently on Windows, causing solid-js to load its **server-side rendering (SSR) modules** instead of the client-side ones. This results in runtime errors when rendering. I try to run this locally, and find some problem, Claude Code help me to fix it by change local code, but I'm not familiar with ts and this project, need some help from mantainers to check whether this fix is right or not. Here is the changed code and analysis from Claude Code. <img width="1849" height="853" alt="Image" src="https://github.com/user-attachments/assets/cf39c833-e675-4434-ae7d-23d539b9f740" /> ## Root Cause Two issues in `solid-plugin.ts`: ### 1. Regex filters only match forward slashes The `onLoad` filters use forward slashes to match paths: ```ts build.onLoad({ filter: /\/node_modules\/solid-js\/dist\/server\.js$/ }, ...) build.onLoad({ filter: /\/node_modules\/solid-js\/store\/dist\/server\.js$/ }, ...) ``` On Windows, Bun resolves module paths with backslashes (e.g. D:\project\node_modules\solid-js\dist\server.js), so these regex patterns never match and the redirect silently fails. ### 2. Missing rule for solid-js/web/dist/server.js The plugin redirects solid-js/dist/server.js → solid.js and solid-js/store/dist/server.js → store.js, but there is no rule for solid-js/web/dist/server.js → web.js. Since solid-js/web/package.json maps the "node" export condition to dist/server.js, Bun (which matches "node" by default) loads the SSR version of solid-js/web, leading to errors like: at render (node_modules/@opentui/solid/index.js:357:17) Suggested Fix Use [\/\\] in regex filters to match both path separators, and add the missing solid-js/web rule: ```ts build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]dist[\/\\]server\.js$/ }, async (args) => { const path = args.path.replace("server.js", "solid.js") return { contents: await Bun.file(path).text(), loader: "js" } }) build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]store[\/\\]dist[\/\\]server\.js$/ }, async (args) => { const path = args.path.replace("server.js", "store.js") return { contents: await Bun.file(path).text(), loader: "js" } }) build.onLoad({ filter: /[\/\\]node_modules[\/\\]solid-js[\/\\]web[\/\\]dist[\/\\]server\.js$/ }, async (args) => { const path = args.path.replace("server.js", "web.js") return { contents: await Bun.file(path).text(), loader: "js" } }) ``` Environment - OS: Windows 11 - Bun: 1.2.x - @opentui/solid: 0.1.76 (also verified unfixed in 0.1.86)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#987
No description provided.