Skip to content

Commit f3417b4

Browse files
authored
fix(expo): Preserve relative imports for Metro in tsdown builds (#8880)
1 parent a938d74 commit f3417b4

4 files changed

Lines changed: 13 additions & 174 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/expo': patch
3+
---
4+
5+
Preserve Expo's relative import specifiers in tsdown builds so Metro platform-specific module resolution and root exports work correctly.

packages/expo/scripts/__tests__/preservePlatformSpecifiers.test.ts

Lines changed: 0 additions & 110 deletions
This file was deleted.

packages/expo/scripts/preservePlatformSpecifiers.mts

Lines changed: 0 additions & 62 deletions
This file was deleted.

packages/expo/tsdown.config.mts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { defineConfig } from 'tsdown';
44
import { runAfterLast } from '../../scripts/utils.ts';
55
import clerkJsPkgJson from '../clerk-js/package.json' with { type: 'json' };
66
import pkgJson from './package.json' with { type: 'json' };
7-
import { preservePlatformSpecifiers } from './scripts/preservePlatformSpecifiers.mts';
7+
8+
function preserveRelativeImports(id: string) {
9+
return id.startsWith('.');
10+
}
811

912
export default defineConfig(overrideOptions => {
1013
const isWatch = !!overrideOptions.watch;
@@ -19,13 +22,16 @@ export default defineConfig(overrideOptions => {
1922
clean: true,
2023
minify: false,
2124
sourcemap: true,
25+
deps: {
26+
// Keep relative import specifiers unchanged so Metro can apply platform-specific resolution.
27+
neverBundle: preserveRelativeImports,
28+
},
2229
define: {
2330
PACKAGE_NAME: `"${pkgJson.name}"`,
2431
PACKAGE_VERSION: `"${pkgJson.version}"`,
2532
JS_PACKAGE_VERSION: `"${clerkJsPkgJson.version}"`,
2633
__DEV__: `${isWatch}`,
2734
},
28-
plugins: [preservePlatformSpecifiers()],
2935
};
3036

3137
return runAfterLast(['pnpm build:declarations', shouldPublish && 'pkglab pub --ping'])(options);

0 commit comments

Comments
 (0)