@multiplatform.one/config 7.20.0 → 7.22.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,5 +1,5 @@
1
- import { t as createViteConfig } from "./vite-DXXr5In0.js";
2
- import { t as createStorybookViteConfig } from "./storybook-DFdvDJ_s.js";
1
+ import { t as createViteConfig } from "./vite-CS7fRWSI.js";
2
+ import { t as createStorybookViteConfig } from "./storybook-BqMQy98f.js";
3
3
  import { n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-ZIcqybtn.js";
4
4
  import { createVitestConfig } from "./vitest.js";
5
5
 
@@ -1,4 +1,4 @@
1
- import { i as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots } from "./workspacePublicPackages-BuYRXxFs.js";
1
+ import { i as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots } from "./workspacePublicPackages-B9ho3BjU.js";
2
2
  import { t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-ZIcqybtn.js";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
package/lib/storybook.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createStorybookViteConfig } from "./storybook-DFdvDJ_s.js";
1
+ import { t as createStorybookViteConfig } from "./storybook-BqMQy98f.js";
2
2
 
3
3
  export { createStorybookViteConfig };
@@ -1,4 +1,4 @@
1
- import { i as withSingletonDepAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-BuYRXxFs.js";
1
+ import { i as withSingletonDepAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-B9ho3BjU.js";
2
2
  import { t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-ZIcqybtn.js";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
package/lib/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as publicConfigPlugin, r as readPublicConfigKeys, t as createViteConfig } from "./vite-DXXr5In0.js";
2
- import { n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-BuYRXxFs.js";
1
+ import { n as publicConfigPlugin, r as readPublicConfigKeys, t as createViteConfig } from "./vite-CS7fRWSI.js";
2
+ import { n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-B9ho3BjU.js";
3
3
 
4
4
  export { createViteConfig, discoverPublicPackageRoots, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys };
@@ -208,17 +208,96 @@ function resolvePackageMainSource(pkgDir) {
208
208
  path.join(pkgDir, "index.tsx")
209
209
  ].find((c) => fs.existsSync(c));
210
210
  }
211
+ const webConditionOrder = [
212
+ "import",
213
+ "default",
214
+ "require"
215
+ ];
216
+ const skippedConditions = new Set(["types", "react-native"]);
217
+ const tsSourcePattern = /\.(c|m)?tsx?$/;
218
+ function collectExportTargets(target, out) {
219
+ if (typeof target === "string") {
220
+ out.push(target);
221
+ return;
222
+ }
223
+ if (!target) return;
224
+ if (Array.isArray(target)) {
225
+ for (const item of target) collectExportTargets(item, out);
226
+ return;
227
+ }
228
+ if (typeof target.source === "string") out.push(target.source);
229
+ const keys = Object.keys(target).filter((k) => k !== "source" && !skippedConditions.has(k));
230
+ const ordered = [...webConditionOrder.filter((k) => keys.includes(k)), ...keys.filter((k) => !webConditionOrder.includes(k))];
231
+ for (const key of ordered) collectExportTargets(target[key], out);
232
+ }
211
233
  /**
212
- * Vite `resolve.alias` entries: each public package name → its TypeScript main.
213
- * For SPA / ad-hoc Vite configs that should not list packages by hand.
234
+ * The file a web build should compile for one `exports` entry: its `source`
235
+ * condition, else the first TypeScript file among its web conditions, else
236
+ * the first existing file (css, a prebuilt .mjs), so the package-name alias
237
+ * never swallows a subpath it cannot see.
214
238
  */
215
- function publicPackageViteSourceAliases(workspaceRoot) {
239
+ function resolveExportSource(pkgDir, target) {
240
+ const candidates = [];
241
+ collectExportTargets(target, candidates);
242
+ const existing = candidates.map((c) => path.resolve(pkgDir, c)).filter((c) => !c.endsWith(".d.ts") && fs.existsSync(c) && fs.statSync(c).isFile());
243
+ return existing.find((c) => tsSourcePattern.test(c)) ?? existing[0];
244
+ }
245
+ /**
246
+ * Vite `resolve.alias` entries for one package's `exports` subpaths:
247
+ * `<name>/<subpath>` → its source file, and a `./dir/*` pattern → the directory.
248
+ */
249
+ function packageSubpathSourceAliases(pkgName, pkgDir, exportsField) {
216
250
  const aliases = {};
251
+ if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField)) return aliases;
252
+ for (const [key, target] of Object.entries(exportsField)) {
253
+ if (key === "." || key === "./package.json" || !key.startsWith("./")) continue;
254
+ if (key.endsWith("/*")) {
255
+ const pattern = key.slice(2, -2);
256
+ if (pattern.includes("*")) continue;
257
+ const targets = [];
258
+ collectExportTargets(target, targets);
259
+ const dirTarget = targets.find((t) => t.endsWith("/*"));
260
+ if (!dirTarget) continue;
261
+ const dir = path.resolve(pkgDir, dirTarget.slice(0, -2));
262
+ if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) aliases[`${pkgName}/${pattern}`] = dir;
263
+ continue;
264
+ }
265
+ if (key.includes("*")) continue;
266
+ const file = resolveExportSource(pkgDir, target);
267
+ if (file) aliases[`${pkgName}/${key.slice(2)}`] = file;
268
+ }
269
+ return aliases;
270
+ }
271
+ /**
272
+ * Vite `resolve.alias` entries: each public package name → its TypeScript
273
+ * main, plus every `exports` subpath → its own source file. For SPA / ad-hoc
274
+ * Vite configs that should not list packages by hand.
275
+ *
276
+ * Vite matches a string alias as a prefix at a `/` boundary and takes the
277
+ * first match, so a bare `@multiplatform.one/gpg` → `src/index.ts` entry
278
+ * rewrites `@multiplatform.one/gpg/signer` to `src/index.ts/signer` (MPO-391,
279
+ * MPO-323). Subpath entries are therefore emitted before every bare name,
280
+ * longest first.
281
+ */
282
+ function publicPackageViteSourceAliases(workspaceRoot) {
283
+ const subpaths = {};
284
+ const mains = {};
217
285
  for (const [name, dir] of discoverPublicPackageRoots(workspaceRoot)) {
218
286
  const main = resolvePackageMainSource(dir);
219
- if (main) aliases[name] = main;
287
+ if (main) mains[name] = main;
288
+ let exportsField;
289
+ try {
290
+ exportsField = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")).exports;
291
+ } catch {
292
+ continue;
293
+ }
294
+ Object.assign(subpaths, packageSubpathSourceAliases(name, dir, exportsField));
220
295
  }
221
- return aliases;
296
+ const ordered = Object.keys(subpaths).sort((a, b) => b.length - a.length);
297
+ return {
298
+ ...Object.fromEntries(ordered.map((k) => [k, subpaths[k]])),
299
+ ...mains
300
+ };
222
301
  }
223
302
 
224
303
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "7.20.0",
3
+ "version": "7.22.0",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -99,7 +99,7 @@
99
99
  "access": "public"
100
100
  },
101
101
  "dependencies": {
102
- "@multiplatform.one/utils": "7.20.0",
102
+ "@multiplatform.one/utils": "7.22.0",
103
103
  "@tamagui/vite-plugin": "2.7.6",
104
104
  "@vitejs/plugin-react": "^6.0.1",
105
105
  "dotenv": "^17.4.2",
@@ -1,12 +1,17 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { afterAll, describe, expect, it } from "vitest";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
2
4
  import path from "node:path";
3
5
  import {
4
6
  discoverPublicPackageRoots,
7
+ packageSubpathSourceAliases,
8
+ resolveExportSource,
5
9
  resolvePackageMainSource,
6
10
  publicPackageViteSourceAliases,
7
11
  } from "./workspacePublicPackages";
8
12
 
9
13
  const workspaceRoot = path.resolve(__dirname, "../../..");
14
+ const pub = (p: string) => path.join(workspaceRoot, "public", p);
10
15
 
11
16
  describe("discoverPublicPackageRoots", () => {
12
17
  it("returns a Map of package names to their directories", () => {
@@ -58,10 +63,74 @@ describe("publicPackageViteSourceAliases", () => {
58
63
  expect(Object.keys(aliases).length).toBeGreaterThan(0);
59
64
  });
60
65
 
61
- it("each alias value points to a .ts or .tsx file", () => {
66
+ it("each bare package alias points to a .ts or .tsx file", () => {
62
67
  const aliases = publicPackageViteSourceAliases(workspaceRoot);
63
- for (const [, filePath] of Object.entries(aliases)) {
64
- expect(filePath).toMatch(/\.(ts|tsx)$/);
68
+ for (const name of discoverPublicPackageRoots(workspaceRoot).keys()) {
69
+ if (aliases[name]) expect(aliases[name]).toMatch(/\.(ts|tsx)$/);
70
+ }
71
+ });
72
+
73
+ it("every alias value exists on disk", () => {
74
+ const aliases = publicPackageViteSourceAliases(workspaceRoot);
75
+ for (const [, target] of Object.entries(aliases)) {
76
+ expect(fs.existsSync(target)).toBe(true);
77
+ }
78
+ });
79
+
80
+ it("resolves the bare gpg package to src/index.ts and its signer subpath to src/signer.ts", () => {
81
+ const aliases = publicPackageViteSourceAliases(workspaceRoot);
82
+ expect(aliases["@multiplatform.one/gpg"]).toBe(pub("gpg/src/index.ts"));
83
+ expect(aliases["@multiplatform.one/gpg/signer"]).toBe(pub("gpg/src/signer.ts"));
84
+ });
85
+
86
+ it("resolves the web3 subpaths to their source files", () => {
87
+ const aliases = publicPackageViteSourceAliases(workspaceRoot);
88
+ expect(aliases["@multiplatform.one/web3/connectkit"]).toBe(pub("web3/src/connectkit/index.ts"));
89
+ expect(aliases["@multiplatform.one/web3/solana"]).toBe(pub("web3/src/solana.ts"));
90
+ });
91
+
92
+ it("derives every subpath apps/one used to alias by hand", () => {
93
+ const aliases = publicPackageViteSourceAliases(workspaceRoot);
94
+ expect(aliases).toMatchObject({
95
+ "@multiplatform.one/frappe/devtools": pub("frappe/src/devtools/index.ts"),
96
+ "@multiplatform.one/markdown/mermaid": pub("markdown/src/mermaid/index.ts"),
97
+ "@multiplatform.one/core/healthz": pub("core/src/healthz.ts"),
98
+ "@multiplatform.one/backoffice/one-adapter": pub("backoffice/src/oneAdapter/index.tsx"),
99
+ "@multiplatform.one/frappe-ui/dependsOn": pub("frappe-ui/src/dependsOn.ts"),
100
+ "@multiplatform.one/frappe-ui/formActions": pub("frappe-ui/src/formEngine/formActions.ts"),
101
+ "@multiplatform.one/platform/file": pub("platform/src/file/index.ts"),
102
+ "@multiplatform.one/frappe-ui/src": pub("frappe-ui/src"),
103
+ });
104
+ });
105
+
106
+ it("orders every subpath alias before every bare package alias", () => {
107
+ const keys = Object.keys(publicPackageViteSourceAliases(workspaceRoot));
108
+ const roots = discoverPublicPackageRoots(workspaceRoot);
109
+ const firstBare = keys.findIndex((k) => roots.has(k));
110
+ const lastSubpath = keys.reduce((last, k, i) => (roots.has(k) ? last : i), -1);
111
+ expect(firstBare).toBeGreaterThan(lastSubpath);
112
+ });
113
+
114
+ it("resolves every exported subpath specifier to a real file under Vite's first-match prefix rule", () => {
115
+ const aliases = Object.entries(publicPackageViteSourceAliases(workspaceRoot));
116
+ const viteResolve = (spec: string) => {
117
+ const hit = aliases.find(([find]) => spec === find || spec.startsWith(`${find}/`));
118
+ return hit ? spec.replace(hit[0], hit[1]) : undefined;
119
+ };
120
+ for (const [name, dir] of discoverPublicPackageRoots(workspaceRoot)) {
121
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
122
+ if (!pkg.exports || typeof pkg.exports !== "object") continue;
123
+ for (const [key, target] of Object.entries(pkg.exports)) {
124
+ if (key === "." || key === "./package.json" || key.includes("*")) continue;
125
+ const typesOnly =
126
+ typeof target === "object" && target !== null && Object.keys(target).join() === "types";
127
+ if (typesOnly) continue;
128
+ const spec = `${name}/${key.slice(2)}`;
129
+ const resolved = viteResolve(spec);
130
+ if (resolved === undefined) continue;
131
+ const isFile = fs.existsSync(resolved) && fs.statSync(resolved).isFile();
132
+ expect({ spec, isFile }).toEqual({ spec, isFile: true });
133
+ }
65
134
  }
66
135
  });
67
136
 
@@ -70,3 +139,78 @@ describe("publicPackageViteSourceAliases", () => {
70
139
  expect(aliases["@multiplatform.one/platform"]).toBeDefined();
71
140
  });
72
141
  });
142
+
143
+ describe("packageSubpathSourceAliases", () => {
144
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "mpo-subpath-"));
145
+ const touch = (p: string) => {
146
+ fs.mkdirSync(path.dirname(path.join(dir, p)), { recursive: true });
147
+ fs.writeFileSync(path.join(dir, p), "");
148
+ };
149
+ touch("src/index.ts");
150
+ touch("src/signer.ts");
151
+ touch("src/one.ts");
152
+ touch("src/deep/entry.tsx");
153
+ touch("css/theme.css");
154
+ touch("dist/esm/signer.mjs");
155
+ afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
156
+
157
+ it("maps a subpath to its source condition, not its dist import", () => {
158
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, {
159
+ ".": { source: "./src/index.ts", import: "./dist/esm/index.mjs" },
160
+ "./signer": {
161
+ source: "./src/signer.ts",
162
+ types: "./types/signer.d.ts",
163
+ import: "./dist/esm/signer.mjs",
164
+ },
165
+ });
166
+ expect(aliases).toEqual({ "@x/pkg/signer": path.join(dir, "src/signer.ts") });
167
+ });
168
+
169
+ it("falls back to a TypeScript file among the web conditions when there is no source", () => {
170
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, {
171
+ "./one": { types: "./types/one.d.ts", import: "./src/one.ts", require: "./src/one.ts" },
172
+ });
173
+ expect(aliases["@x/pkg/one"]).toBe(path.join(dir, "src/one.ts"));
174
+ });
175
+
176
+ it("ignores the react-native branch on the web", () => {
177
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, {
178
+ "./deep": {
179
+ "react-native": { import: "./src/one.ts" },
180
+ default: "./src/deep/entry.tsx",
181
+ },
182
+ });
183
+ expect(aliases["@x/pkg/deep"]).toBe(path.join(dir, "src/deep/entry.tsx"));
184
+ });
185
+
186
+ it("keeps a non-source subpath on its real file so the bare alias cannot swallow it", () => {
187
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, {
188
+ "./css/theme.css": { import: "./css/theme.css" },
189
+ });
190
+ expect(aliases["@x/pkg/css/theme.css"]).toBe(path.join(dir, "css/theme.css"));
191
+ });
192
+
193
+ it("maps a directory wildcard to the directory", () => {
194
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, { "./src/*": "./src/*" });
195
+ expect(aliases["@x/pkg/src"]).toBe(path.join(dir, "src"));
196
+ });
197
+
198
+ it("skips types-only and missing targets", () => {
199
+ const aliases = packageSubpathSourceAliases("@x/pkg", dir, {
200
+ "./types-only": { types: "./src/overrides.d.ts" },
201
+ "./missing": { source: "./src/nope.ts", import: "./dist/esm/nope.mjs" },
202
+ });
203
+ expect(aliases).toEqual({});
204
+ });
205
+
206
+ it("returns nothing for a string or absent exports field", () => {
207
+ expect(packageSubpathSourceAliases("@x/pkg", dir, "./src/index.ts")).toEqual({});
208
+ expect(packageSubpathSourceAliases("@x/pkg", dir, undefined)).toEqual({});
209
+ });
210
+
211
+ it("resolveExportSource prefers TypeScript over an existing dist file", () => {
212
+ expect(
213
+ resolveExportSource(dir, { import: "./dist/esm/signer.mjs", default: "./src/signer.ts" }),
214
+ ).toBe(path.join(dir, "src/signer.ts"));
215
+ });
216
+ });
@@ -56,15 +56,113 @@ export function resolvePackageMainSource(pkgDir: string): string | undefined {
56
56
  return candidates.find((c) => fs.existsSync(c));
57
57
  }
58
58
 
59
+ type ExportTarget = string | null | ExportTarget[] | { [condition: string]: ExportTarget };
60
+
61
+ const webConditionOrder = ["import", "default", "require"];
62
+ const skippedConditions = new Set(["types", "react-native"]);
63
+ const tsSourcePattern = /\.(c|m)?tsx?$/;
64
+
65
+ function collectExportTargets(target: ExportTarget, out: string[]): void {
66
+ if (typeof target === "string") {
67
+ out.push(target);
68
+ return;
69
+ }
70
+ if (!target) return;
71
+ if (Array.isArray(target)) {
72
+ for (const item of target) collectExportTargets(item, out);
73
+ return;
74
+ }
75
+ if (typeof target.source === "string") out.push(target.source);
76
+ const keys = Object.keys(target).filter((k) => k !== "source" && !skippedConditions.has(k));
77
+ const ordered = [
78
+ ...webConditionOrder.filter((k) => keys.includes(k)),
79
+ ...keys.filter((k) => !webConditionOrder.includes(k)),
80
+ ];
81
+ for (const key of ordered) collectExportTargets(target[key], out);
82
+ }
83
+
59
84
  /**
60
- * Vite `resolve.alias` entries: each public package name → its TypeScript main.
61
- * For SPA / ad-hoc Vite configs that should not list packages by hand.
85
+ * The file a web build should compile for one `exports` entry: its `source`
86
+ * condition, else the first TypeScript file among its web conditions, else
87
+ * the first existing file (css, a prebuilt .mjs), so the package-name alias
88
+ * never swallows a subpath it cannot see.
62
89
  */
63
- export function publicPackageViteSourceAliases(workspaceRoot: string): Record<string, string> {
90
+ export function resolveExportSource(pkgDir: string, target: ExportTarget): string | undefined {
91
+ const candidates: string[] = [];
92
+ collectExportTargets(target, candidates);
93
+ const existing = candidates
94
+ .map((c) => path.resolve(pkgDir, c))
95
+ .filter((c) => !c.endsWith(".d.ts") && fs.existsSync(c) && fs.statSync(c).isFile());
96
+ return existing.find((c) => tsSourcePattern.test(c)) ?? existing[0];
97
+ }
98
+
99
+ /**
100
+ * Vite `resolve.alias` entries for one package's `exports` subpaths:
101
+ * `<name>/<subpath>` → its source file, and a `./dir/*` pattern → the directory.
102
+ */
103
+ export function packageSubpathSourceAliases(
104
+ pkgName: string,
105
+ pkgDir: string,
106
+ exportsField: unknown,
107
+ ): Record<string, string> {
64
108
  const aliases: Record<string, string> = {};
109
+ if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField)) {
110
+ return aliases;
111
+ }
112
+ for (const [key, target] of Object.entries(exportsField as Record<string, ExportTarget>)) {
113
+ if (key === "." || key === "./package.json" || !key.startsWith("./")) continue;
114
+ if (key.endsWith("/*")) {
115
+ const pattern = key.slice(2, -2);
116
+ if (pattern.includes("*")) continue;
117
+ const targets: string[] = [];
118
+ collectExportTargets(target, targets);
119
+ const dirTarget = targets.find((t) => t.endsWith("/*"));
120
+ if (!dirTarget) continue;
121
+ const dir = path.resolve(pkgDir, dirTarget.slice(0, -2));
122
+ if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
123
+ aliases[`${pkgName}/${pattern}`] = dir;
124
+ }
125
+ continue;
126
+ }
127
+ if (key.includes("*")) continue;
128
+ const file = resolveExportSource(pkgDir, target);
129
+ if (file) aliases[`${pkgName}/${key.slice(2)}`] = file;
130
+ }
131
+ return aliases;
132
+ }
133
+
134
+ /**
135
+ * Vite `resolve.alias` entries: each public package name → its TypeScript
136
+ * main, plus every `exports` subpath → its own source file. For SPA / ad-hoc
137
+ * Vite configs that should not list packages by hand.
138
+ *
139
+ * Vite matches a string alias as a prefix at a `/` boundary and takes the
140
+ * first match, so a bare `@multiplatform.one/gpg` → `src/index.ts` entry
141
+ * rewrites `@multiplatform.one/gpg/signer` to `src/index.ts/signer` (MPO-391,
142
+ * MPO-323). Subpath entries are therefore emitted before every bare name,
143
+ * longest first.
144
+ */
145
+ export function publicPackageViteSourceAliases(workspaceRoot: string): Record<string, string> {
146
+ const subpaths: Record<string, string> = {};
147
+ const mains: Record<string, string> = {};
65
148
  for (const [name, dir] of discoverPublicPackageRoots(workspaceRoot)) {
66
149
  const main = resolvePackageMainSource(dir);
67
- if (main) aliases[name] = main;
150
+ if (main) mains[name] = main;
151
+ let exportsField: unknown;
152
+ try {
153
+ exportsField = (
154
+ JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")) as {
155
+ exports?: unknown;
156
+ }
157
+ ).exports;
158
+ } catch {
159
+ continue;
160
+ }
161
+ Object.assign(subpaths, packageSubpathSourceAliases(name, dir, exportsField));
68
162
  }
69
- return aliases;
163
+ const ordered = Object.keys(subpaths).sort((a, b) => b.length - a.length);
164
+ return {
165
+ ...Object.fromEntries(ordered.map((k) => [k, subpaths[k] as string])),
166
+ ...mains,
167
+ };
70
168
  }
@@ -16,9 +16,32 @@ export declare function discoverPublicPackageRoots(workspaceRoot: string): Map<s
16
16
  * web-only side effects (fontsource @font-face CSS imports) never load.
17
17
  */
18
18
  export declare function resolvePackageMainSource(pkgDir: string): string | undefined;
19
+ type ExportTarget = string | null | ExportTarget[] | {
20
+ [condition: string]: ExportTarget;
21
+ };
19
22
  /**
20
- * Vite `resolve.alias` entries: each public package name → its TypeScript main.
21
- * For SPA / ad-hoc Vite configs that should not list packages by hand.
23
+ * The file a web build should compile for one `exports` entry: its `source`
24
+ * condition, else the first TypeScript file among its web conditions, else
25
+ * the first existing file (css, a prebuilt .mjs), so the package-name alias
26
+ * never swallows a subpath it cannot see.
27
+ */
28
+ export declare function resolveExportSource(pkgDir: string, target: ExportTarget): string | undefined;
29
+ /**
30
+ * Vite `resolve.alias` entries for one package's `exports` subpaths:
31
+ * `<name>/<subpath>` → its source file, and a `./dir/*` pattern → the directory.
32
+ */
33
+ export declare function packageSubpathSourceAliases(pkgName: string, pkgDir: string, exportsField: unknown): Record<string, string>;
34
+ /**
35
+ * Vite `resolve.alias` entries: each public package name → its TypeScript
36
+ * main, plus every `exports` subpath → its own source file. For SPA / ad-hoc
37
+ * Vite configs that should not list packages by hand.
38
+ *
39
+ * Vite matches a string alias as a prefix at a `/` boundary and takes the
40
+ * first match, so a bare `@multiplatform.one/gpg` → `src/index.ts` entry
41
+ * rewrites `@multiplatform.one/gpg/signer` to `src/index.ts/signer` (MPO-391,
42
+ * MPO-323). Subpath entries are therefore emitted before every bare name,
43
+ * longest first.
22
44
  */
23
45
  export declare function publicPackageViteSourceAliases(workspaceRoot: string): Record<string, string>;
46
+ export {};
24
47
  //# sourceMappingURL=workspacePublicPackages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspacePublicPackages.d.ts","sourceRoot":"","sources":["../src/workspacePublicPackages.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBrF;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgB3E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO5F"}
1
+ {"version":3,"file":"workspacePublicPackages.d.ts","sourceRoot":"","sources":["../src/workspacePublicPackages.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBrF;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgB3E;AAED,KAAK,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,EAAE,GAAG;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAyB3F;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAO5F;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuB5F"}