@multiplatform.one/config 10.0.0 → 10.1.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.
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
2
- import { t as createStorybookViteConfig } from "./storybook-BRZwQLAM.js";
3
- import { t as createViteConfig } from "./vite-DaBjbGS0.js";
4
- import { t as createVitestConfig } from "./vitest-NTT7k5jB.js";
1
+ import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-7eT9XxzE.js";
2
+ import { t as createStorybookViteConfig } from "./storybook-LYamvanr.js";
3
+ import { t as createViteConfig } from "./vite-BtlhFd_U.js";
4
+ import { t as createVitestConfig } from "./vitest-B8Z8ZZQR.js";
5
5
 
6
6
  export { createStorybookViteConfig, createViteConfig, createVitestConfig, ensureTamaguiWorkspacePaths, phosphorTokenColorPlugin, tamaguiWorkspacePathsFile };
@@ -1,146 +1,9 @@
1
- import { c as singletonResolvePlugin, l as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots, u as movedDepAliases } from "./workspacePublicPackages-z0fVhgGN.js";
2
- import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
1
+ import { d as nativeOnlyDepStubPlugin, f as movedDepAliases, o as singletonResolvePlugin, r as resolvePackageMainSource, s as withSingletonDepAliases, t as discoverPublicPackageRoots, u as nativeOnlyDepStubOptimizerPlugin } from "./workspacePublicPackages-B_kw7fuc.js";
2
+ import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-7eT9XxzE.js";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
6
 
8
- //#region src/nativeOnlyDepStubs.ts
9
- const NATIVE_ONLY_MODULES = [{
10
- pkg: "react-native-svg",
11
- flavours: [
12
- "lib/module/fabric/NativeSvgSoundModule.js",
13
- "lib/commonjs/fabric/NativeSvgSoundModule.js",
14
- "src/fabric/NativeSvgSoundModule.ts"
15
- ],
16
- specifier: "../fabric/NativeSvgSoundModule",
17
- binding: "TurboModuleRegistry",
18
- stub: "svgTouchSound.web.js"
19
- }];
20
- /** The web stand-in for `react-native`, whose exports decide every entry. */
21
- const webRuntime = {
22
- pkg: "react-native-web",
23
- entry: "dist/index.js"
24
- };
25
- /**
26
- * Entries whose breakage is real in this tree, with their stub resolved.
27
- *
28
- * @param root Directory whose `node_modules` the packages resolve from.
29
- */
30
- function nativeOnlyDepStubs(root = process.cwd()) {
31
- const requireFrom = createRequire(path.join(root, "package.json"));
32
- const webExports = runtimeExports(root, requireFrom);
33
- const stubs = [];
34
- for (const entry of NATIVE_ONLY_MODULES) {
35
- if (!webExports || webExports.has(entry.binding)) continue;
36
- const pkgDir = resolvePackageDir$1(entry.pkg, root, requireFrom);
37
- if (!pkgDir) continue;
38
- if (!entry.flavours.map((flavour) => path.join(pkgDir, flavour)).filter((file) => fs.existsSync(file)).some((file) => importsBinding(file, entry.binding))) continue;
39
- const stub = stubFile(entry.stub);
40
- if (!stub) continue;
41
- stubs.push({
42
- marker: `${path.sep}${entry.pkg}${path.sep}`,
43
- specifiers: [
44
- entry.specifier,
45
- `${entry.specifier}.js`,
46
- `${entry.specifier}.ts`
47
- ],
48
- stub
49
- });
50
- }
51
- return stubs;
52
- }
53
- /**
54
- * The resolver behind both plugins below, or undefined when nothing in this
55
- * tree measures as broken.
56
- */
57
- function nativeOnlyDepResolver(root = process.cwd()) {
58
- const stubs = nativeOnlyDepStubs(root);
59
- if (!stubs.length) return void 0;
60
- return (id, importer) => {
61
- if (!importer) return null;
62
- for (const stub of stubs) {
63
- if (!importer.includes(stub.marker)) continue;
64
- if (stub.specifiers.includes(id)) return stub.stub;
65
- }
66
- return null;
67
- };
68
- }
69
- /**
70
- * Vite plugin for the transform pipeline (`vite build`, `storybook build`).
71
- *
72
- * `enforce: "pre"` is load-bearing: a normal-order plugin resolves after
73
- * `vite:resolve`, which has already turned the relative specifier into a real
74
- * file by then.
75
- */
76
- function nativeOnlyDepStubPlugin(root = process.cwd()) {
77
- const resolver = nativeOnlyDepResolver(root);
78
- if (!resolver) return void 0;
79
- return {
80
- name: "multiplatform-native-only-dep-stubs",
81
- enforce: "pre",
82
- resolveId(id, importer) {
83
- return resolver(id, importer);
84
- }
85
- };
86
- }
87
- /**
88
- * The same resolver for the dev dep-optimizer, which runs its own rolldown
89
- * build that sees neither user plugins nor `resolve.alias` for a relative
90
- * specifier — only `optimizeDeps.rolldownOptions.plugins`. Carries no vite-only
91
- * fields, since rolldown receives this object directly.
92
- */
93
- function nativeOnlyDepStubOptimizerPlugin(root = process.cwd()) {
94
- const resolver = nativeOnlyDepResolver(root);
95
- if (!resolver) return void 0;
96
- return {
97
- name: "multiplatform-native-only-dep-stubs",
98
- resolveId: resolver
99
- };
100
- }
101
- /** Names the web runtime re-exports, or undefined when it cannot be read. */
102
- function runtimeExports(root, requireFrom) {
103
- const pkgDir = resolvePackageDir$1(webRuntime.pkg, root, requireFrom);
104
- if (!pkgDir) return void 0;
105
- let source;
106
- try {
107
- source = fs.readFileSync(path.join(pkgDir, webRuntime.entry), "utf8");
108
- } catch {
109
- return;
110
- }
111
- const names = /* @__PURE__ */ new Set();
112
- for (const match of source.matchAll(/^export\s*\{([^}]*)\}/gm)) for (const clause of match[1].split(",")) {
113
- const name = clause.trim().split(/\s+as\s+/).pop()?.trim();
114
- if (name) names.add(name);
115
- }
116
- for (const match of source.matchAll(/^export\s+(?:const|let|var|function|class)\s+(\w+)/gm)) names.add(match[1]);
117
- return names.size ? names : void 0;
118
- }
119
- /** Whether the module takes the binding off `react-native` by name. */
120
- function importsBinding(file, binding) {
121
- let source;
122
- try {
123
- source = fs.readFileSync(file, "utf8");
124
- } catch {
125
- return false;
126
- }
127
- return new RegExp(`(?:import|require)[^;]*\\b${binding}\\b[^;]*['"]react-native['"]`, "s").test(source);
128
- }
129
- /** `src/shims/<name>` from source, `../src/shims/<name>` from the built `lib`. */
130
- function stubFile(name) {
131
- const here = path.dirname(fileURLToPath(import.meta.url));
132
- return [path.resolve(here, "shims", name), path.resolve(here, "../src/shims", name)].find((candidate) => fs.existsSync(candidate));
133
- }
134
- function resolvePackageDir$1(pkgName, root, requireFrom) {
135
- try {
136
- return path.dirname(requireFrom.resolve(`${pkgName}/package.json`));
137
- } catch {
138
- const hoisted = path.join(root, "node_modules", ...pkgName.split("/"));
139
- return fs.existsSync(path.join(hoisted, "package.json")) ? hoisted : void 0;
140
- }
141
- }
142
-
143
- //#endregion
144
7
  //#region src/unexportedDepAliases.ts
145
8
  /**
146
9
  * Package subtrees that consumers deep-import but the publisher never declared
package/lib/storybook.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createStorybookViteConfig } from "./storybook-BRZwQLAM.js";
1
+ import { t as createStorybookViteConfig } from "./storybook-LYamvanr.js";
2
2
 
3
3
  export { createStorybookViteConfig };
@@ -1,8 +1,8 @@
1
1
  import Module from "node:module";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
5
4
  import { execFileSync } from "node:child_process";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
6
 
7
7
  //#region src/phosphorTokenColor.ts
8
8
  const virtualPrefix = "\0mpo-phosphor-token-icon-base:";
@@ -1,5 +1,5 @@
1
- import { c as singletonResolvePlugin, d as __require, i as resolveWorkspaceNativeEntry, l as withSingletonDepAliases, o as lookupTamaguiModules, s as resolveConfig, t as discoverPublicPackageRoots, u as movedDepAliases } from "./workspacePublicPackages-z0fVhgGN.js";
2
- import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
1
+ import { c as lookupTamaguiModules, f as movedDepAliases, i as resolveWorkspaceNativeEntry, l as resolveConfig, o as singletonResolvePlugin, p as __require, s as withSingletonDepAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-B_kw7fuc.js";
2
+ import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-7eT9XxzE.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import dotenv from "dotenv";
package/lib/vite.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as staleNativeDistSource, i as resolveWorkspaceNativeEntry, n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-z0fVhgGN.js";
2
- import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
3
- import { a as phosphorNativeIconLibId, i as phosphorNativeIconBaseId, n as nativeOnlyPlugin, o as publicConfigPlugin, r as phosphorNativeIconBase, s as readPublicConfigKeys, t as createViteConfig } from "./vite-DaBjbGS0.js";
1
+ import { a as staleNativeDistSource, i as resolveWorkspaceNativeEntry, n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-B_kw7fuc.js";
2
+ import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-7eT9XxzE.js";
3
+ import { a as phosphorNativeIconLibId, i as phosphorNativeIconBaseId, n as nativeOnlyPlugin, o as publicConfigPlugin, r as phosphorNativeIconBase, s as readPublicConfigKeys, t as createViteConfig } from "./vite-BtlhFd_U.js";
4
4
 
5
5
  export { createViteConfig, discoverPublicPackageRoots, nativeOnlyPlugin, phosphorNativeIconBase, phosphorNativeIconBaseId, phosphorNativeIconLibId, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys, resolveWorkspaceNativeEntry, staleNativeDistSource };
@@ -1,4 +1,4 @@
1
- import { i as phosphorTokenColorPlugin, r as phosphorBarrelBundlePlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-BFMQNk1l.js";
1
+ import { i as phosphorTokenColorPlugin, r as phosphorBarrelBundlePlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-7eT9XxzE.js";
2
2
  import Module from "node:module";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
package/lib/vitest.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as tamaguiExtractedCss, i as tamaguiEvaluationExternals, n as pinnedPackages, r as tamaguiEvaluationConditions, t as createVitestConfig } from "./vitest-NTT7k5jB.js";
1
+ import { a as tamaguiExtractedCss, i as tamaguiEvaluationExternals, n as pinnedPackages, r as tamaguiEvaluationConditions, t as createVitestConfig } from "./vitest-B8Z8ZZQR.js";
2
2
 
3
3
  export { createVitestConfig, pinnedPackages, tamaguiEvaluationConditions, tamaguiEvaluationExternals, tamaguiExtractedCss };
@@ -2,12 +2,13 @@ import { createRequire } from "node:module";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { spawnSync } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
5
6
 
6
7
  //#region \0rolldown/runtime.js
7
8
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
8
9
 
9
10
  //#endregion
10
- //#region src/movedDepAliases.ts
11
+ //#region ../utils/src/movedDepAliases.ts
11
12
  const MOVED_MODULES = [{
12
13
  specifier: "@react-native/assets-registry/registry",
13
14
  goneWith: "@react-native/assets-registry",
@@ -25,7 +26,7 @@ function movedDepAliases(root = process.cwd()) {
25
26
  const aliases = {};
26
27
  for (const moved of MOVED_MODULES) {
27
28
  if (resolvesPackage(moved.goneWith, root, requireFrom)) continue;
28
- const host = resolvePackageDir$1(moved.nowIn, root, requireFrom);
29
+ const host = resolvePackageDir$2(moved.nowIn, root, requireFrom);
29
30
  if (!host) continue;
30
31
  const target = path.join(host, moved.file);
31
32
  if (fs.existsSync(target)) aliases[moved.specifier] = target;
@@ -33,7 +34,143 @@ function movedDepAliases(root = process.cwd()) {
33
34
  return aliases;
34
35
  }
35
36
  function resolvesPackage(pkgName, root, requireFrom) {
36
- return resolvePackageDir$1(pkgName, root, requireFrom) !== void 0;
37
+ return resolvePackageDir$2(pkgName, root, requireFrom) !== void 0;
38
+ }
39
+ function resolvePackageDir$2(pkgName, root, requireFrom) {
40
+ try {
41
+ return path.dirname(requireFrom.resolve(`${pkgName}/package.json`));
42
+ } catch {
43
+ const hoisted = path.join(root, "node_modules", ...pkgName.split("/"));
44
+ return fs.existsSync(path.join(hoisted, "package.json")) ? hoisted : void 0;
45
+ }
46
+ }
47
+
48
+ //#endregion
49
+ //#region ../utils/src/nativeOnlyDepStubs.ts
50
+ const NATIVE_ONLY_MODULES = [{
51
+ pkg: "react-native-svg",
52
+ flavours: [
53
+ "lib/module/fabric/NativeSvgSoundModule.js",
54
+ "lib/commonjs/fabric/NativeSvgSoundModule.js",
55
+ "src/fabric/NativeSvgSoundModule.ts"
56
+ ],
57
+ specifier: "../fabric/NativeSvgSoundModule",
58
+ binding: "TurboModuleRegistry",
59
+ stub: "svgTouchSound.web.js"
60
+ }];
61
+ /** The web stand-in for `react-native`, whose exports decide every entry. */
62
+ const webRuntime = {
63
+ pkg: "react-native-web",
64
+ entry: "dist/index.js"
65
+ };
66
+ /**
67
+ * Entries whose breakage is real in this tree, with their stub resolved.
68
+ *
69
+ * @param root Directory whose `node_modules` the packages resolve from.
70
+ */
71
+ function nativeOnlyDepStubs(root = process.cwd()) {
72
+ const requireFrom = createRequire(path.join(root, "package.json"));
73
+ const webExports = runtimeExports(root, requireFrom);
74
+ const stubs = [];
75
+ for (const entry of NATIVE_ONLY_MODULES) {
76
+ if (!webExports || webExports.has(entry.binding)) continue;
77
+ const pkgDir = resolvePackageDir$1(entry.pkg, root, requireFrom);
78
+ if (!pkgDir) continue;
79
+ if (!entry.flavours.map((flavour) => path.join(pkgDir, flavour)).filter((file) => fs.existsSync(file)).some((file) => importsBinding(file, entry.binding))) continue;
80
+ const stub = stubFile(entry.stub);
81
+ if (!stub) continue;
82
+ stubs.push({
83
+ marker: `${path.sep}${entry.pkg}${path.sep}`,
84
+ specifiers: [
85
+ entry.specifier,
86
+ `${entry.specifier}.js`,
87
+ `${entry.specifier}.ts`
88
+ ],
89
+ stub
90
+ });
91
+ }
92
+ return stubs;
93
+ }
94
+ /**
95
+ * The resolver behind both plugins below, or undefined when nothing in this
96
+ * tree measures as broken.
97
+ */
98
+ function nativeOnlyDepResolver(root = process.cwd()) {
99
+ const stubs = nativeOnlyDepStubs(root);
100
+ if (!stubs.length) return void 0;
101
+ return (id, importer) => {
102
+ if (!importer) return null;
103
+ for (const stub of stubs) {
104
+ if (!importer.includes(stub.marker)) continue;
105
+ if (stub.specifiers.includes(id)) return stub.stub;
106
+ }
107
+ return null;
108
+ };
109
+ }
110
+ /**
111
+ * Vite plugin for the transform pipeline (`vite build`, `storybook build`).
112
+ *
113
+ * `enforce: "pre"` is load-bearing: a normal-order plugin resolves after
114
+ * `vite:resolve`, which has already turned the relative specifier into a real
115
+ * file by then.
116
+ */
117
+ function nativeOnlyDepStubPlugin(root = process.cwd()) {
118
+ const resolver = nativeOnlyDepResolver(root);
119
+ if (!resolver) return void 0;
120
+ return {
121
+ name: "multiplatform-native-only-dep-stubs",
122
+ enforce: "pre",
123
+ resolveId(id, importer) {
124
+ return resolver(id, importer);
125
+ }
126
+ };
127
+ }
128
+ /**
129
+ * The same resolver for the dev dep-optimizer, which runs its own rolldown
130
+ * build that sees neither user plugins nor `resolve.alias` for a relative
131
+ * specifier — only `optimizeDeps.rolldownOptions.plugins`. Carries no vite-only
132
+ * fields, since rolldown receives this object directly.
133
+ */
134
+ function nativeOnlyDepStubOptimizerPlugin(root = process.cwd()) {
135
+ const resolver = nativeOnlyDepResolver(root);
136
+ if (!resolver) return void 0;
137
+ return {
138
+ name: "multiplatform-native-only-dep-stubs",
139
+ resolveId: resolver
140
+ };
141
+ }
142
+ /** Names the web runtime re-exports, or undefined when it cannot be read. */
143
+ function runtimeExports(root, requireFrom) {
144
+ const pkgDir = resolvePackageDir$1(webRuntime.pkg, root, requireFrom);
145
+ if (!pkgDir) return void 0;
146
+ let source;
147
+ try {
148
+ source = fs.readFileSync(path.join(pkgDir, webRuntime.entry), "utf8");
149
+ } catch {
150
+ return;
151
+ }
152
+ const names = /* @__PURE__ */ new Set();
153
+ for (const match of source.matchAll(/^export\s*\{([^}]*)\}/gm)) for (const clause of match[1].split(",")) {
154
+ const name = clause.trim().split(/\s+as\s+/).pop()?.trim();
155
+ if (name) names.add(name);
156
+ }
157
+ for (const match of source.matchAll(/^export\s+(?:const|let|var|function|class)\s+(\w+)/gm)) names.add(match[1]);
158
+ return names.size ? names : void 0;
159
+ }
160
+ /** Whether the module takes the binding off `react-native` by name. */
161
+ function importsBinding(file, binding) {
162
+ let source;
163
+ try {
164
+ source = fs.readFileSync(file, "utf8");
165
+ } catch {
166
+ return false;
167
+ }
168
+ return new RegExp(`(?:import|require)[^;]*\\b${binding}\\b[^;]*['"]react-native['"]`, "s").test(source);
169
+ }
170
+ /** `src/shims/<name>` from source, `../src/shims/<name>` from the built `lib`. */
171
+ function stubFile(name) {
172
+ const here = path.dirname(fileURLToPath(import.meta.url));
173
+ return [path.resolve(here, "shims", name), path.resolve(here, "../src/shims", name)].find((candidate) => fs.existsSync(candidate));
37
174
  }
38
175
  function resolvePackageDir$1(pkgName, root, requireFrom) {
39
176
  try {
@@ -44,6 +181,127 @@ function resolvePackageDir$1(pkgName, root, requireFrom) {
44
181
  }
45
182
  }
46
183
 
184
+ //#endregion
185
+ //#region ../utils/src/dev.ts
186
+ const logger = console;
187
+ function lookupTamaguiModules(packageDirs, { log = true } = {}) {
188
+ const projectRoot = lookupProjectRoot();
189
+ const tamaguiModules = [...new Set(["tamagui", ...[...new Set([
190
+ projectRoot,
191
+ path.resolve(projectRoot, "app"),
192
+ path.resolve(projectRoot, "features"),
193
+ ...packageDirs || []
194
+ ])].map((packageDir) => {
195
+ const pkgPath = path.join(packageDir, "package.json");
196
+ if (!fs.existsSync(pkgPath)) return [];
197
+ try {
198
+ return JSON.parse(fs.readFileSync(pkgPath, "utf-8")).tamaguiModules || [];
199
+ } catch (err) {
200
+ if (log) logger.error(err);
201
+ return [];
202
+ }
203
+ })])].flat();
204
+ if (log) logger.debug("tamaguiModules:", tamaguiModules.join(", "));
205
+ return tamaguiModules;
206
+ }
207
+ function resolveConfig(keys = []) {
208
+ return keys.reduce((acc, key) => {
209
+ if (process.env[key]) acc[key] = process.env[key];
210
+ return acc;
211
+ }, {});
212
+ }
213
+ let _projectRoot;
214
+ function lookupProjectRoot() {
215
+ if (_projectRoot) return _projectRoot;
216
+ try {
217
+ const { stdout } = spawnSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" });
218
+ _projectRoot = stdout.trim();
219
+ return _projectRoot;
220
+ } catch {
221
+ _projectRoot = process.cwd();
222
+ return _projectRoot;
223
+ }
224
+ }
225
+ const webConditionOrder = [
226
+ "import",
227
+ "default",
228
+ "require"
229
+ ];
230
+ const skippedConditions = new Set(["types", "react-native"]);
231
+ const tsSourcePattern = /\.[cm]?tsx?$/;
232
+ function collectExportTargets(target, out) {
233
+ if (typeof target === "string") {
234
+ out.push(target);
235
+ return;
236
+ }
237
+ if (!target) return;
238
+ if (Array.isArray(target)) {
239
+ for (const item of target) collectExportTargets(item, out);
240
+ return;
241
+ }
242
+ if (typeof target.source === "string") out.push(target.source);
243
+ const keys = Object.keys(target).filter((k) => k !== "source" && !skippedConditions.has(k));
244
+ const ordered = [...webConditionOrder.filter((k) => keys.includes(k)), ...keys.filter((k) => !webConditionOrder.includes(k))];
245
+ for (const key of ordered) collectExportTargets(target[key], out);
246
+ }
247
+ /**
248
+ * The file a web build should compile for one `exports` entry: its `source`
249
+ * condition, else the first TypeScript file among its web conditions, else
250
+ * the first existing file (css, a prebuilt .mjs), so the package-name alias
251
+ * never swallows a subpath it cannot see.
252
+ */
253
+ function resolveExportSource(pkgDir, target) {
254
+ const candidates = [];
255
+ collectExportTargets(target, candidates);
256
+ const existing = candidates.map((c) => path.resolve(pkgDir, c)).filter((c) => !c.endsWith(".d.ts") && fs.existsSync(c) && fs.statSync(c).isFile());
257
+ return existing.find((c) => tsSourcePattern.test(c)) ?? existing[0];
258
+ }
259
+ /**
260
+ * The file a subpath declares when none of its targets is on disk yet, such
261
+ * as a prebuilt `./dist/...` asset in an unbuilt tree. Aliasing it keeps the
262
+ * bare package alias from rewriting the subpath into `src/index.ts/<subpath>`,
263
+ * so a missing build fails on the real path. Types-only subpaths get none.
264
+ */
265
+ function declaredExportTarget(pkgDir, target) {
266
+ const candidates = [];
267
+ collectExportTargets(target, candidates);
268
+ const runtime = candidates.find((c) => !c.endsWith(".d.ts"));
269
+ return runtime ? path.resolve(pkgDir, runtime) : void 0;
270
+ }
271
+ function directoryPatternAlias(pkgDir, target) {
272
+ const targets = [];
273
+ collectExportTargets(target, targets);
274
+ const dirTarget = targets.find((t) => t.endsWith("/*"));
275
+ if (!dirTarget) return void 0;
276
+ const dir = path.resolve(pkgDir, dirTarget.slice(0, -2));
277
+ return fs.existsSync(dir) && fs.statSync(dir).isDirectory() ? dir : void 0;
278
+ }
279
+ function subpathAlias(pkgDir, key, target) {
280
+ if (key === "." || key === "./package.json" || !key.startsWith("./")) return void 0;
281
+ if (key.endsWith("/*")) {
282
+ const pattern = key.slice(2, -2);
283
+ if (pattern.includes("*")) return void 0;
284
+ const dir = directoryPatternAlias(pkgDir, target);
285
+ return dir ? [pattern, dir] : void 0;
286
+ }
287
+ if (key.includes("*")) return void 0;
288
+ const file = resolveExportSource(pkgDir, target) ?? declaredExportTarget(pkgDir, target);
289
+ return file ? [key.slice(2), file] : void 0;
290
+ }
291
+ /**
292
+ * Vite `resolve.alias` entries for one package's `exports` subpaths:
293
+ * `<name>/<subpath>` → its source file, and a `./dir/*` pattern → the directory.
294
+ */
295
+ function packageSubpathSourceAliases(pkgName, pkgDir, exportsField) {
296
+ const aliases = {};
297
+ if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField)) return aliases;
298
+ for (const [key, target] of Object.entries(exportsField)) {
299
+ const alias = subpathAlias(pkgDir, key, target);
300
+ if (alias) aliases[`${pkgName}/${alias[0]}`] = alias[1];
301
+ }
302
+ return aliases;
303
+ }
304
+
47
305
  //#endregion
48
306
  //#region src/singletonDepAliases.ts
49
307
  /**
@@ -276,127 +534,6 @@ function resolvePackageDir(pkgName, root, requireFrom) {
276
534
  }
277
535
  }
278
536
 
279
- //#endregion
280
- //#region ../utils/src/dev.ts
281
- const logger = console;
282
- function lookupTamaguiModules(packageDirs, { log = true } = {}) {
283
- const projectRoot = lookupProjectRoot();
284
- const tamaguiModules = [...new Set(["tamagui", ...[...new Set([
285
- projectRoot,
286
- path.resolve(projectRoot, "app"),
287
- path.resolve(projectRoot, "features"),
288
- ...packageDirs || []
289
- ])].map((packageDir) => {
290
- const pkgPath = path.join(packageDir, "package.json");
291
- if (!fs.existsSync(pkgPath)) return [];
292
- try {
293
- return JSON.parse(fs.readFileSync(pkgPath, "utf-8")).tamaguiModules || [];
294
- } catch (err) {
295
- if (log) logger.error(err);
296
- return [];
297
- }
298
- })])].flat();
299
- if (log) logger.debug("tamaguiModules:", tamaguiModules.join(", "));
300
- return tamaguiModules;
301
- }
302
- function resolveConfig(keys = []) {
303
- return keys.reduce((acc, key) => {
304
- if (process.env[key]) acc[key] = process.env[key];
305
- return acc;
306
- }, {});
307
- }
308
- let _projectRoot;
309
- function lookupProjectRoot() {
310
- if (_projectRoot) return _projectRoot;
311
- try {
312
- const { stdout } = spawnSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" });
313
- _projectRoot = stdout.trim();
314
- return _projectRoot;
315
- } catch {
316
- _projectRoot = process.cwd();
317
- return _projectRoot;
318
- }
319
- }
320
- const webConditionOrder = [
321
- "import",
322
- "default",
323
- "require"
324
- ];
325
- const skippedConditions = new Set(["types", "react-native"]);
326
- const tsSourcePattern = /\.[cm]?tsx?$/;
327
- function collectExportTargets(target, out) {
328
- if (typeof target === "string") {
329
- out.push(target);
330
- return;
331
- }
332
- if (!target) return;
333
- if (Array.isArray(target)) {
334
- for (const item of target) collectExportTargets(item, out);
335
- return;
336
- }
337
- if (typeof target.source === "string") out.push(target.source);
338
- const keys = Object.keys(target).filter((k) => k !== "source" && !skippedConditions.has(k));
339
- const ordered = [...webConditionOrder.filter((k) => keys.includes(k)), ...keys.filter((k) => !webConditionOrder.includes(k))];
340
- for (const key of ordered) collectExportTargets(target[key], out);
341
- }
342
- /**
343
- * The file a web build should compile for one `exports` entry: its `source`
344
- * condition, else the first TypeScript file among its web conditions, else
345
- * the first existing file (css, a prebuilt .mjs), so the package-name alias
346
- * never swallows a subpath it cannot see.
347
- */
348
- function resolveExportSource(pkgDir, target) {
349
- const candidates = [];
350
- collectExportTargets(target, candidates);
351
- const existing = candidates.map((c) => path.resolve(pkgDir, c)).filter((c) => !c.endsWith(".d.ts") && fs.existsSync(c) && fs.statSync(c).isFile());
352
- return existing.find((c) => tsSourcePattern.test(c)) ?? existing[0];
353
- }
354
- /**
355
- * The file a subpath declares when none of its targets is on disk yet, such
356
- * as a prebuilt `./dist/...` asset in an unbuilt tree. Aliasing it keeps the
357
- * bare package alias from rewriting the subpath into `src/index.ts/<subpath>`,
358
- * so a missing build fails on the real path. Types-only subpaths get none.
359
- */
360
- function declaredExportTarget(pkgDir, target) {
361
- const candidates = [];
362
- collectExportTargets(target, candidates);
363
- const runtime = candidates.find((c) => !c.endsWith(".d.ts"));
364
- return runtime ? path.resolve(pkgDir, runtime) : void 0;
365
- }
366
- function directoryPatternAlias(pkgDir, target) {
367
- const targets = [];
368
- collectExportTargets(target, targets);
369
- const dirTarget = targets.find((t) => t.endsWith("/*"));
370
- if (!dirTarget) return void 0;
371
- const dir = path.resolve(pkgDir, dirTarget.slice(0, -2));
372
- return fs.existsSync(dir) && fs.statSync(dir).isDirectory() ? dir : void 0;
373
- }
374
- function subpathAlias(pkgDir, key, target) {
375
- if (key === "." || key === "./package.json" || !key.startsWith("./")) return void 0;
376
- if (key.endsWith("/*")) {
377
- const pattern = key.slice(2, -2);
378
- if (pattern.includes("*")) return void 0;
379
- const dir = directoryPatternAlias(pkgDir, target);
380
- return dir ? [pattern, dir] : void 0;
381
- }
382
- if (key.includes("*")) return void 0;
383
- const file = resolveExportSource(pkgDir, target) ?? declaredExportTarget(pkgDir, target);
384
- return file ? [key.slice(2), file] : void 0;
385
- }
386
- /**
387
- * Vite `resolve.alias` entries for one package's `exports` subpaths:
388
- * `<name>/<subpath>` → its source file, and a `./dir/*` pattern → the directory.
389
- */
390
- function packageSubpathSourceAliases(pkgName, pkgDir, exportsField) {
391
- const aliases = {};
392
- if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField)) return aliases;
393
- for (const [key, target] of Object.entries(exportsField)) {
394
- const alias = subpathAlias(pkgDir, key, target);
395
- if (alias) aliases[`${pkgName}/${alias[0]}`] = alias[1];
396
- }
397
- return aliases;
398
- }
399
-
400
537
  //#endregion
401
538
  //#region src/workspacePublicPackages.ts
402
539
  /**
@@ -542,4 +679,4 @@ function publicPackageViteSourceAliases(workspaceRoot) {
542
679
  }
543
680
 
544
681
  //#endregion
545
- export { staleNativeDistSource as a, singletonResolvePlugin as c, __require as d, resolveWorkspaceNativeEntry as i, withSingletonDepAliases as l, publicPackageViteSourceAliases as n, lookupTamaguiModules as o, resolvePackageMainSource as r, resolveConfig as s, discoverPublicPackageRoots as t, movedDepAliases as u };
682
+ export { staleNativeDistSource as a, lookupTamaguiModules as c, nativeOnlyDepStubPlugin as d, movedDepAliases as f, resolveWorkspaceNativeEntry as i, resolveConfig as l, publicPackageViteSourceAliases as n, singletonResolvePlugin as o, __require as p, resolvePackageMainSource as r, withSingletonDepAliases as s, discoverPublicPackageRoots as t, nativeOnlyDepStubOptimizerPlugin as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -122,7 +122,7 @@
122
122
  "@babel/parser": "^7.29.9",
123
123
  "@babel/plugin-transform-block-scoping": "^7.29.7",
124
124
  "@babel/traverse": "^7.29.10",
125
- "@multiplatform.one/utils": "^10.0.0",
125
+ "@multiplatform.one/utils": "^10.1.0",
126
126
  "@tamagui/vite-plugin": "3.2.3",
127
127
  "@vitejs/plugin-react": "^6.1.2",
128
128
  "dotenv": "^17.4.2",