vitest-native 0.9.0 → 0.11.0

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +921 -0
  2. package/README.md +33 -1
  3. package/dist/cli.cjs +185 -31
  4. package/dist/cli.mjs +182 -28
  5. package/dist/ecosystem-BJzJU3Cf.cjs +568 -0
  6. package/dist/ecosystem-C4qT_vl3.mjs +506 -0
  7. package/dist/errors-B3lJK46O.cjs +75 -0
  8. package/dist/errors-CxoBUfVJ.mjs +64 -0
  9. package/dist/errors.d.mts +46 -0
  10. package/dist/errors.mjs +78 -0
  11. package/dist/helpers.cjs +6 -23
  12. package/dist/helpers.d.cts +0 -6
  13. package/dist/helpers.d.mts +0 -6
  14. package/dist/helpers.mjs +6 -23
  15. package/dist/{index-CEgRDdhd.d.cts → index-CrMeE8rd.d.mts} +14 -9
  16. package/dist/{index-j-0tueBr.d.mts → index-DIMbjH8R.d.cts} +15 -7
  17. package/dist/index.d.mts +8 -7
  18. package/dist/index.mjs +307 -91
  19. package/dist/jest-compat/interop.mjs +15 -0
  20. package/dist/jest-compat/setup.mjs +102 -7
  21. package/dist/jest-compat.cjs +4 -4
  22. package/dist/jest-compat.d.cts +0 -1
  23. package/dist/jest-compat.d.mts +0 -1
  24. package/dist/jest-compat.mjs +2 -2
  25. package/dist/matchers.cjs +16 -7
  26. package/dist/matchers.mjs +16 -7
  27. package/dist/native/hooks.mjs +152 -13
  28. package/dist/native/loader.mjs +36 -11
  29. package/dist/native/match.d.mts +33 -0
  30. package/dist/native/match.mjs +94 -22
  31. package/dist/native/module-reset.mjs +63 -0
  32. package/dist/native/registry.mjs +110 -13
  33. package/dist/native/resolve.d.mts +22 -0
  34. package/dist/native/resolve.mjs +21 -13
  35. package/dist/native/runner.mjs +21 -0
  36. package/dist/native/setup.mjs +4 -2
  37. package/dist/native/transform.mjs +108 -3
  38. package/dist/native/worker.mjs +59 -16
  39. package/dist/{pool-DzsEo9vv.cjs → pool-BU-1ecIF.cjs} +7 -6
  40. package/dist/{pool-CJmjRgsB.mjs → pool-Bcxn9a3I.mjs} +4 -3
  41. package/dist/{preset-map-CG4FMtsl.cjs → preset-map-BoG19dLa.cjs} +1 -1
  42. package/dist/{preset-map-CNsZKfvu.mjs → preset-map-DuX0ocdn.mjs} +1 -1
  43. package/dist/{presets-C4faM3ds.cjs → presets-CwO_c4aL.cjs} +224 -55
  44. package/dist/{presets-CuDrNA_W.mjs → presets-IStcJEOa.mjs} +216 -53
  45. package/dist/presets.d.mts +2 -2
  46. package/dist/presets.mjs +2 -2
  47. package/dist/rntl-matchers.d.ts +35 -0
  48. package/dist/{chunk-CjcI7cDX.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
  49. package/dist/{chunk-CZWwpsFl.cjs → rolldown-runtime-C0BPl7ul.cjs} +1 -1
  50. package/dist/serializer.cjs +34 -4
  51. package/dist/serializer.mjs +34 -4
  52. package/dist/setup.d.mts +1 -1
  53. package/dist/setup.mjs +237 -74
  54. package/docs/release-readiness.md +22 -5
  55. package/docs/versioning.md +133 -0
  56. package/package.json +38 -46
  57. package/dist/ecosystem-BIWaVwYL.cjs +0 -294
  58. package/dist/ecosystem-EFtHnKS9.mjs +0 -256
  59. package/dist/index.cjs +0 -788
  60. package/dist/index.d.cts +0 -14
  61. package/dist/presets.cjs +0 -18
  62. package/dist/presets.d.cts +0 -2
  63. package/dist/setup.cjs +0 -2702
  64. package/dist/setup.d.cts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-native",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "description": "Run real React Native tests under Vitest. One install, zero config.",
6
6
  "license": "MIT",
@@ -24,19 +24,13 @@
24
24
  "expo",
25
25
  "react"
26
26
  ],
27
- "main": "./dist/index.cjs",
27
+ "main": "./dist/index.mjs",
28
28
  "module": "./dist/index.mjs",
29
29
  "types": "./dist/index.d.mts",
30
30
  "exports": {
31
31
  ".": {
32
- "import": {
33
- "types": "./dist/index.d.mts",
34
- "default": "./dist/index.mjs"
35
- },
36
- "require": {
37
- "types": "./dist/index.d.cts",
38
- "default": "./dist/index.cjs"
39
- }
32
+ "types": "./dist/index.d.mts",
33
+ "default": "./dist/index.mjs"
40
34
  },
41
35
  "./helpers": {
42
36
  "import": {
@@ -49,14 +43,8 @@
49
43
  }
50
44
  },
51
45
  "./setup": {
52
- "import": {
53
- "types": "./dist/setup.d.mts",
54
- "default": "./dist/setup.mjs"
55
- },
56
- "require": {
57
- "types": "./dist/setup.d.cts",
58
- "default": "./dist/setup.cjs"
59
- }
46
+ "types": "./dist/setup.d.mts",
47
+ "default": "./dist/setup.mjs"
60
48
  },
61
49
  "./serializer": {
62
50
  "import": {
@@ -69,14 +57,8 @@
69
57
  }
70
58
  },
71
59
  "./presets": {
72
- "import": {
73
- "types": "./dist/presets.d.mts",
74
- "default": "./dist/presets.mjs"
75
- },
76
- "require": {
77
- "types": "./dist/presets.d.cts",
78
- "default": "./dist/presets.cjs"
79
- }
60
+ "types": "./dist/presets.d.mts",
61
+ "default": "./dist/presets.mjs"
80
62
  },
81
63
  "./matchers": {
82
64
  "import": {
@@ -109,6 +91,9 @@
109
91
  "./jest-compat/extend-expect-noop": {
110
92
  "types": "./dist/jest-compat/noop.d.mts",
111
93
  "import": "./dist/jest-compat/noop.mjs"
94
+ },
95
+ "./rntl-matchers": {
96
+ "types": "./dist/rntl-matchers.d.ts"
112
97
  }
113
98
  },
114
99
  "files": [
@@ -118,10 +103,9 @@
118
103
  "CHANGELOG.md"
119
104
  ],
120
105
  "engines": {
121
- "node": ">=20"
106
+ "node": ">=20.19.0"
122
107
  },
123
108
  "sideEffects": [
124
- "./dist/setup.cjs",
125
109
  "./dist/setup.mjs",
126
110
  "./dist/jest-compat/setup.mjs",
127
111
  "./dist/native/*.mjs"
@@ -151,45 +135,52 @@
151
135
  "devDependencies": {
152
136
  "@babel/core": "^7.29.7",
153
137
  "@gorhom/bottom-sheet": "5.2.14",
138
+ "@react-native-community/netinfo": "12.0.1",
154
139
  "@react-native-vector-icons/common": "13.0.1",
155
140
  "@react-native-vector-icons/material-icons": "13.1.2",
156
- "@react-native/babel-preset": "^0.85.3",
157
- "@react-navigation/native": "7.2.5",
158
- "@react-navigation/native-stack": "7.16.0",
141
+ "@react-native/babel-preset": "^0.86.2",
142
+ "@react-navigation/native": "7.3.14",
143
+ "@react-navigation/native-stack": "7.18.6",
159
144
  "@shopify/flash-list": "2.3.2",
160
145
  "@testing-library/react-native": "14.0.0",
161
146
  "@types/node": "25.3.5",
162
- "@types/react": "19.2.14",
163
- "@vitest/coverage-v8": "4.1.8",
147
+ "@types/react": "19.2.18",
148
+ "@vitest/coverage-v8": "4.1.10",
164
149
  "expo-constants": "56.0.16",
165
150
  "expo-status-bar": "56.0.4",
166
151
  "ext-platform-lib": "file:./tests-native/fixtures/ext-platform-lib",
167
152
  "ext-rn-named-lib": "file:./tests-native/fixtures/ext-rn-named-lib",
168
153
  "generic-mainfield-lib": "file:./tests-native/fixtures/generic-mainfield-lib",
169
- "react": "^19.2.3",
154
+ "react": "^19.2.8",
170
155
  "react-native": "^0.86.0",
171
- "react-native-gesture-handler": "3.0.0",
172
- "react-native-keyboard-controller": "1.21.11",
173
- "react-native-reanimated": "4.3.1",
156
+ "react-native-gesture-handler": "3.1.0",
157
+ "react-native-keyboard-controller": "1.22.2",
158
+ "react-native-reanimated": "4.5.3",
174
159
  "react-native-safe-area-context": "5.8.0",
175
- "react-native-worklets": "0.9.1",
176
- "react-test-renderer": "^19.2.3",
160
+ "react-native-worklets": "0.11.3",
161
+ "react-test-renderer": "^19.2.8",
162
+ "resident-singleton": "file:./tests-native/fixtures/resident-singleton",
163
+ "rn-condition-cjs-lib": "file:./tests-native/fixtures/rn-condition-cjs-lib",
177
164
  "rn-condition-lib": "file:./tests-native/fixtures/rn-condition-lib",
178
165
  "rn-ecosystem-lib": "file:./tests-native/fixtures/rn-ecosystem-lib",
179
166
  "rn-mainfield-lib": "file:./tests-native/fixtures/rn-mainfield-lib",
167
+ "rn-platform-flow-lib": "file:./tests-native/fixtures/rn-platform-flow-lib",
168
+ "rn-singleton-lib": "file:./tests-native/fixtures/rn-singleton-lib",
180
169
  "test-renderer": "^1.2.0",
181
- "tsdown": "0.21.10",
170
+ "tsdown": "0.22.14",
182
171
  "typescript": "6.0.3",
183
172
  "untranspiled-jsx-lib": "file:./tests-native/fixtures/untranspiled-jsx-lib",
184
- "vite": "^8.0.5",
185
- "vitest": "^4.1.8"
173
+ "vite": "^8.2.0",
174
+ "vitest": "4.1.10"
186
175
  },
187
176
  "scripts": {
188
- "build": "tsdown",
177
+ "build": "bunx --bun tsdown && node scripts/copy-static-types.mjs",
189
178
  "test": "vitest run",
190
179
  "test:native": "vitest run --config tests-native/vitest.config.mts",
180
+ "test:native:forks": "vitest run --config tests-native/vitest.forks.config.mts",
191
181
  "test:native:navigation": "vitest run --config tests-native/vitest.navigation.config.mts",
192
182
  "test:native:android": "vitest run --config tests-native/vitest.android.config.mts",
183
+ "test:native:advice": "vitest run --config tests-native/vitest.advice.config.mts",
193
184
  "test:native:hot": "vitest run --config tests-native/vitest.hot.config.mts",
194
185
  "test:native:hot:isolation": "vitest run --config tests-native/vitest.hot-isolation.config.mts",
195
186
  "test:native:hot:soak": "node scripts/test-hot-soak.mjs",
@@ -199,17 +190,18 @@
199
190
  "format:check": "oxfmt --check src/ tests/ consumer-tests/ scripts/",
200
191
  "check-compat": "bun scripts/check-compat.ts",
201
192
  "check:size": "node scripts/check-package-size.mjs",
193
+ "check:exports": "node scripts/check-exports.mjs",
202
194
  "typecheck": "tsc --noEmit",
203
195
  "clean": "rm -rf dist",
204
- "prepublishOnly": "bun run build && bun run check:size && bun run test && bun run test:native && bun run test:native:navigation && bun run test:native:android && bun run test:native:hot && bun run test:native:hot:isolation && bun run test:native:hot:soak && bun run fidelity:check && bun run test:consumers && bun run lint && bun run typecheck",
196
+ "prepublishOnly": "bun run build && bun run check:size && bun run test && bun run test:native && bun run test:native:forks && bun run test:native:navigation && bun run test:native:android && bun run test:native:advice && bun run test:native:hot && bun run test:native:hot:isolation && bun run test:native:hot:soak && bun run validate:hot-parity && bun run fidelity:check && bun run test:consumers && bun run lint && bun run typecheck",
205
197
  "crosscheck": "node scripts/crosscheck.mjs",
206
198
  "fidelity:report": "node scripts/fidelity-report.mjs",
207
199
  "fidelity:check": "node scripts/fidelity-report.mjs --check && node scripts/fidelity-matrix.mjs --check",
208
200
  "validate:hot-parity": "node validation/idiomatic/scale/run-compare.mjs"
209
201
  },
210
202
  "dependencies": {
211
- "flow-remove-types": "^2.322.0",
212
- "magic-string": "^0.30.21"
203
+ "flow-remove-types": "^2.325.0",
204
+ "magic-string": "^1.1.0"
213
205
  },
214
206
  "bin": {
215
207
  "vitest-native": "./dist/cli.mjs"
@@ -1,294 +0,0 @@
1
- const require_chunk = require("./chunk-CZWwpsFl.cjs");
2
- const require_preset_map = require("./preset-map-CG4FMtsl.cjs");
3
- let node_path = require("node:path");
4
- node_path = require_chunk.__toESM(node_path, 1);
5
- let node_fs = require("node:fs");
6
- node_fs = require_chunk.__toESM(node_fs, 1);
7
- let node_module = require("node:module");
8
- //#region src/validate.ts
9
- const KNOWN_OPTIONS = [
10
- "platform",
11
- "presets",
12
- "mocks",
13
- "diagnostics",
14
- "assetExts",
15
- "engine",
16
- "transform",
17
- "hotRuntime"
18
- ];
19
- const KNOWN_HOT_RUNTIME_OPTIONS = [
20
- "recycleAfterFiles",
21
- "memoryLimit",
22
- "preserveGlobals"
23
- ];
24
- function assertStringArray(value, option) {
25
- if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string" || entry.length === 0)) throw new TypeError(`[vitest-native] "${option}" must be an array of non-empty strings.`);
26
- }
27
- function assertNonNegativeInteger(value, option) {
28
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new TypeError(`[vitest-native] "${option}" must be a non-negative safe integer.`);
29
- }
30
- function validateOptions(options) {
31
- if (options.engine !== void 0 && options.engine !== "auto" && options.engine !== "mock" && options.engine !== "native") throw new TypeError(`[vitest-native] "engine" must be "auto", "mock", or "native".`);
32
- if (options.platform !== void 0 && options.platform !== "ios" && options.platform !== "android") throw new TypeError(`[vitest-native] "platform" must be "ios" or "android".`);
33
- if (options.diagnostics !== void 0 && typeof options.diagnostics !== "boolean") throw new TypeError(`[vitest-native] "diagnostics" must be a boolean.`);
34
- if (options.assetExts !== void 0) assertStringArray(options.assetExts, "assetExts");
35
- if (options.transform !== void 0) assertStringArray(options.transform, "transform");
36
- if (options.presets !== void 0 && !Array.isArray(options.presets)) throw new TypeError(`[vitest-native] "presets" must be an array.`);
37
- if (options.mocks !== void 0 && (options.mocks === null || Array.isArray(options.mocks) || typeof options.mocks !== "object")) throw new TypeError(`[vitest-native] "mocks" must be a plain object.`);
38
- const hotRuntime = options.hotRuntime;
39
- if (hotRuntime === void 0 || typeof hotRuntime === "boolean") return;
40
- if (hotRuntime === null || Array.isArray(hotRuntime) || typeof hotRuntime !== "object") throw new TypeError(`[vitest-native] "hotRuntime" must be a boolean or an options object.`);
41
- const hotOptions = hotRuntime;
42
- for (const key of Object.keys(hotOptions)) if (!KNOWN_HOT_RUNTIME_OPTIONS.includes(key)) throw new TypeError(`[vitest-native] Unknown hotRuntime option "${key}".`);
43
- if (hotOptions.recycleAfterFiles !== void 0) assertNonNegativeInteger(hotOptions.recycleAfterFiles, "hotRuntime.recycleAfterFiles");
44
- if (hotOptions.memoryLimit !== void 0) assertNonNegativeInteger(hotOptions.memoryLimit, "hotRuntime.memoryLimit");
45
- if (hotOptions.preserveGlobals !== void 0) assertStringArray(hotOptions.preserveGlobals, "hotRuntime.preserveGlobals");
46
- }
47
- function satisfiesMinimum(version, minimum) {
48
- const parse = (v) => v.replace(/^[^0-9]*/, "").split(/[-+]/)[0].split(".").map(Number);
49
- const [aMaj, aMin = 0, aPat = 0] = parse(version);
50
- const [bMaj, bMin = 0, bPat = 0] = parse(minimum);
51
- if (aMaj !== bMaj) return aMaj > bMaj;
52
- if (aMin !== bMin) return aMin > bMin;
53
- return aPat >= bPat;
54
- }
55
- function validatePeerDependency(pkgName, minimumVersion, projectRoot, maximumMajorExclusive, minimumByMajor) {
56
- const req = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
57
- try {
58
- const { version } = req(req.resolve(`${pkgName}/package.json`));
59
- const major = Number(version.replace(/^[^0-9]*/, "").split(".")[0]);
60
- const requiredMinimum = minimumByMajor?.[major] ?? minimumVersion;
61
- if (!satisfiesMinimum(version, requiredMinimum)) return `vitest-native requires ${pkgName} >= ${requiredMinimum} for ${major}.x, but found ${version}. Please upgrade.`;
62
- if (maximumMajorExclusive !== void 0 && major >= maximumMajorExclusive) return `vitest-native supports ${pkgName} >= ${minimumVersion} and < ${maximumMajorExclusive}, but found ${version}.`;
63
- return null;
64
- } catch {
65
- return `vitest-native requires ${pkgName} >= ${minimumVersion}, but it was not found. Please install it.`;
66
- }
67
- }
68
- function warnUnknownOptions(options) {
69
- for (const key of Object.keys(options)) if (!KNOWN_OPTIONS.includes(key)) {
70
- const suggestion = findClosest(key, KNOWN_OPTIONS);
71
- const hint = suggestion ? ` Did you mean '${suggestion}'?` : "";
72
- console.warn(`[vitest-native] Unknown option '${key}'.${hint}`);
73
- }
74
- }
75
- function findClosest(input, candidates) {
76
- let best = null;
77
- let bestDist = Infinity;
78
- for (const c of candidates) {
79
- const d = levenshtein(input.toLowerCase(), c.toLowerCase());
80
- if (d < bestDist && d <= 3) {
81
- bestDist = d;
82
- best = c;
83
- }
84
- }
85
- return best;
86
- }
87
- function levenshtein(a, b) {
88
- const m = a.length;
89
- const n = b.length;
90
- const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
91
- for (let i = 0; i <= m; i++) dp[i][0] = i;
92
- for (let j = 0; j <= n; j++) dp[0][j] = j;
93
- for (let i = 1; i <= m; i++) for (let j = 1; j <= n; j++) dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
94
- return dp[m][n];
95
- }
96
- //#endregion
97
- //#region src/peer-requirements.ts
98
- const PEER_REQUIREMENTS = [
99
- {
100
- name: "vitest",
101
- minimum: "4.0.0",
102
- maximumMajor: 6
103
- },
104
- {
105
- name: "vite",
106
- minimum: "6.4.2",
107
- maximumMajor: 9,
108
- minimumByMajor: {
109
- 6: "6.4.2",
110
- 7: "7.3.2",
111
- 8: "8.0.5"
112
- }
113
- },
114
- {
115
- name: "react",
116
- minimum: "18.0.0"
117
- }
118
- ];
119
- /** Can this project run the native engine? (Both transform deps resolvable.) */
120
- function isNativeCapable(projectRoot) {
121
- try {
122
- const req = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
123
- req.resolve("@react-native/babel-preset");
124
- req.resolve("@babel/core");
125
- return true;
126
- } catch {
127
- return false;
128
- }
129
- }
130
- /** Resolve the concrete engine for a run. Pure; never throws. */
131
- function detectEngine(requested, projectRoot, opts) {
132
- const nativeAvailable = isNativeCapable(projectRoot);
133
- if (requested === "native") return {
134
- engine: "native",
135
- nativeAvailable,
136
- notice: null
137
- };
138
- if (requested === "mock") return {
139
- engine: "mock",
140
- nativeAvailable,
141
- notice: null
142
- };
143
- const prefersNative = opts?.autoPrefersNative ?? true;
144
- if (prefersNative && nativeAvailable) return {
145
- engine: "native",
146
- nativeAvailable,
147
- notice: null
148
- };
149
- if (prefersNative) return {
150
- engine: "mock",
151
- nativeAvailable: false,
152
- notice: "[vitest-native] @react-native/babel-preset not found — using the mock engine. Install it (and @babel/core) to run real React Native, or set engine:'mock' to silence this."
153
- };
154
- return {
155
- engine: "mock",
156
- nativeAvailable,
157
- notice: null
158
- };
159
- }
160
- //#endregion
161
- //#region src/native/ecosystem.ts
162
- /**
163
- * Packages that must never be auto-inlined even though they depend on React
164
- * Native. The test library and the renderers underneath it are infrastructure the
165
- * engine itself wires up; pulling a second copy of them into the module graph has
166
- * corrupted rendering before, in ways that surface as unrelated act() and
167
- * host-component failures.
168
- */
169
- const NEVER_INLINE = new Set([
170
- "@testing-library/react-native",
171
- "react-test-renderer",
172
- "test-renderer",
173
- "react-native"
174
- ]);
175
- /** Manifest fields that make a package part of the React Native ecosystem. */
176
- function dependsOnReactNative(manifest) {
177
- for (const field of ["dependencies", "peerDependencies"]) {
178
- const deps = manifest[field];
179
- if (deps && typeof deps === "object" && "react-native" in deps) return true;
180
- }
181
- return false;
182
- }
183
- /**
184
- * Every package manifest from the project up to the filesystem root.
185
- *
186
- * A workspace does not always declare its dependencies where the tests run: an app
187
- * package may inherit React Native libraries from the repository root, and a Vitest
188
- * `root` can point at a directory above or below the package that owns them. Reading
189
- * only the project's own manifest silently found nothing in those layouts and sent
190
- * the user back to maintaining `transform: [...]` by hand.
191
- *
192
- * Over-collecting is safe and under-collecting is not: a package that is listed but
193
- * never imported costs nothing, because inlining only applies to files that are
194
- * actually loaded.
195
- */
196
- function manifestsFrom(projectRoot) {
197
- const manifests = [];
198
- let dir = node_path.default.resolve(projectRoot);
199
- for (;;) {
200
- try {
201
- const raw = node_fs.default.readFileSync(node_path.default.join(dir, "package.json"), "utf8");
202
- manifests.push(JSON.parse(raw));
203
- } catch {}
204
- const parent = node_path.default.dirname(dir);
205
- if (parent === dir) return manifests;
206
- dir = parent;
207
- }
208
- }
209
- /**
210
- * Packages in the project that declare React Native in their own manifest.
211
- *
212
- * These are the ones published the way the React Native ecosystem publishes:
213
- * untranspiled JSX, Flow, or TypeScript, on the assumption that Metro will compile
214
- * them. Node cannot run that source, which is why they previously had to be listed
215
- * by hand in `transform: [...]` — a list every project had to discover the hard way,
216
- * one `SyntaxError: Unexpected token '<'` at a time.
217
- *
218
- * A package's own manifest is the authority here rather than a heuristic on its
219
- * name: `react-native-*` misses `@gorhom/bottom-sheet` and would wrongly claim
220
- * `react-native` itself, while the manifest states the relationship exactly.
221
- *
222
- * Declared dependencies are read from the project and every manifest above it, so a
223
- * workspace that declares its React Native libraries at the repository root is covered
224
- * too. Resolving each name is cheap and package-manager-agnostic, where walking the
225
- * installed tree depends on the store layout. Transitive dependencies that nothing
226
- * declares stay available through `transform: [...]`.
227
- *
228
- * Excluded: packages a preset already shadows (their real source never loads), the
229
- * test infrastructure in NEVER_INLINE, and anything the consumer listed explicitly
230
- * in `transform` — that option keeps its existing meaning and takes precedence.
231
- */
232
- function detectEcosystemPackages(projectRoot, explicit = []) {
233
- const req = (0, node_module.createRequire)(node_path.default.join(projectRoot, "package.json"));
234
- const skip = new Set([
235
- ...NEVER_INLINE,
236
- ...Object.keys(require_preset_map.AUTO_DETECT_PRESETS),
237
- ...explicit
238
- ]);
239
- const candidates = /* @__PURE__ */ new Set();
240
- for (const manifest of manifestsFrom(projectRoot)) for (const field of [
241
- "dependencies",
242
- "devDependencies",
243
- "optionalDependencies"
244
- ]) {
245
- const deps = manifest[field];
246
- if (deps && typeof deps === "object") for (const name of Object.keys(deps)) candidates.add(name);
247
- }
248
- if (candidates.size === 0) return [];
249
- const detected = [];
250
- for (const name of candidates) {
251
- if (skip.has(name) || name.startsWith("@react-native/")) continue;
252
- try {
253
- if (dependsOnReactNative(req(`${name}/package.json`))) detected.push(name);
254
- } catch {}
255
- }
256
- return detected.sort();
257
- }
258
- //#endregion
259
- Object.defineProperty(exports, "PEER_REQUIREMENTS", {
260
- enumerable: true,
261
- get: function() {
262
- return PEER_REQUIREMENTS;
263
- }
264
- });
265
- Object.defineProperty(exports, "detectEcosystemPackages", {
266
- enumerable: true,
267
- get: function() {
268
- return detectEcosystemPackages;
269
- }
270
- });
271
- Object.defineProperty(exports, "detectEngine", {
272
- enumerable: true,
273
- get: function() {
274
- return detectEngine;
275
- }
276
- });
277
- Object.defineProperty(exports, "validateOptions", {
278
- enumerable: true,
279
- get: function() {
280
- return validateOptions;
281
- }
282
- });
283
- Object.defineProperty(exports, "validatePeerDependency", {
284
- enumerable: true,
285
- get: function() {
286
- return validatePeerDependency;
287
- }
288
- });
289
- Object.defineProperty(exports, "warnUnknownOptions", {
290
- enumerable: true,
291
- get: function() {
292
- return warnUnknownOptions;
293
- }
294
- });