@multiplatform.one/config 7.31.0 → 7.32.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 +3 -3
- package/lib/{storybook-CWDetyRO.js → storybook-Dxwh_fl2.js} +1 -1
- package/lib/storybook.js +1 -1
- package/lib/{tamaguiWorkspacePaths-2mDESDbT.js → tamaguiWorkspacePaths-B6aRC2BU.js} +79 -5
- package/lib/{vite-DZwt8mk9.js → vite-D0MOGcSZ.js} +1 -1
- package/lib/vite.js +2 -2
- package/lib/vitest.js +6 -2
- package/package.json +2 -2
- package/src/phosphorTokenColor.spec.ts +52 -3
- package/src/phosphorTokenColor.ts +84 -3
- package/src/vitest.ts +2 -1
- package/types/phosphorTokenColor.d.ts +14 -3
- package/types/phosphorTokenColor.d.ts.map +1 -1
- package/types/vitest.d.ts.map +1 -1
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createViteConfig } from "./vite-
|
|
2
|
-
import {
|
|
3
|
-
import { t as createStorybookViteConfig } from "./storybook-
|
|
1
|
+
import { t as createViteConfig } from "./vite-D0MOGcSZ.js";
|
|
2
|
+
import { i as phosphorTokenColorPlugin, n as tamaguiWorkspacePathsFile, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-B6aRC2BU.js";
|
|
3
|
+
import { t as createStorybookViteConfig } from "./storybook-Dxwh_fl2.js";
|
|
4
4
|
import { createVitestConfig } from "./vitest.js";
|
|
5
5
|
|
|
6
6
|
export { createStorybookViteConfig, createViteConfig, createVitestConfig, ensureTamaguiWorkspacePaths, phosphorTokenColorPlugin, tamaguiWorkspacePathsFile };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-B6aRC2BU.js";
|
|
2
2
|
import { i as withSingletonDepAliases, r as resolvePackageMainSource, t as discoverPublicPackageRoots } from "./workspacePublicPackages-ClSmVngx.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
package/lib/storybook.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import Module from "node:module";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
5
|
import { execFileSync } from "node:child_process";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
6
7
|
//#region src/phosphorTokenColor.ts
|
|
7
8
|
const virtualPrefix = "\0mpo-phosphor-token-icon-base:";
|
|
8
9
|
const iconBaseFilter = /IconBase\.es\.js$/;
|
|
9
10
|
const phosphorLibFile = /\/@phosphor-icons\/react\/dist\/lib\/IconBase\.es\.js$/;
|
|
11
|
+
const phosphorBarrelFile = /\/@phosphor-icons\/react\/dist\/index\.es\.js$/;
|
|
10
12
|
const virtualIdFilter = new RegExp(`^${virtualPrefix}`);
|
|
11
13
|
/**
|
|
12
14
|
* Where a caller's `color` becomes a paint. Tamagui tokens ("$color9",
|
|
@@ -83,9 +85,10 @@ function rolldownTokenColorPlugin() {
|
|
|
83
85
|
* fell back to black and vanished on the dark scheme. This swaps that one
|
|
84
86
|
* module for a wrapper that resolves the token first, so no call site has to.
|
|
85
87
|
*
|
|
86
|
-
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined
|
|
87
|
-
* and inside the dev dep optimizer, which
|
|
88
|
-
* never consults Vite plugins for a
|
|
88
|
+
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined,
|
|
89
|
+
* see phosphorBarrelBundlePlugin) and inside the dev dep optimizer, which
|
|
90
|
+
* bundles phosphor with rolldown and never consults Vite plugins for a
|
|
91
|
+
* dependency's relative imports.
|
|
89
92
|
*/
|
|
90
93
|
function phosphorTokenColorPlugin() {
|
|
91
94
|
return {
|
|
@@ -104,6 +107,77 @@ function phosphorTokenColorPlugin() {
|
|
|
104
107
|
}
|
|
105
108
|
};
|
|
106
109
|
}
|
|
110
|
+
let rolldownLoad;
|
|
111
|
+
function loadRolldown() {
|
|
112
|
+
rolldownLoad ??= (async () => {
|
|
113
|
+
try {
|
|
114
|
+
const vite = Module.createRequire(import.meta.url).resolve("vite/package.json");
|
|
115
|
+
return (await import(pathToFileURL(Module.createRequire(vite).resolve("rolldown")).href)).rolldown;
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
})();
|
|
120
|
+
return rolldownLoad;
|
|
121
|
+
}
|
|
122
|
+
async function rollUpBarrel(barrel) {
|
|
123
|
+
const rolldown = await loadRolldown();
|
|
124
|
+
if (!rolldown) return null;
|
|
125
|
+
const lib = `${path.posix.dirname(barrel)}/lib/`;
|
|
126
|
+
const bundle = await rolldown({
|
|
127
|
+
input: barrel,
|
|
128
|
+
logLevel: "silent",
|
|
129
|
+
treeshake: false,
|
|
130
|
+
external: (id) => !id.startsWith(".") && !path.isAbsolute(id),
|
|
131
|
+
plugins: [{
|
|
132
|
+
name: "mpo-phosphor-barrel:lib",
|
|
133
|
+
resolveId(source, importer) {
|
|
134
|
+
if (!importer || !source.startsWith(".")) return null;
|
|
135
|
+
const file = toPosix(path.resolve(path.dirname(importer), source));
|
|
136
|
+
return file.startsWith(lib) ? {
|
|
137
|
+
id: file,
|
|
138
|
+
external: true
|
|
139
|
+
} : null;
|
|
140
|
+
}
|
|
141
|
+
}]
|
|
142
|
+
});
|
|
143
|
+
try {
|
|
144
|
+
const { output } = await bundle.generate({
|
|
145
|
+
format: "esm",
|
|
146
|
+
file: barrel
|
|
147
|
+
});
|
|
148
|
+
return output[0]?.code ?? null;
|
|
149
|
+
} finally {
|
|
150
|
+
await bundle.close();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Serves `@phosphor-icons/react`'s barrel to vitest as one module (MPO-482).
|
|
155
|
+
* The IconBase swap needs phosphor inlined, and inlined module by module the
|
|
156
|
+
* barrel costs 4,542 transforms per spec run. Rolled up, the icons are one
|
|
157
|
+
* module that still imports `./lib/*` from disk: IconBase resolves through
|
|
158
|
+
* phosphorTokenColorPlugin, IconContext stays one instance, and the id
|
|
159
|
+
* `vi.mock("@phosphor-icons/react")` targets does not change. Without rolldown
|
|
160
|
+
* the barrel loads as it ships.
|
|
161
|
+
*/
|
|
162
|
+
function phosphorBarrelBundlePlugin() {
|
|
163
|
+
const bundles = /* @__PURE__ */ new Map();
|
|
164
|
+
return {
|
|
165
|
+
name: "mpo-phosphor-barrel-bundle",
|
|
166
|
+
enforce: "pre",
|
|
167
|
+
load: {
|
|
168
|
+
filter: { id: phosphorBarrelFile },
|
|
169
|
+
handler(id) {
|
|
170
|
+
const barrel = toPosix(id);
|
|
171
|
+
let bundle = bundles.get(barrel);
|
|
172
|
+
if (!bundle) {
|
|
173
|
+
bundle = rollUpBarrel(barrel).catch(() => null);
|
|
174
|
+
bundles.set(barrel, bundle);
|
|
175
|
+
}
|
|
176
|
+
return bundle;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
107
181
|
|
|
108
182
|
//#endregion
|
|
109
183
|
//#region src/tamaguiWorkspacePaths.ts
|
|
@@ -158,4 +232,4 @@ function ensureTamaguiWorkspacePaths(options = {}) {
|
|
|
158
232
|
}
|
|
159
233
|
|
|
160
234
|
//#endregion
|
|
161
|
-
export { tamaguiWorkspacePathsFile as n,
|
|
235
|
+
export { phosphorTokenColorPlugin as i, tamaguiWorkspacePathsFile as n, phosphorBarrelBundlePlugin as r, ensureTamaguiWorkspacePaths as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as phosphorTokenColorPlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-B6aRC2BU.js";
|
|
2
2
|
import { i as withSingletonDepAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-ClSmVngx.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
package/lib/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as publicConfigPlugin, r as readPublicConfigKeys, t as createViteConfig } from "./vite-
|
|
2
|
-
import {
|
|
1
|
+
import { n as publicConfigPlugin, r as readPublicConfigKeys, t as createViteConfig } from "./vite-D0MOGcSZ.js";
|
|
2
|
+
import { i as phosphorTokenColorPlugin } from "./tamaguiWorkspacePaths-B6aRC2BU.js";
|
|
3
3
|
import { n as publicPackageViteSourceAliases, t as discoverPublicPackageRoots } from "./workspacePublicPackages-ClSmVngx.js";
|
|
4
4
|
|
|
5
5
|
export { createViteConfig, discoverPublicPackageRoots, phosphorTokenColorPlugin, publicConfigPlugin, publicPackageViteSourceAliases, readPublicConfigKeys };
|
package/lib/vitest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as phosphorTokenColorPlugin, r as phosphorBarrelBundlePlugin, t as ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths-B6aRC2BU.js";
|
|
2
2
|
import Module from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -55,7 +55,11 @@ function createVitestConfig(options = {}) {
|
|
|
55
55
|
"browser"
|
|
56
56
|
], include, exclude, passWithNoTests } = options;
|
|
57
57
|
const rootNodeModules = _rootNodeModules || path.resolve(process.cwd(), "../../node_modules");
|
|
58
|
-
const plugins = [
|
|
58
|
+
const plugins = [
|
|
59
|
+
react({ jsxRuntime: "automatic" }),
|
|
60
|
+
phosphorTokenColorPlugin(),
|
|
61
|
+
phosphorBarrelBundlePlugin()
|
|
62
|
+
];
|
|
59
63
|
if (replaceReactNative) plugins.push({
|
|
60
64
|
name: "replace-react-native",
|
|
61
65
|
transform(code, id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/config",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.32.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.
|
|
102
|
+
"@multiplatform.one/utils": "7.32.0",
|
|
103
103
|
"@tamagui/vite-plugin": "2.7.6",
|
|
104
104
|
"@vitejs/plugin-react": "^6.0.1",
|
|
105
105
|
"dotenv": "^17.4.2",
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* public/components/src/icons/phosphorTokenColor.spec.tsx; these hold the
|
|
5
5
|
* swap to phosphor's own IconBase and to every web config factory.
|
|
6
6
|
*/
|
|
7
|
+
import Module from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
7
9
|
import { describe, expect, it } from "vitest";
|
|
8
10
|
import { resolveConfig, type Plugin } from "vite";
|
|
9
|
-
import { phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
|
|
11
|
+
import { phosphorBarrelBundlePlugin, phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
|
|
10
12
|
import { createStorybookViteConfig } from "./storybook.js";
|
|
11
13
|
import { createViteConfig } from "./vite.js";
|
|
12
14
|
import { createVitestConfig } from "./vitest.js";
|
|
@@ -21,10 +23,10 @@ function hook(plugin: { resolveId?: unknown; load?: unknown }, name: "resolveId"
|
|
|
21
23
|
return typeof value === "function" ? value : value.handler;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
function hasPlugin(plugins: unknown): boolean {
|
|
26
|
+
function hasPlugin(plugins: unknown, name = "mpo-phosphor-token-color"): boolean {
|
|
25
27
|
return (plugins as unknown[])
|
|
26
28
|
.flat(Infinity)
|
|
27
|
-
.some((p) => (p as { name?: string } | null)?.name ===
|
|
29
|
+
.some((p) => (p as { name?: string } | null)?.name === name);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
describe("phosphorTokenColorPlugin", () => {
|
|
@@ -83,8 +85,55 @@ describe("phosphorTokenColorPlugin", () => {
|
|
|
83
85
|
expect(hasPlugin(createStorybookViteConfig().plugins)).toBe(true);
|
|
84
86
|
const vitest = createVitestConfig({ tamaguiConfig: false, dedupeReact: false });
|
|
85
87
|
expect(hasPlugin(vitest.plugins)).toBe(true);
|
|
88
|
+
expect(hasPlugin(vitest.plugins, "mpo-phosphor-barrel-bundle")).toBe(true);
|
|
86
89
|
const inline = (vitest as { test: { server: { deps: { inline: unknown[] } } } }).test.server
|
|
87
90
|
.deps.inline;
|
|
88
91
|
expect(inline).toContain("@phosphor-icons/react");
|
|
89
92
|
});
|
|
90
93
|
});
|
|
94
|
+
|
|
95
|
+
describe("phosphorBarrelBundlePlugin (MPO-482)", () => {
|
|
96
|
+
const plugin = phosphorBarrelBundlePlugin();
|
|
97
|
+
const { filter, handler } = plugin.load as unknown as {
|
|
98
|
+
filter: { id: RegExp };
|
|
99
|
+
handler: (id: string) => Promise<string | null>;
|
|
100
|
+
};
|
|
101
|
+
const barrel = path.join(
|
|
102
|
+
path.dirname(
|
|
103
|
+
Module.createRequire(import.meta.url).resolve("@phosphor-icons/react/package.json"),
|
|
104
|
+
),
|
|
105
|
+
"dist/index.es.js",
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
it("only takes phosphor's ESM barrel", () => {
|
|
109
|
+
expect(filter.id.test(`${dist}/index.es.js`)).toBe(true);
|
|
110
|
+
expect(filter.id.test(`${dist}/csr/Heart.es.js`)).toBe(false);
|
|
111
|
+
expect(filter.id.test(`${dist}/index.cjs.js`)).toBe(false);
|
|
112
|
+
expect(filter.id.test(`${dist}/index.es.js?v=1a2b`)).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("rolls the icons into one module that still imports ./lib from disk", async () => {
|
|
116
|
+
const code = (await handler(barrel)) ?? "";
|
|
117
|
+
const sources = new Set([...code.matchAll(/^import .* from "([^"]+)";$/gm)].map((m) => m[1]));
|
|
118
|
+
expect([...sources].sort()).toEqual([
|
|
119
|
+
"./lib/IconBase.es.js",
|
|
120
|
+
"./lib/SSRBase.es.js",
|
|
121
|
+
"./lib/context.es.js",
|
|
122
|
+
"react",
|
|
123
|
+
]);
|
|
124
|
+
for (const name of [
|
|
125
|
+
"HeartIcon",
|
|
126
|
+
"FolderIcon",
|
|
127
|
+
"ActivityIcon",
|
|
128
|
+
"IconBase",
|
|
129
|
+
"IconContext",
|
|
130
|
+
"SSR",
|
|
131
|
+
]) {
|
|
132
|
+
expect(code).toMatch(new RegExp(`\\bas ${name}\\b`));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("rolls each barrel up once per run", () => {
|
|
137
|
+
expect(handler(barrel)).toBe(handler(barrel));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import Module from "node:module";
|
|
1
2
|
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
2
4
|
import type { Plugin } from "vite";
|
|
3
5
|
|
|
4
6
|
const virtualPrefix = "\0mpo-phosphor-token-icon-base:";
|
|
5
7
|
const iconBaseFilter = /IconBase\.es\.js$/;
|
|
6
8
|
const phosphorLibFile = /\/@phosphor-icons\/react\/dist\/lib\/IconBase\.es\.js$/;
|
|
9
|
+
const phosphorBarrelFile = /\/@phosphor-icons\/react\/dist\/index\.es\.js$/;
|
|
7
10
|
const virtualIdFilter = new RegExp(`^${virtualPrefix}`);
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -89,9 +92,10 @@ function rolldownTokenColorPlugin() {
|
|
|
89
92
|
* fell back to black and vanished on the dark scheme. This swaps that one
|
|
90
93
|
* module for a wrapper that resolves the token first, so no call site has to.
|
|
91
94
|
*
|
|
92
|
-
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined
|
|
93
|
-
* and inside the dev dep optimizer, which
|
|
94
|
-
* never consults Vite plugins for a
|
|
95
|
+
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined,
|
|
96
|
+
* see phosphorBarrelBundlePlugin) and inside the dev dep optimizer, which
|
|
97
|
+
* bundles phosphor with rolldown and never consults Vite plugins for a
|
|
98
|
+
* dependency's relative imports.
|
|
95
99
|
*/
|
|
96
100
|
export function phosphorTokenColorPlugin(): Plugin {
|
|
97
101
|
return {
|
|
@@ -110,3 +114,80 @@ export function phosphorTokenColorPlugin(): Plugin {
|
|
|
110
114
|
},
|
|
111
115
|
};
|
|
112
116
|
}
|
|
117
|
+
|
|
118
|
+
type Rolldown = (options: Record<string, unknown>) => Promise<{
|
|
119
|
+
generate(options: Record<string, unknown>): Promise<{ output: Array<{ code?: string }> }>;
|
|
120
|
+
close(): Promise<void>;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
let rolldownLoad: Promise<Rolldown | null> | undefined;
|
|
124
|
+
|
|
125
|
+
function loadRolldown(): Promise<Rolldown | null> {
|
|
126
|
+
rolldownLoad ??= (async () => {
|
|
127
|
+
try {
|
|
128
|
+
const vite = Module.createRequire(import.meta.url).resolve("vite/package.json");
|
|
129
|
+
const entry = Module.createRequire(vite).resolve("rolldown");
|
|
130
|
+
return ((await import(pathToFileURL(entry).href)) as { rolldown: Rolldown }).rolldown;
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
})();
|
|
135
|
+
return rolldownLoad;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function rollUpBarrel(barrel: string): Promise<string | null> {
|
|
139
|
+
const rolldown = await loadRolldown();
|
|
140
|
+
if (!rolldown) return null;
|
|
141
|
+
const lib = `${path.posix.dirname(barrel)}/lib/`;
|
|
142
|
+
const bundle = await rolldown({
|
|
143
|
+
input: barrel,
|
|
144
|
+
logLevel: "silent",
|
|
145
|
+
treeshake: false,
|
|
146
|
+
external: (id: string) => !id.startsWith(".") && !path.isAbsolute(id),
|
|
147
|
+
plugins: [
|
|
148
|
+
{
|
|
149
|
+
name: "mpo-phosphor-barrel:lib",
|
|
150
|
+
resolveId(source: string, importer: string | undefined) {
|
|
151
|
+
if (!importer || !source.startsWith(".")) return null;
|
|
152
|
+
const file = toPosix(path.resolve(path.dirname(importer), source));
|
|
153
|
+
return file.startsWith(lib) ? { id: file, external: true } : null;
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const { output } = await bundle.generate({ format: "esm", file: barrel });
|
|
160
|
+
return output[0]?.code ?? null;
|
|
161
|
+
} finally {
|
|
162
|
+
await bundle.close();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Serves `@phosphor-icons/react`'s barrel to vitest as one module (MPO-482).
|
|
168
|
+
* The IconBase swap needs phosphor inlined, and inlined module by module the
|
|
169
|
+
* barrel costs 4,542 transforms per spec run. Rolled up, the icons are one
|
|
170
|
+
* module that still imports `./lib/*` from disk: IconBase resolves through
|
|
171
|
+
* phosphorTokenColorPlugin, IconContext stays one instance, and the id
|
|
172
|
+
* `vi.mock("@phosphor-icons/react")` targets does not change. Without rolldown
|
|
173
|
+
* the barrel loads as it ships.
|
|
174
|
+
*/
|
|
175
|
+
export function phosphorBarrelBundlePlugin(): Plugin {
|
|
176
|
+
const bundles = new Map<string, Promise<string | null>>();
|
|
177
|
+
return {
|
|
178
|
+
name: "mpo-phosphor-barrel-bundle",
|
|
179
|
+
enforce: "pre",
|
|
180
|
+
load: {
|
|
181
|
+
filter: { id: phosphorBarrelFile },
|
|
182
|
+
handler(id) {
|
|
183
|
+
const barrel = toPosix(id);
|
|
184
|
+
let bundle = bundles.get(barrel);
|
|
185
|
+
if (!bundle) {
|
|
186
|
+
bundle = rollUpBarrel(barrel).catch(() => null);
|
|
187
|
+
bundles.set(barrel, bundle);
|
|
188
|
+
}
|
|
189
|
+
return bundle;
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
package/src/vitest.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { tamaguiPlugin } from "@tamagui/vite-plugin";
|
|
6
6
|
import react from "@vitejs/plugin-react";
|
|
7
7
|
import type { UserConfig } from "vite";
|
|
8
|
-
import { phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
|
|
8
|
+
import { phosphorBarrelBundlePlugin, phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
|
|
9
9
|
import { ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths.js";
|
|
10
10
|
|
|
11
11
|
const pinReactRequireSetup = path.resolve(
|
|
@@ -189,6 +189,7 @@ export function createVitestConfig(options: CreateVitestConfigOptions = {}): Use
|
|
|
189
189
|
jsxRuntime: "automatic",
|
|
190
190
|
}),
|
|
191
191
|
phosphorTokenColorPlugin(),
|
|
192
|
+
phosphorBarrelBundlePlugin(),
|
|
192
193
|
];
|
|
193
194
|
|
|
194
195
|
// Replace react-native imports with react-native-web
|
|
@@ -9,9 +9,20 @@ import type { Plugin } from "vite";
|
|
|
9
9
|
* fell back to black and vanished on the dark scheme. This swaps that one
|
|
10
10
|
* module for a wrapper that resolves the token first, so no call site has to.
|
|
11
11
|
*
|
|
12
|
-
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined
|
|
13
|
-
* and inside the dev dep optimizer, which
|
|
14
|
-
* never consults Vite plugins for a
|
|
12
|
+
* The swap runs in the plugin pipeline (build, vitest with phosphor inlined,
|
|
13
|
+
* see phosphorBarrelBundlePlugin) and inside the dev dep optimizer, which
|
|
14
|
+
* bundles phosphor with rolldown and never consults Vite plugins for a
|
|
15
|
+
* dependency's relative imports.
|
|
15
16
|
*/
|
|
16
17
|
export declare function phosphorTokenColorPlugin(): Plugin;
|
|
18
|
+
/**
|
|
19
|
+
* Serves `@phosphor-icons/react`'s barrel to vitest as one module (MPO-482).
|
|
20
|
+
* The IconBase swap needs phosphor inlined, and inlined module by module the
|
|
21
|
+
* barrel costs 4,542 transforms per spec run. Rolled up, the icons are one
|
|
22
|
+
* module that still imports `./lib/*` from disk: IconBase resolves through
|
|
23
|
+
* phosphorTokenColorPlugin, IconContext stays one instance, and the id
|
|
24
|
+
* `vi.mock("@phosphor-icons/react")` targets does not change. Without rolldown
|
|
25
|
+
* the barrel loads as it ships.
|
|
26
|
+
*/
|
|
27
|
+
export declare function phosphorBarrelBundlePlugin(): Plugin;
|
|
17
28
|
//# sourceMappingURL=phosphorTokenColor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phosphorTokenColor.d.ts","sourceRoot":"","sources":["../src/phosphorTokenColor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phosphorTokenColor.d.ts","sourceRoot":"","sources":["../src/phosphorTokenColor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAiFnC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAgBjD;AAkDD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAkBnD"}
|
package/types/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAsDvC,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;IAE7C;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU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