From bea524c3e9c411b0988754f7aed9927fc4c3535d Mon Sep 17 00:00:00 2001 From: Kallinikos Milonakis Date: Wed, 2 Sep 2026 13:42:25 +0300 Subject: [PATCH] fix(init): use posix separators for the paths written into package.json `bob init` builds the values for `main`, `module`, `types` and `exports` by interpolating `path.join` into a `./...` string. On Windows that yields backslashes, so a freshly initialised library gets: "main": "./lib\module\index.js", "exports": { ".": { "default": "./lib\module\index.js" } } Those fields are module specifiers rather than filesystem paths and are always forward-slashed, so the manifest is wrong and `exports` in particular will not resolve. Join them with `path.posix` instead. The committed snapshot in init.test.ts already encodes the correct forward-slash output and now matches on Windows without being regenerated. --- packages/react-native-builder-bob/src/init.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/react-native-builder-bob/src/init.ts b/packages/react-native-builder-bob/src/init.ts index fe363f78d..934698b72 100644 --- a/packages/react-native-builder-bob/src/init.ts +++ b/packages/react-native-builder-bob/src/init.ts @@ -149,6 +149,9 @@ export async function init() { ? targets[0] : undefined; + // These end up in `main`, `module`, `types` and `exports` in package.json, + // which are specifiers rather than filesystem paths and always use forward + // slashes, so they are joined with `path.posix` regardless of platform. const entries: { [key in 'commonjs' | 'module']?: string; } = {}; @@ -157,11 +160,11 @@ export async function init() { if (targets.includes('module')) { esm = true; - entries.module = `./${path.join(output, 'module', 'index.js')}`; + entries.module = `./${path.posix.join(output, 'module', 'index.js')}`; } if (targets.includes('commonjs')) { - entries.commonjs = `./${path.join(output, 'commonjs', 'index.js')}`; + entries.commonjs = `./${path.posix.join(output, 'commonjs', 'index.js')}`; } const types: { @@ -170,7 +173,7 @@ export async function init() { if (targets.includes('typescript')) { if (targets.includes('commonjs') && targets.includes('module')) { - types.require = `./${path.join( + types.require = `./${path.posix.join( output, 'typescript', 'commonjs', @@ -178,7 +181,7 @@ export async function init() { 'index.d.ts' )}`; - types.import = `./${path.join( + types.import = `./${path.posix.join( output, 'typescript', 'module', @@ -186,7 +189,7 @@ export async function init() { 'index.d.ts' )}`; } else { - types.require = `./${path.join( + types.require = `./${path.posix.join( output, 'typescript', source,