@multiplatform.one/config 9.17.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/design-lint.mjs +29 -6
- package/lib/index.js +4 -4
- package/lib/{storybook-BpaziEtP.js → storybook-LYamvanr.js} +13 -9
- package/lib/storybook.js +1 -1
- package/lib/{tamaguiWorkspacePaths-DR3dud79.js → tamaguiWorkspacePaths-7eT9XxzE.js} +9 -6
- package/lib/{vite-CgiDLR6V.js → vite-BtlhFd_U.js} +40 -52
- package/lib/vite.js +4 -4
- package/lib/{vitest-B2vcGrZM.js → vitest-B8Z8ZZQR.js} +97 -10
- package/lib/vitest.js +2 -2
- package/lib/{workspacePublicPackages-DN-1LPcH.js → workspacePublicPackages-B_kw7fuc.js} +379 -129
- package/lint.mjs +874 -52
- package/oxlint.mjs +26 -1
- package/package.json +6 -6
- package/press-lint.mjs +86 -5
- package/spec-registry.mjs +15 -0
- package/src/lint.spec.ts +696 -12
- package/src/movedDepAliases.spec.ts +24 -0
- package/src/nativeBlockScoping.spec.ts +12 -14
- package/src/noVoicelessText.rule.spec.ts +1 -1
- package/src/noVoicelessText.spec.ts +1 -1
- package/src/oxlint.spec.ts +5 -5
- package/src/phosphorNativeInk.spec.ts +17 -18
- package/src/phosphorTokenColor.spec.ts +35 -0
- package/src/phosphorTokenColor.ts +8 -5
- package/src/press-lint.spec.ts +64 -3
- package/src/react-native.config.cjs +9 -0
- package/src/shims/phosphorThemeInk.js +6 -1
- package/src/singletonDepAliases.spec.ts +99 -14
- package/src/singletonDepAliases.ts +102 -7
- package/src/storybook.spec.ts +0 -3
- package/src/storybook.ts +20 -6
- package/src/vite.nativeEntries.spec.ts +21 -20
- package/src/vite.spec.ts +11 -20
- package/src/vite.ts +44 -69
- package/src/vitest.spec.ts +142 -4
- package/src/vitest.ts +106 -8
- package/types/phosphorTokenColor.d.ts.map +1 -1
- package/types/singletonDepAliases.d.ts +55 -3
- package/types/singletonDepAliases.d.ts.map +1 -1
- package/types/storybook.d.ts.map +1 -1
- package/types/vite.d.ts +10 -1
- package/types/vite.d.ts.map +1 -1
- package/types/vitest.d.ts +46 -1
- package/types/vitest.d.ts.map +1 -1
|
@@ -111,22 +111,117 @@ const CONTEXT_SINGLETONS: readonly string[] = [
|
|
|
111
111
|
* Vite `resolve.alias` entries pinning each context singleton to one directory.
|
|
112
112
|
*
|
|
113
113
|
* Alias keys match the whole specifier or a `key + "/"` prefix, so subpath
|
|
114
|
-
* imports follow the same copy instead of resolving independently.
|
|
115
|
-
*
|
|
116
|
-
*
|
|
114
|
+
* imports follow the same copy instead of resolving independently. That holds
|
|
115
|
+
* only while every subpath is a real file under the package directory; a
|
|
116
|
+
* package whose `exports` map REMAPS one is pinned by
|
|
117
|
+
* `singletonResolvePlugin` instead, because the prefix would rewrite the
|
|
118
|
+
* specifier to a path that does not exist. Entries are omitted when the
|
|
119
|
+
* package is not installed, so a consumer that does not use cookies is
|
|
120
|
+
* unaffected.
|
|
117
121
|
*
|
|
118
122
|
* @param root Directory whose `node_modules` the packages resolve from.
|
|
119
123
|
*/
|
|
120
124
|
export function singletonDepAliases(root: string = process.cwd()): Record<string, string> {
|
|
121
125
|
const aliases: Record<string, string> = {};
|
|
126
|
+
for (const { name, dir, exportsMapped } of resolveSingletons(root)) {
|
|
127
|
+
if (!exportsMapped) aliases[name] = dir;
|
|
128
|
+
}
|
|
129
|
+
return aliases;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** One installed context singleton, and how it has to be pinned. */
|
|
133
|
+
export interface SingletonPin {
|
|
134
|
+
name: string;
|
|
135
|
+
dir: string;
|
|
136
|
+
/** Its `exports` map remaps a subpath, so a directory alias cannot pin it. */
|
|
137
|
+
exportsMapped: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Every installed context singleton with its pinned directory.
|
|
142
|
+
*
|
|
143
|
+
* `exportsMapped` is measured rather than listed: a subpath key whose literal
|
|
144
|
+
* path does not exist under the package is one only the `exports` map can
|
|
145
|
+
* resolve. Measured on the installed tree at Tamagui 3.2.3, `@tamagui/core`
|
|
146
|
+
* and `@tamagui/web` each remap `./theme-update`, `./dom` and
|
|
147
|
+
* `./static-resolve`, and `react-cookie` and the three tanstack packages remap
|
|
148
|
+
* nothing. So a tanstack upgrade that adds a remapped subpath moves itself to
|
|
149
|
+
* the plugin instead of breaking a build.
|
|
150
|
+
*/
|
|
151
|
+
export function resolveSingletons(root: string = process.cwd()): SingletonPin[] {
|
|
122
152
|
const requireFrom = createRequire(path.join(root, "package.json"));
|
|
153
|
+
const pins: SingletonPin[] = [];
|
|
154
|
+
for (const name of CONTEXT_SINGLETONS) {
|
|
155
|
+
const dir = resolvePackageDir(name, root, requireFrom);
|
|
156
|
+
if (dir) pins.push({ name, dir, exportsMapped: remapsASubpath(dir) });
|
|
157
|
+
}
|
|
158
|
+
return pins;
|
|
159
|
+
}
|
|
123
160
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
161
|
+
function remapsASubpath(pkgDir: string): boolean {
|
|
162
|
+
let exports: unknown;
|
|
163
|
+
try {
|
|
164
|
+
exports = JSON.parse(fs.readFileSync(path.join(pkgDir, "package.json"), "utf8")).exports;
|
|
165
|
+
} catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (typeof exports !== "object" || exports === null) return false;
|
|
169
|
+
for (const key of Object.keys(exports)) {
|
|
170
|
+
if (key === "." || key === "./package.json" || !key.startsWith("./")) continue;
|
|
171
|
+
if (key.includes("*")) return true;
|
|
172
|
+
if (!fs.existsSync(path.join(pkgDir, key.slice(2)))) return true;
|
|
127
173
|
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
128
176
|
|
|
129
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Pins the singletons a directory alias cannot reach.
|
|
179
|
+
*
|
|
180
|
+
* `tamagui`'s own index imports `./theme-update.mjs`, which imports
|
|
181
|
+
* `@tamagui/core/theme-update`, which imports `@tamagui/web/theme-update`, so
|
|
182
|
+
* every import of `tamagui` anywhere walks that chain. Under a directory alias
|
|
183
|
+
* the prefix match rewrites it to `<pkgDir>/theme-update`, which is not a file,
|
|
184
|
+
* and `apps/one`'s production build dies with
|
|
185
|
+
* `[UNLOADABLE_DEPENDENCY] Could not load @tamagui/core/theme-update`. The dev
|
|
186
|
+
* server and vitest pre-bundle bare imports by package NAME and never see it,
|
|
187
|
+
* which is why 19,236 specs pass against a build that cannot be made.
|
|
188
|
+
*
|
|
189
|
+
* Re-resolving ANCHORED at the pinned package's own `package.json` is what
|
|
190
|
+
* keeps both halves: the exports map runs, so the environment's own conditions
|
|
191
|
+
* pick `.mjs` on web and `.native.js` on native, and the copy is the pinned one
|
|
192
|
+
* because that is where the resolution starts. A static target cannot do this,
|
|
193
|
+
* since the web and native files differ and this alias set is shared by both.
|
|
194
|
+
*
|
|
195
|
+
* @param root Directory whose `node_modules` the packages resolve from.
|
|
196
|
+
*/
|
|
197
|
+
export function singletonResolvePlugin(root: string = process.cwd()): {
|
|
198
|
+
name: string;
|
|
199
|
+
enforce: "pre";
|
|
200
|
+
resolveId: (
|
|
201
|
+
this: {
|
|
202
|
+
resolve: (
|
|
203
|
+
source: string,
|
|
204
|
+
importer?: string,
|
|
205
|
+
options?: Record<string, unknown>,
|
|
206
|
+
) => Promise<{ id: string } | null>;
|
|
207
|
+
},
|
|
208
|
+
source: string,
|
|
209
|
+
importer: string | undefined,
|
|
210
|
+
options: Record<string, unknown>,
|
|
211
|
+
) => Promise<string | null>;
|
|
212
|
+
} {
|
|
213
|
+
const pinned = resolveSingletons(root).filter((pin) => pin.exportsMapped);
|
|
214
|
+
return {
|
|
215
|
+
name: "multiplatform-singleton-resolve",
|
|
216
|
+
enforce: "pre",
|
|
217
|
+
async resolveId(source, _importer, options) {
|
|
218
|
+
const pin = pinned.find((p) => source === p.name || source.startsWith(`${p.name}/`));
|
|
219
|
+
if (!pin) return null;
|
|
220
|
+
const anchor = path.join(pin.dir, "package.json");
|
|
221
|
+
const resolved = await this.resolve(source, anchor, { ...options, skipSelf: true });
|
|
222
|
+
return resolved?.id ?? null;
|
|
223
|
+
},
|
|
224
|
+
};
|
|
130
225
|
}
|
|
131
226
|
|
|
132
227
|
/**
|
package/src/storybook.spec.ts
CHANGED
|
@@ -54,17 +54,14 @@ describe("createStorybookViteConfig", () => {
|
|
|
54
54
|
"@tamagui/animations-css",
|
|
55
55
|
"@tamagui/react-native-svg",
|
|
56
56
|
"@tamagui/colors",
|
|
57
|
-
"@tamagui/config",
|
|
58
57
|
"@tamagui/config/v5",
|
|
59
58
|
"@tamagui/constants",
|
|
60
59
|
"@tamagui/font-inter",
|
|
61
60
|
"@tamagui/get-font-sized",
|
|
62
61
|
"@tamagui/get-token",
|
|
63
62
|
"@tamagui/linear-gradient",
|
|
64
|
-
"@tamagui/lucide-icons-2",
|
|
65
63
|
"@tamagui/roving-focus",
|
|
66
64
|
"@tamagui/shorthands",
|
|
67
|
-
"@tamagui/theme-builder",
|
|
68
65
|
"@tamagui/themes",
|
|
69
66
|
"@tamagui/toast",
|
|
70
67
|
]) {
|
package/src/storybook.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
movedDepAliases,
|
|
5
|
+
nativeOnlyDepStubOptimizerPlugin,
|
|
6
|
+
nativeOnlyDepStubPlugin,
|
|
7
|
+
} from "@multiplatform.one/utils/dev";
|
|
3
8
|
import type { Plugin, UserConfig } from "vite";
|
|
4
9
|
import { phosphorTokenColorPlugin } from "./phosphorTokenColor.js";
|
|
5
|
-
import { withSingletonDepAliases } from "./singletonDepAliases.js";
|
|
10
|
+
import { singletonResolvePlugin, withSingletonDepAliases } from "./singletonDepAliases.js";
|
|
6
11
|
import { unexportedDepAliases } from "./unexportedDepAliases.js";
|
|
7
12
|
import { discoverPublicPackageRoots, resolvePackageMainSource } from "./workspacePublicPackages.js";
|
|
8
13
|
import { ensureTamaguiWorkspacePaths } from "./tamaguiWorkspacePaths.js";
|
|
@@ -56,12 +61,15 @@ export function createStorybookViteConfig(
|
|
|
56
61
|
ensureTamaguiWorkspacePaths();
|
|
57
62
|
const workspaceRoot = options.workspaceRoot || findWorkspaceRoot();
|
|
58
63
|
const packagesDir = path.join(workspaceRoot, "packages");
|
|
64
|
+
const nativeOnlyStub = nativeOnlyDepStubPlugin(workspaceRoot);
|
|
65
|
+
const nativeOnlyStubForOptimizer = nativeOnlyDepStubOptimizerPlugin(workspaceRoot);
|
|
59
66
|
|
|
60
67
|
const sortedAliases = withSingletonDepAliases(
|
|
61
68
|
{
|
|
62
69
|
...discoverPackageAliases(packagesDir),
|
|
63
70
|
...discoverPublicPackageViteAliases(workspaceRoot),
|
|
64
71
|
...unexportedDepAliases(workspaceRoot),
|
|
72
|
+
...movedDepAliases(workspaceRoot),
|
|
65
73
|
},
|
|
66
74
|
workspaceRoot,
|
|
67
75
|
options.aliases,
|
|
@@ -121,7 +129,6 @@ export function createStorybookViteConfig(
|
|
|
121
129
|
"react-native-web",
|
|
122
130
|
"@tamagui/core",
|
|
123
131
|
"@tamagui/web",
|
|
124
|
-
"@tamagui/helpers-icon",
|
|
125
132
|
"tamagui",
|
|
126
133
|
// MPO-149: every @tamagui/* package the story graph can reach, so the
|
|
127
134
|
// whole tamagui graph is pre-bundled in ONE optimizer generation.
|
|
@@ -152,7 +159,6 @@ export function createStorybookViteConfig(
|
|
|
152
159
|
"@tamagui/animations-css",
|
|
153
160
|
"@tamagui/react-native-svg",
|
|
154
161
|
"@tamagui/colors",
|
|
155
|
-
"@tamagui/config",
|
|
156
162
|
"@tamagui/config/v5",
|
|
157
163
|
"@tamagui/constants",
|
|
158
164
|
"@tamagui/font-inter",
|
|
@@ -161,7 +167,6 @@ export function createStorybookViteConfig(
|
|
|
161
167
|
"@tamagui/input",
|
|
162
168
|
"@tamagui/label",
|
|
163
169
|
"@tamagui/linear-gradient",
|
|
164
|
-
"@tamagui/lucide-icons-2",
|
|
165
170
|
"@tamagui/popover",
|
|
166
171
|
"@tamagui/portal",
|
|
167
172
|
"@tamagui/roving-focus",
|
|
@@ -170,7 +175,6 @@ export function createStorybookViteConfig(
|
|
|
170
175
|
"@tamagui/shorthands",
|
|
171
176
|
"@tamagui/stacks",
|
|
172
177
|
"@tamagui/text",
|
|
173
|
-
"@tamagui/theme-builder",
|
|
174
178
|
"@tamagui/themes",
|
|
175
179
|
"@tamagui/toast",
|
|
176
180
|
"@tamagui/use-presence",
|
|
@@ -207,6 +211,7 @@ export function createStorybookViteConfig(
|
|
|
207
211
|
"use-sync-external-store/with-selector",
|
|
208
212
|
"fast-deep-equal",
|
|
209
213
|
"color",
|
|
214
|
+
"warn-once",
|
|
210
215
|
// query-string v7 is CJS-only (require/exports), pulled in by
|
|
211
216
|
// @react-navigation/core for URL parsing. Unlike the One app which
|
|
212
217
|
// aliases it to @vxrn/query-string (ESM), Storybook has no such alias.
|
|
@@ -229,8 +234,17 @@ export function createStorybookViteConfig(
|
|
|
229
234
|
"@react-navigation/bottom-tabs",
|
|
230
235
|
"@react-navigation/native-stack",
|
|
231
236
|
],
|
|
237
|
+
rolldownOptions: nativeOnlyStubForOptimizer
|
|
238
|
+
? { plugins: [nativeOnlyStubForOptimizer] }
|
|
239
|
+
: undefined,
|
|
232
240
|
},
|
|
233
|
-
plugins: [
|
|
241
|
+
plugins: [
|
|
242
|
+
singletonResolvePlugin(workspaceRoot) as Plugin,
|
|
243
|
+
nodeAsyncHooksStub(),
|
|
244
|
+
phosphorTokenColorPlugin(),
|
|
245
|
+
...(nativeOnlyStub ? [nativeOnlyStub] : []),
|
|
246
|
+
...(options.plugins || []),
|
|
247
|
+
],
|
|
234
248
|
};
|
|
235
249
|
}
|
|
236
250
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { afterAll, beforeAll,
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
5
5
|
import { createViteConfig } from "./vite.js";
|
|
6
6
|
|
|
7
7
|
type NativePlugin = { name?: string; resolveId?: (id: string) => string | null };
|
|
8
|
-
|
|
8
|
+
function nativePlugins<T>(config: ReturnType<typeof createViteConfig>): T[] {
|
|
9
|
+
return (config.plugins as Array<{ api?: { vxrnNative?: () => T } } | undefined>)
|
|
10
|
+
.flat()
|
|
11
|
+
.flatMap((plugin) => (plugin?.api?.vxrnNative ? [plugin.api.vxrnNative()] : []));
|
|
12
|
+
}
|
|
9
13
|
|
|
10
14
|
const cwd = process.cwd();
|
|
11
15
|
let workspace: string;
|
|
@@ -17,8 +21,8 @@ function write(file: string, body: string, mtime?: Date) {
|
|
|
17
21
|
if (mtime) fs.utimesSync(at, mtime, mtime);
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
function nativeEntries() {
|
|
21
|
-
const plugins = (
|
|
24
|
+
function nativeEntries(config: ReturnType<typeof createViteConfig>) {
|
|
25
|
+
const plugins = nativePlugins<NativePlugin>(config).filter(
|
|
22
26
|
(plugin) => plugin.name === "vxrn-workspace-native-entries",
|
|
23
27
|
);
|
|
24
28
|
expect(plugins).toHaveLength(1);
|
|
@@ -52,47 +56,44 @@ afterAll(() => {
|
|
|
52
56
|
fs.rmSync(workspace, { recursive: true, force: true });
|
|
53
57
|
});
|
|
54
58
|
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
delete g.__vxrnAddNativePlugins;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
59
|
describe("native workspace entries outside a git checkout", () => {
|
|
60
60
|
it("finds the workspace by its pnpm-workspace.yaml and registers the resolver once", () => {
|
|
61
61
|
createViteConfig({ one: true });
|
|
62
|
-
createViteConfig({ one: true });
|
|
63
|
-
nativeEntries();
|
|
62
|
+
nativeEntries(createViteConfig({ one: true }));
|
|
64
63
|
});
|
|
65
64
|
|
|
66
65
|
it("sends a bare workspace name to source when the package has no native build", () => {
|
|
67
|
-
createViteConfig({ one: true });
|
|
68
|
-
expect(nativeEntries()("@fixture/alpha")).toBe(
|
|
66
|
+
const config = createViteConfig({ one: true });
|
|
67
|
+
expect(nativeEntries(config)("@fixture/alpha")).toBe(
|
|
69
68
|
path.join(workspace, "public/alpha/src/index.ts"),
|
|
70
69
|
);
|
|
71
70
|
});
|
|
72
71
|
|
|
73
72
|
it("sends a resolved web dist entry to its current native sibling", () => {
|
|
74
|
-
createViteConfig({ one: true });
|
|
75
|
-
const resolve = nativeEntries();
|
|
73
|
+
const config = createViteConfig({ one: true });
|
|
74
|
+
const resolve = nativeEntries(config);
|
|
76
75
|
const native = path.join(workspace, "public/beta/dist/esm/index.native.js");
|
|
77
76
|
expect(resolve(path.join(workspace, "public/beta/dist/esm/index.mjs"))).toBe(native);
|
|
78
77
|
expect(resolve("@fixture/beta")).toBe(native);
|
|
79
78
|
});
|
|
80
79
|
|
|
81
80
|
it("leaves a web dist entry alone when there is no native build", () => {
|
|
82
|
-
createViteConfig({ one: true });
|
|
83
|
-
expect(
|
|
81
|
+
const config = createViteConfig({ one: true });
|
|
82
|
+
expect(
|
|
83
|
+
nativeEntries(config)(path.join(workspace, "public/gamma/dist/esm/index.mjs")),
|
|
84
|
+
).toBeNull();
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
it("ignores ids that are neither a workspace name nor a workspace dist entry", () => {
|
|
87
|
-
createViteConfig({ one: true });
|
|
88
|
-
const resolve = nativeEntries();
|
|
88
|
+
const config = createViteConfig({ one: true });
|
|
89
|
+
const resolve = nativeEntries(config);
|
|
89
90
|
expect(resolve("react")).toBeNull();
|
|
90
91
|
expect(resolve(path.join(workspace, "missing/dist/esm/index.mjs"))).toBeNull();
|
|
91
92
|
expect(resolve(path.join(workspace, "public/alpha/src/index.ts"))).toBeNull();
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
it("refuses a native build older than its source", () => {
|
|
95
|
-
createViteConfig({ one: true });
|
|
96
|
-
expect(() => nativeEntries()("@fixture/stale")).toThrow(/older than src[\\/]index\.ts/);
|
|
96
|
+
const config = createViteConfig({ one: true });
|
|
97
|
+
expect(() => nativeEntries(config)("@fixture/stale")).toThrow(/older than src[\\/]index\.ts/);
|
|
97
98
|
});
|
|
98
99
|
});
|
package/src/vite.spec.ts
CHANGED
|
@@ -17,9 +17,11 @@ type NativePlugin = {
|
|
|
17
17
|
renderChunk?: (code: string) => { code: string; map: null };
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
function nativePlugins<T>(config: ReturnType<typeof createViteConfig>): T[] {
|
|
21
|
+
return (config.plugins as Array<{ api?: { vxrnNative?: () => T } } | undefined>)
|
|
22
|
+
.flat()
|
|
23
|
+
.flatMap((plugin) => (plugin?.api?.vxrnNative ? [plugin.api.vxrnNative()] : []));
|
|
24
|
+
}
|
|
23
25
|
|
|
24
26
|
function findPlugin(config: ReturnType<typeof createViteConfig>, name: string): Plugin | undefined {
|
|
25
27
|
return (config.plugins as Plugin[]).flat().find((p) => p && (p as Plugin).name === name) as
|
|
@@ -37,11 +39,6 @@ function runConfigResolved(
|
|
|
37
39
|
return fakeConfig.ssr.external;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
// Native fix registration is global and deduped — reset between tests.
|
|
42
|
-
delete globalWithNativePlugins.__vxrnAddNativePlugins;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
42
|
describe("ssrCjsExternal", () => {
|
|
46
43
|
it("appends the default CJS-only ids to ssr.external after one() replaces the list", () => {
|
|
47
44
|
const config = createViteConfig({ one: true });
|
|
@@ -101,8 +98,7 @@ describe("ssrCjsExternal", () => {
|
|
|
101
98
|
|
|
102
99
|
describe("nativeFixes.protoShadow", () => {
|
|
103
100
|
it("registers the Hermes proto-shadow renderChunk fix by default", () => {
|
|
104
|
-
createViteConfig({ one: true })
|
|
105
|
-
const plugin = globalWithNativePlugins.__vxrnAddNativePlugins?.find(
|
|
101
|
+
const plugin = nativePlugins<NativePlugin>(createViteConfig({ one: true })).find(
|
|
106
102
|
(p) => p.name === "vxrn-proto-shadow-fix",
|
|
107
103
|
);
|
|
108
104
|
expect(plugin).toBeDefined();
|
|
@@ -114,20 +110,18 @@ describe("nativeFixes.protoShadow", () => {
|
|
|
114
110
|
});
|
|
115
111
|
|
|
116
112
|
it("can be disabled with nativeFixes.protoShadow: false", () => {
|
|
117
|
-
createViteConfig({ one: true, nativeFixes: { protoShadow: false } });
|
|
113
|
+
const config = createViteConfig({ one: true, nativeFixes: { protoShadow: false } });
|
|
118
114
|
expect(
|
|
119
|
-
|
|
120
|
-
(p) => p.name === "vxrn-proto-shadow-fix",
|
|
121
|
-
),
|
|
115
|
+
nativePlugins<NativePlugin>(config).some((p) => p.name === "vxrn-proto-shadow-fix"),
|
|
122
116
|
).toBeFalsy();
|
|
123
117
|
});
|
|
124
118
|
});
|
|
125
119
|
|
|
126
120
|
describe("nativeFixes.web3Stub", () => {
|
|
127
121
|
it("auto-skips when @multiplatform.one/web3 is installed (monorepo has it)", () => {
|
|
128
|
-
createViteConfig({ one: true });
|
|
122
|
+
const config = createViteConfig({ one: true });
|
|
129
123
|
expect(
|
|
130
|
-
|
|
124
|
+
nativePlugins<NativePlugin>(config).some((p) => p.name === "vxrn-web3-stub"),
|
|
131
125
|
).toBeFalsy();
|
|
132
126
|
});
|
|
133
127
|
});
|
|
@@ -138,12 +132,11 @@ describe("community Flow strip (FZ-7357)", () => {
|
|
|
138
132
|
transform: (code: string, id: string) => Promise<{ code: string } | null>;
|
|
139
133
|
};
|
|
140
134
|
const strip = () =>
|
|
141
|
-
|
|
135
|
+
nativePlugins<NativePlugin>(createViteConfig({ one: true })).find(
|
|
142
136
|
(p) => p.name === "vxrn-community-flow-strip",
|
|
143
137
|
) as unknown as FlowStrip | undefined;
|
|
144
138
|
|
|
145
139
|
it("strips Flow from @react-native-community sources on native", async () => {
|
|
146
|
-
createViteConfig({ one: true });
|
|
147
140
|
const result = await strip()!.transform(
|
|
148
141
|
"// @flow\nconst x: number = 1;\nexport default x;\n",
|
|
149
142
|
"/app/node_modules/@react-native-community/datetimepicker/src/index.js",
|
|
@@ -153,7 +146,6 @@ describe("community Flow strip (FZ-7357)", () => {
|
|
|
153
146
|
});
|
|
154
147
|
|
|
155
148
|
it("strips Flow from @react-native-segmented-control sources on native (FZ-8486)", async () => {
|
|
156
|
-
createViteConfig({ one: true });
|
|
157
149
|
const result = await strip()!.transform(
|
|
158
150
|
"// @flow\nimport type {Node} from 'react';\nconst x: number = 1;\nexport default x;\n",
|
|
159
151
|
"/app/node_modules/@react-native-segmented-control/segmented-control/js/SegmentedControl.ios.js",
|
|
@@ -164,7 +156,6 @@ describe("community Flow strip (FZ-7357)", () => {
|
|
|
164
156
|
});
|
|
165
157
|
|
|
166
158
|
it("leaves every other package to vxrn", async () => {
|
|
167
|
-
createViteConfig({ one: true });
|
|
168
159
|
expect(
|
|
169
160
|
await strip()!.transform("const x = 1;", "/app/node_modules/react-native-webview/index.js"),
|
|
170
161
|
).toBeNull();
|