@teardown/metro-config 2.0.59 → 2.0.61
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 +11 -3
- package/dist/bun.d.ts.map +1 -1
- package/dist/bun.js +25 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/tsconfig-paths.d.ts +9 -1
- package/dist/tsconfig-paths.d.ts.map +1 -1
- package/dist/tsconfig-paths.js +19 -4
- package/dist/workspace.d.ts +6 -2
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +9 -5
- package/package.json +2 -2
package/dist/bun.d.ts
CHANGED
|
@@ -12,10 +12,18 @@ 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
|
-
*
|
|
16
|
-
* This resolver
|
|
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
|
+
* IMPORTANT: This resolver must always return a resolution result (not null) because
|
|
20
|
+
* it may be wrapped by other resolvers (like uniwind) that don't handle null.
|
|
21
|
+
* When we want Metro's default resolution, we call context.resolveRequest.
|
|
22
|
+
*
|
|
23
|
+
* @param projectRoot - The project root directory
|
|
24
|
+
* @param existingResolver - Optional existing resolver from the config that should be preserved.
|
|
17
25
|
*/
|
|
18
|
-
export declare function createBunAwareResolver(projectRoot: string,
|
|
26
|
+
export declare function createBunAwareResolver(projectRoot: string, existingResolver?: ResolveRequestFn): ResolveRequestFn;
|
|
19
27
|
/**
|
|
20
28
|
* Get blockList patterns for Metro config.
|
|
21
29
|
* 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
|
|
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;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAsCjH;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,35 @@ exports.BUN_BLOCK_PATTERN = /.*[/\\]\.bun[/\\].*/;
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a custom resolver that filters out .bun paths during module resolution.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
* This resolver
|
|
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
|
+
* IMPORTANT: This resolver must always return a resolution result (not null) because
|
|
30
|
+
* it may be wrapped by other resolvers (like uniwind) that don't handle null.
|
|
31
|
+
* When we want Metro's default resolution, we call context.resolveRequest.
|
|
32
|
+
*
|
|
33
|
+
* @param projectRoot - The project root directory
|
|
34
|
+
* @param existingResolver - Optional existing resolver from the config that should be preserved.
|
|
27
35
|
*/
|
|
28
|
-
function createBunAwareResolver(projectRoot,
|
|
36
|
+
function createBunAwareResolver(projectRoot, existingResolver) {
|
|
29
37
|
const modulesPaths = (0, workspace_1.getModulesPaths)(projectRoot);
|
|
30
38
|
return (context, moduleName, platform) => {
|
|
31
|
-
//
|
|
32
|
-
|
|
39
|
+
// If there's an existing resolver, try it first
|
|
40
|
+
let result = null;
|
|
41
|
+
if (existingResolver) {
|
|
42
|
+
result = existingResolver(context, moduleName, platform);
|
|
43
|
+
}
|
|
44
|
+
// If no result from existing resolver, use Metro's default via context
|
|
45
|
+
if (!result) {
|
|
46
|
+
result = context.resolveRequest(context, moduleName, platform);
|
|
47
|
+
}
|
|
48
|
+
// If still no result, return null (shouldn't happen but be safe)
|
|
49
|
+
if (!result) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
33
52
|
// If resolved path contains .bun, try to find alternative
|
|
34
|
-
if (result
|
|
53
|
+
if (result.filePath?.includes("/.bun/")) {
|
|
35
54
|
for (const modulesPath of modulesPaths) {
|
|
36
55
|
if (modulesPath.includes("/.bun/"))
|
|
37
56
|
continue;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
-
//
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
const bunAwareResolver = (0, bun_1.createBunAwareResolver)(projectRoot,
|
|
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)
|
package/dist/tsconfig-paths.d.ts
CHANGED
|
@@ -28,7 +28,15 @@ export declare function buildPathMappings(projectRoot: string, config: TsConfigP
|
|
|
28
28
|
export declare function resolveWithTsConfigPaths(moduleName: string, mappings: PathMapping[]): string | null;
|
|
29
29
|
/**
|
|
30
30
|
* Create a resolver that handles tsconfig paths.
|
|
31
|
+
*
|
|
32
|
+
* IMPORTANT: This resolver must always return a resolution result (not null) because
|
|
33
|
+
* it may be wrapped by other resolvers (like uniwind) that don't handle null.
|
|
34
|
+
* When we want Metro's default resolution, we call context.resolveRequest.
|
|
35
|
+
*
|
|
36
|
+
* @param projectRoot - The project root directory
|
|
37
|
+
* @param nextResolver - Optional next resolver in the chain.
|
|
38
|
+
* @param verbose - Whether to log debug information
|
|
31
39
|
*/
|
|
32
|
-
export declare function createTsConfigPathsResolver(projectRoot: string,
|
|
40
|
+
export declare function createTsConfigPathsResolver(projectRoot: string, nextResolver?: ResolveRequestFn, verbose?: boolean): ResolveRequestFn;
|
|
33
41
|
export {};
|
|
34
42
|
//# 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;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
|
|
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;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAC1C,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,gBAAgB,EAC/B,OAAO,UAAQ,GACb,gBAAgB,CAwClB"}
|
package/dist/tsconfig-paths.js
CHANGED
|
@@ -193,14 +193,23 @@ function resolveWithTsConfigPaths(moduleName, mappings) {
|
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
195
|
* Create a resolver that handles tsconfig paths.
|
|
196
|
+
*
|
|
197
|
+
* IMPORTANT: This resolver must always return a resolution result (not null) because
|
|
198
|
+
* it may be wrapped by other resolvers (like uniwind) that don't handle null.
|
|
199
|
+
* When we want Metro's default resolution, we call context.resolveRequest.
|
|
200
|
+
*
|
|
201
|
+
* @param projectRoot - The project root directory
|
|
202
|
+
* @param nextResolver - Optional next resolver in the chain.
|
|
203
|
+
* @param verbose - Whether to log debug information
|
|
196
204
|
*/
|
|
197
|
-
function createTsConfigPathsResolver(projectRoot,
|
|
205
|
+
function createTsConfigPathsResolver(projectRoot, nextResolver, verbose = false) {
|
|
198
206
|
const config = parseTsConfigPaths(projectRoot);
|
|
199
207
|
if (!config?.paths) {
|
|
200
208
|
if (verbose) {
|
|
201
209
|
console.log("[teardown/metro-config] No tsconfig paths found, skipping path resolution");
|
|
202
210
|
}
|
|
203
|
-
|
|
211
|
+
// Pass through to next resolver or Metro's default
|
|
212
|
+
return nextResolver ?? ((context, moduleName, platform) => context.resolveRequest(context, moduleName, platform));
|
|
204
213
|
}
|
|
205
214
|
const mappings = buildPathMappings(projectRoot, config);
|
|
206
215
|
if (verbose) {
|
|
@@ -218,7 +227,13 @@ function createTsConfigPathsResolver(projectRoot, defaultResolveRequest, verbose
|
|
|
218
227
|
}
|
|
219
228
|
return { type: "sourceFile", filePath: resolvedPath };
|
|
220
229
|
}
|
|
221
|
-
// Fall back to
|
|
222
|
-
|
|
230
|
+
// Fall back to next resolver in chain
|
|
231
|
+
if (nextResolver) {
|
|
232
|
+
const result = nextResolver(context, moduleName, platform);
|
|
233
|
+
if (result)
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
// Use Metro's default resolution via context
|
|
237
|
+
return context.resolveRequest(context, moduleName, platform);
|
|
223
238
|
};
|
|
224
239
|
}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -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
|
|
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
|
/**
|
package/dist/workspace.d.ts.map
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
3
|
+
"version": "2.0.61",
|
|
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.
|
|
48
|
+
"@teardown/tsconfig": "2.0.61",
|
|
49
49
|
"@types/bun": "1.3.5",
|
|
50
50
|
"typescript": "5.9.3"
|
|
51
51
|
},
|