@teardown/metro-config 2.0.58 → 2.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bun.d.ts CHANGED
@@ -12,10 +12,15 @@ export declare const BUN_BLOCK_PATTERN: RegExp;
12
12
  /**
13
13
  * Create a custom resolver that filters out .bun paths during module resolution.
14
14
  *
15
- * Metro's blockList only prevents processing after resolution, not during.
16
- * This resolver intercepts resolution and redirects away from .bun paths.
15
+ * Note: The primary mechanism for blocking .bun directories is the blockList pattern.
16
+ * This resolver provides an additional layer of protection by finding alternative
17
+ * paths when a resolution from an existing custom resolver points to .bun.
18
+ *
19
+ * @param projectRoot - The project root directory
20
+ * @param existingResolver - Optional existing resolver from the config that should be preserved.
21
+ * If not provided, returns null to signal Metro's default resolution.
17
22
  */
18
- export declare function createBunAwareResolver(projectRoot: string, defaultResolveRequest: ResolveRequestFn): ResolveRequestFn;
23
+ export declare function createBunAwareResolver(projectRoot: string, existingResolver?: ResolveRequestFn): ResolveRequestFn;
19
24
  /**
20
25
  * Get blockList patterns for Metro config.
21
26
  * Includes .bun directory blocking.
package/dist/bun.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../src/bun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAwB,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,GAAG,gBAAgB,CAwBrH;AAmCD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAQ5E"}
1
+ {"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../src/bun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAkCjH;AAmCD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAQ5E"}
package/dist/bun.js CHANGED
@@ -22,16 +22,29 @@ exports.BUN_BLOCK_PATTERN = /.*[/\\]\.bun[/\\].*/;
22
22
  /**
23
23
  * Create a custom resolver that filters out .bun paths during module resolution.
24
24
  *
25
- * Metro's blockList only prevents processing after resolution, not during.
26
- * This resolver intercepts resolution and redirects away from .bun paths.
25
+ * Note: The primary mechanism for blocking .bun directories is the blockList pattern.
26
+ * This resolver provides an additional layer of protection by finding alternative
27
+ * paths when a resolution from an existing custom resolver points to .bun.
28
+ *
29
+ * @param projectRoot - The project root directory
30
+ * @param existingResolver - Optional existing resolver from the config that should be preserved.
31
+ * If not provided, returns null to signal Metro's default resolution.
27
32
  */
28
- function createBunAwareResolver(projectRoot, defaultResolveRequest) {
33
+ function createBunAwareResolver(projectRoot, existingResolver) {
29
34
  const modulesPaths = (0, workspace_1.getModulesPaths)(projectRoot);
35
+ // If no existing resolver, just return a pass-through that defers to Metro's default
36
+ if (!existingResolver) {
37
+ return (_context, _moduleName, _platform) => null;
38
+ }
30
39
  return (context, moduleName, platform) => {
31
- // Use Metro's default resolution
32
- const result = defaultResolveRequest(context, moduleName, platform);
40
+ // Call the existing resolver
41
+ const result = existingResolver(context, moduleName, platform);
42
+ // If no result, defer to Metro's default
43
+ if (!result) {
44
+ return null;
45
+ }
33
46
  // If resolved path contains .bun, try to find alternative
34
- if (result?.filePath?.includes("/.bun/")) {
47
+ if (result.filePath?.includes("/.bun/")) {
35
48
  for (const modulesPath of modulesPaths) {
36
49
  if (modulesPath.includes("/.bun/"))
37
50
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAiB,MAAM,yBAAyB,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAoB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAUnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB,GAAG,WAAW,CA0FjG;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAiB,MAAM,yBAAyB,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAoB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAUnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB,GAAG,WAAW,CAyFjG;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -82,11 +82,11 @@ function withTeardown(config, options = {}) {
82
82
  const existingNodeModulesPaths = config.resolver?.nodeModulesPaths || [];
83
83
  // Get block list with .bun blocking
84
84
  const blockList = (0, bun_1.getBlockList)(config.resolver?.blockList);
85
- // Create resolver chain: tsconfig paths -> bun-aware -> default
86
- const defaultResolveRequest = config.resolver?.resolveRequest ||
87
- ((context, moduleName, platform) => context.resolveRequest(context, moduleName, platform));
88
- // Apply Bun-aware resolver first
89
- const bunAwareResolver = (0, bun_1.createBunAwareResolver)(projectRoot, defaultResolveRequest);
85
+ // Get any existing custom resolver from the config
86
+ const existingResolver = config.resolver?.resolveRequest;
87
+ // Create resolver chain: tsconfig paths -> bun-aware -> existing/default
88
+ // The bun-aware resolver handles .bun path filtering
89
+ const bunAwareResolver = (0, bun_1.createBunAwareResolver)(projectRoot, existingResolver);
90
90
  // Apply tsconfig paths resolver on top (so it runs first)
91
91
  const finalResolver = tsconfigPaths
92
92
  ? (0, tsconfig_paths_1.createTsConfigPathsResolver)(projectRoot, bunAwareResolver, verbose)
@@ -14,6 +14,7 @@ interface PathMapping {
14
14
  }
15
15
  /**
16
16
  * Parse tsconfig.json and extract paths configuration.
17
+ * Properly evaluates the full config including `extends` inheritance.
17
18
  */
18
19
  export declare function parseTsConfigPaths(projectRoot: string): TsConfigPaths | null;
19
20
  /**
@@ -27,7 +28,12 @@ export declare function buildPathMappings(projectRoot: string, config: TsConfigP
27
28
  export declare function resolveWithTsConfigPaths(moduleName: string, mappings: PathMapping[]): string | null;
28
29
  /**
29
30
  * Create a resolver that handles tsconfig paths.
31
+ *
32
+ * @param projectRoot - The project root directory
33
+ * @param nextResolver - Optional next resolver in the chain. If not provided or returns null,
34
+ * Metro will use its default resolution.
35
+ * @param verbose - Whether to log debug information
30
36
  */
31
- export declare function createTsConfigPathsResolver(projectRoot: string, defaultResolveRequest: ResolveRequestFn, verbose?: boolean): ResolveRequestFn;
37
+ export declare function createTsConfigPathsResolver(projectRoot: string, nextResolver?: ResolveRequestFn, verbose?: boolean): ResolveRequestFn;
32
38
  export {};
33
39
  //# sourceMappingURL=tsconfig-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../src/tsconfig-paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,UAAU,aAAa;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACjC;AAED,UAAU,WAAW;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CA0B5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,WAAW,EAAE,CAsB3F;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CA0CnG;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,gBAAgB,EACvC,OAAO,UAAQ,GACb,gBAAgB,CAiClB"}
1
+ {"version":3,"file":"tsconfig-paths.d.ts","sourceRoot":"","sources":["../src/tsconfig-paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,UAAU,aAAa;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACjC;AAED,UAAU,WAAW;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;CACvB;AAoGD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAqB5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,WAAW,EAAE,CAsB3F;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CA0CnG;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAC1C,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,gBAAgB,EAC/B,OAAO,UAAQ,GACb,gBAAgB,CAuClB"}
@@ -15,32 +15,117 @@ exports.createTsConfigPathsResolver = createTsConfigPathsResolver;
15
15
  const node_fs_1 = require("node:fs");
16
16
  const node_path_1 = __importDefault(require("node:path"));
17
17
  /**
18
- * Parse tsconfig.json and extract paths configuration.
18
+ * Try to import TypeScript from the project.
19
19
  */
20
- function parseTsConfigPaths(projectRoot) {
21
- const tsconfigPath = node_path_1.default.join(projectRoot, "tsconfig.json");
22
- if (!(0, node_fs_1.existsSync)(tsconfigPath)) {
20
+ function importTypeScriptFromProjectOptionally(projectRoot) {
21
+ try {
22
+ const tsPath = require.resolve("typescript", { paths: [projectRoot] });
23
+ return require(tsPath);
24
+ }
25
+ catch {
23
26
  return null;
24
27
  }
28
+ }
29
+ /**
30
+ * Evaluate tsconfig.json using TypeScript's parseJsonConfigFileContent.
31
+ * This properly handles `extends` and all inheritance.
32
+ */
33
+ function evaluateTsConfig(ts, configPath) {
34
+ const configDir = node_path_1.default.dirname(configPath);
35
+ const configFileText = ts.sys.readFile(configPath);
36
+ if (!configFileText) {
37
+ return {};
38
+ }
39
+ const result = ts.parseConfigFileTextToJson(configPath, configFileText);
40
+ if (result.error) {
41
+ return {};
42
+ }
43
+ const parsedConfig = ts.parseJsonConfigFileContent(result.config, ts.sys, configDir, undefined, configPath);
44
+ return {
45
+ compilerOptions: {
46
+ baseUrl: parsedConfig.options.baseUrl,
47
+ paths: parsedConfig.options.paths,
48
+ },
49
+ };
50
+ }
51
+ /**
52
+ * Clean JSON5 content (remove comments and trailing commas) for JSON.parse.
53
+ */
54
+ function cleanJsonContent(content) {
55
+ return content
56
+ .replace(/\/\*[\s\S]*?\*\//g, "") // Remove /* */ comments
57
+ .replace(/\/\/.*/g, "") // Remove // comments
58
+ .replace(/,(\s*[}\]])/g, "$1"); // Remove trailing commas
59
+ }
60
+ /**
61
+ * Parse a config file manually (fallback when TypeScript isn't available).
62
+ */
63
+ function parseConfigFileManually(configPath) {
25
64
  try {
26
- const content = (0, node_fs_1.readFileSync)(tsconfigPath, "utf8");
27
- // Remove comments (both // and /* */) and trailing commas for JSON.parse
28
- const cleanedContent = content
29
- .replace(/\/\*[\s\S]*?\*\//g, "") // Remove /* */ comments
30
- .replace(/\/\/.*/g, "") // Remove // comments
31
- .replace(/,(\s*[}\]])/g, "$1"); // Remove trailing commas
32
- const tsconfig = JSON.parse(cleanedContent);
33
- const compilerOptions = tsconfig.compilerOptions || {};
65
+ const content = (0, node_fs_1.readFileSync)(configPath, "utf8");
66
+ const config = JSON.parse(cleanJsonContent(content));
67
+ const compilerOptions = config.compilerOptions || {};
34
68
  return {
35
69
  baseUrl: compilerOptions.baseUrl,
36
70
  paths: compilerOptions.paths,
37
71
  };
38
72
  }
39
73
  catch (error) {
40
- console.warn(`[teardown/metro-config] Failed to parse tsconfig.json: ${error}`);
74
+ console.warn(`[teardown/metro-config] Failed to parse ${node_path_1.default.basename(configPath)}: ${error}`);
41
75
  return null;
42
76
  }
43
77
  }
78
+ /**
79
+ * Normalize baseUrl from TypeScript's absolute path to relative.
80
+ */
81
+ function normalizeBaseUrl(baseUrl, projectRoot) {
82
+ if (!baseUrl)
83
+ return undefined;
84
+ return node_path_1.default.isAbsolute(baseUrl) ? node_path_1.default.relative(projectRoot, baseUrl) : baseUrl;
85
+ }
86
+ /**
87
+ * Try to parse tsconfig using TypeScript for full extends support.
88
+ */
89
+ function parseTsConfigWithTypeScript(projectRoot, configPath) {
90
+ const ts = importTypeScriptFromProjectOptionally(projectRoot);
91
+ if (!ts)
92
+ return null;
93
+ try {
94
+ const config = evaluateTsConfig(ts, configPath);
95
+ return {
96
+ baseUrl: normalizeBaseUrl(config.compilerOptions?.baseUrl, projectRoot),
97
+ paths: config.compilerOptions?.paths,
98
+ };
99
+ }
100
+ catch (error) {
101
+ console.warn(`[teardown/metro-config] Failed to evaluate tsconfig with TypeScript: ${error}`);
102
+ return null;
103
+ }
104
+ }
105
+ /**
106
+ * Parse tsconfig.json and extract paths configuration.
107
+ * Properly evaluates the full config including `extends` inheritance.
108
+ */
109
+ function parseTsConfigPaths(projectRoot) {
110
+ const tsconfigPath = node_path_1.default.join(projectRoot, "tsconfig.json");
111
+ const jsconfigPath = node_path_1.default.join(projectRoot, "jsconfig.json");
112
+ // Try tsconfig.json first
113
+ if ((0, node_fs_1.existsSync)(tsconfigPath)) {
114
+ // Try TypeScript evaluation first (handles extends)
115
+ const tsResult = parseTsConfigWithTypeScript(projectRoot, tsconfigPath);
116
+ if (tsResult)
117
+ return tsResult;
118
+ // Fallback to manual parsing
119
+ const manualResult = parseConfigFileManually(tsconfigPath);
120
+ if (manualResult)
121
+ return manualResult;
122
+ }
123
+ // Try jsconfig.json as fallback
124
+ if ((0, node_fs_1.existsSync)(jsconfigPath)) {
125
+ return parseConfigFileManually(jsconfigPath);
126
+ }
127
+ return null;
128
+ }
44
129
  /**
45
130
  * Convert tsconfig paths to regex patterns for efficient matching.
46
131
  */
@@ -108,14 +193,20 @@ function resolveWithTsConfigPaths(moduleName, mappings) {
108
193
  }
109
194
  /**
110
195
  * Create a resolver that handles tsconfig paths.
196
+ *
197
+ * @param projectRoot - The project root directory
198
+ * @param nextResolver - Optional next resolver in the chain. If not provided or returns null,
199
+ * Metro will use its default resolution.
200
+ * @param verbose - Whether to log debug information
111
201
  */
112
- function createTsConfigPathsResolver(projectRoot, defaultResolveRequest, verbose = false) {
202
+ function createTsConfigPathsResolver(projectRoot, nextResolver, verbose = false) {
113
203
  const config = parseTsConfigPaths(projectRoot);
114
204
  if (!config?.paths) {
115
205
  if (verbose) {
116
206
  console.log("[teardown/metro-config] No tsconfig paths found, skipping path resolution");
117
207
  }
118
- return defaultResolveRequest;
208
+ // Return null to signal Metro should use default resolution
209
+ return nextResolver ?? ((_context, _moduleName, _platform) => null);
119
210
  }
120
211
  const mappings = buildPathMappings(projectRoot, config);
121
212
  if (verbose) {
@@ -133,7 +224,11 @@ function createTsConfigPathsResolver(projectRoot, defaultResolveRequest, verbose
133
224
  }
134
225
  return { type: "sourceFile", filePath: resolvedPath };
135
226
  }
136
- // Fall back to default resolution
137
- return defaultResolveRequest(context, moduleName, platform);
227
+ // Fall back to next resolver in chain, or return null for Metro's default
228
+ if (nextResolver) {
229
+ return nextResolver(context, moduleName, platform);
230
+ }
231
+ // Return null to signal Metro should use its default resolution
232
+ return null;
138
233
  };
139
234
  }
@@ -50,11 +50,15 @@ export declare function getMetroServerRoot(projectRoot: string): string;
50
50
  */
51
51
  export declare function getWatchFolders(projectRoot: string): string[];
52
52
  /**
53
- * Get node module paths for Metro resolver in a monorepo setup.
53
+ * Get node module paths for Metro resolver.
54
54
  *
55
55
  * Returns paths in priority order:
56
- * 1. Project's local node_modules
56
+ * 1. Project's local node_modules (always included)
57
57
  * 2. Workspace root node_modules (if in monorepo)
58
+ *
59
+ * The project's node_modules must always be included to support packages
60
+ * that publish TypeScript source and need to resolve peer dependencies
61
+ * (e.g., react-native) from deeply nested paths.
58
62
  */
59
63
  export declare function getModulesPaths(projectRoot: string): string[];
60
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0BH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjG;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAY5D;AAiCD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAM9D;AASD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAe7D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAa7D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMlE"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0BH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjG;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAY5D;AAiCD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAM9D;AASD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAe7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAa7D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMlE"}
package/dist/workspace.js CHANGED
@@ -197,19 +197,23 @@ function getWatchFolders(projectRoot) {
197
197
  return uniqueItems([node_path_1.default.join(workspaceRoot, "node_modules"), ...packages.map((pkg) => node_path_1.default.dirname(pkg))]);
198
198
  }
199
199
  /**
200
- * Get node module paths for Metro resolver in a monorepo setup.
200
+ * Get node module paths for Metro resolver.
201
201
  *
202
202
  * Returns paths in priority order:
203
- * 1. Project's local node_modules
203
+ * 1. Project's local node_modules (always included)
204
204
  * 2. Workspace root node_modules (if in monorepo)
205
+ *
206
+ * The project's node_modules must always be included to support packages
207
+ * that publish TypeScript source and need to resolve peer dependencies
208
+ * (e.g., react-native) from deeply nested paths.
205
209
  */
206
210
  function getModulesPaths(projectRoot) {
207
- const paths = [];
208
- // Only add paths if in a monorepo - minimizes chance of Metro resolver breaking
209
211
  const resolvedProjectRoot = node_path_1.default.resolve(projectRoot);
210
212
  const workspaceRoot = getMetroServerRoot(resolvedProjectRoot);
213
+ // Always include project's node_modules for proper peer dependency resolution
214
+ const paths = [node_path_1.default.resolve(projectRoot, "node_modules")];
215
+ // Add workspace root node_modules if in a monorepo
211
216
  if (workspaceRoot !== resolvedProjectRoot) {
212
- paths.push(node_path_1.default.resolve(projectRoot, "node_modules"));
213
217
  paths.push(node_path_1.default.resolve(workspaceRoot, "node_modules"));
214
218
  }
215
219
  return paths;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/metro-config",
3
- "version": "2.0.58",
3
+ "version": "2.0.60",
4
4
  "description": "Metro configuration for Teardown - Rust-powered transforms via Facetpack",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -45,7 +45,7 @@
45
45
  "resolve-workspace-root": "^2.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@teardown/tsconfig": "2.0.58",
48
+ "@teardown/tsconfig": "2.0.60",
49
49
  "@types/bun": "1.3.5",
50
50
  "typescript": "5.9.3"
51
51
  },