-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Environment
OS: Windows 11
Node.js: v24.5.0
Package Manager: pnpm
obuild version: 0.2.1
Reproduction
-
Set up a monorepo structure on Windows. (e.g., using pnpm workspaces).
/monorepo /packages /my-lib <-- Package to be stubbed /apps /my-nuxt-app <-- Consuming application
-
Configure
my-lib
to useobuild
for stubbing.packages/my-lib/package.json
:{ "name": "my-lib", "version": "1.0.0", "main": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.mts", "exports": { ".": { "import": "./dist/index.mjs", "types": "./dist/index.d.mts" } }, "scripts": { "dev": "obuild --stub" }, "devDependencies": { "obuild": "latest" } }
packages/my-lib/build.config.ts
:import { defineBuildConfig } from 'obuild/config' export default defineBuildConfig({ entries: [ 'src/index' ], })
packages/my-lib/src/index.ts
:export const message = "Hello from stubbed lib!";
-
Run the stub command from the root of the monorepo.
pnpm --filter my-lib run dev
-
Inspect the generated stub file. The output file
packages/my-lib/dist/index.mjs
will contain an absolute Windows path:// packages/my-lib/dist/index.mjs // ⚠️ PROBLEM: This path is not a valid ESM import on Windows export * from "C:/Users/YourUser/Projects/monorepo/packages/my-lib/src/index.ts";
-
Attempt to use
my-lib
frommy-nuxt-app
. The Nuxt dev server will fail during module resolution.Error Output:
Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' ... code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
Describe the bug
When using obuild
's stub mode (obuild --stub
) within a monorepo workspace on Windows, the generated stub file for a package re-exports the source code using an absolute Windows file path (e.g., C:/...
).
This absolute path is not a valid file://
URL. When another package in the workspace (like a Nuxt or Vite application) tries to import from this stubbed package, Node.js's ESM loader fails with an ERR_UNSUPPORTED_ESM_URL_SCHEME
error because it interprets C:
as an unsupported URL protocol.
This effectively makes stub mode unusable on Windows for local development within a workspace.
Additional context
No response