vxrn 2.9.2 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/getBaseVitePlugins.mjs +3 -1
- package/dist/config/getBaseVitePlugins.mjs.map +1 -1
- package/dist/config/getBaseVitePlugins.native.js +3 -1
- package/dist/config/getBaseVitePlugins.native.js.map +1 -1
- package/dist/constants.mjs +23 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/constants.native.js +23 -1
- package/dist/constants.native.js.map +1 -1
- package/dist/exports/build.mjs +11 -12
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js +11 -12
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +16 -1
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +16 -1
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/dist/index.native.js +2 -1
- package/dist/plugins/reactNativeDevServer.mjs +7 -5
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +8 -5
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +9 -0
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +9 -0
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/native-prelude.mjs +7 -1
- package/dist/runtime/native-prelude.mjs.map +1 -1
- package/dist/runtime/native-prelude.native.js +7 -1
- package/dist/runtime/native-prelude.native.js.map +1 -1
- package/dist/utils/compileNativeDevBytecode.mjs +13 -3
- package/dist/utils/compileNativeDevBytecode.mjs.map +1 -1
- package/dist/utils/compileNativeDevBytecode.native.js +13 -3
- package/dist/utils/compileNativeDevBytecode.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.mjs +375 -173
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +429 -193
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/dist/utils/environmentUtils.mjs +1 -1
- package/dist/utils/environmentUtils.mjs.map +1 -1
- package/dist/utils/environmentUtils.native.js +1 -1
- package/dist/utils/environmentUtils.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +37 -15
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +45 -15
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/package.json +13 -13
- package/src/config/getBaseVitePlugins.ts +2 -0
- package/src/constants.ts +24 -0
- package/src/exports/build.lifecycle.test.ts +152 -0
- package/src/exports/build.ts +16 -14
- package/src/exports/prebuildWithoutExpo.ts +16 -1
- package/src/index.ts +1 -0
- package/src/plugins/reactNativeCommonJsPlugin.ts +1 -1
- package/src/plugins/reactNativeDevServer.ts +19 -8
- package/src/rn-commands/bundle/buildBundle.ts +13 -1
- package/src/runtime/native-prelude.ts +7 -1
- package/src/types.ts +1 -1
- package/src/utils/compileNativeDevBytecode.test.ts +8 -8
- package/src/utils/compileNativeDevBytecode.ts +22 -2
- package/src/utils/createNativeDevEngine.test.ts +52 -25
- package/src/utils/createNativeDevEngine.ts +567 -254
- package/src/utils/environmentUtils.ts +6 -1
- package/src/utils/scanDepsToOptimize.test.ts +46 -2
- package/src/utils/scanDepsToOptimize.ts +78 -18
- package/types/config/getBaseVitePlugins.d.ts.map +1 -1
- package/types/constants.d.ts +2 -0
- package/types/constants.d.ts.map +1 -1
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/runtime/native-prelude.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/utils/compileNativeDevBytecode.d.ts +2 -1
- package/types/utils/compileNativeDevBytecode.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +11 -5
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/types/utils/environmentUtils.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
|
@@ -2,7 +2,7 @@ function isWebEnvironment(environment) {
|
|
|
2
2
|
return environment.name === "client" || environment.name === "ssr";
|
|
3
3
|
}
|
|
4
4
|
function isNativeEnvironment(environment) {
|
|
5
|
-
return environment.name === "ios" || environment.name === "android";
|
|
5
|
+
return environment.name === "ios" || environment.name === "android" || environment.name === "macos" || environment.name === "linux";
|
|
6
6
|
}
|
|
7
7
|
function isIOSEnvironment(environment) {
|
|
8
8
|
return environment.name === "ios";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentUtils.js","names":[],"sources":["utils/environmentUtils.js"],"sourcesContent":["function isWebEnvironment(environment) {\n return environment.name === \"client\" || environment.name === \"ssr\";\n}\nfunction isNativeEnvironment(environment) {\n return environment.name === \"ios\" || environment.name === \"android\";\n}\nfunction isIOSEnvironment(environment) {\n return environment.name === \"ios\";\n}\nfunction isAndroidEnvironment(environment) {\n return environment.name === \"android\";\n}\nexport {\n isAndroidEnvironment,\n isIOSEnvironment,\n isNativeEnvironment,\n isWebEnvironment\n};\n//# sourceMappingURL=environmentUtils.js.map\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS,YAAY,YAAY,SAAS;AAC/D;AACA,SAAS,oBAAoB,aAAa;CACxC,OAAO,YAAY,SAAS,SAAS,YAAY,SAAS;
|
|
1
|
+
{"version":3,"file":"environmentUtils.js","names":[],"sources":["utils/environmentUtils.js"],"sourcesContent":["function isWebEnvironment(environment) {\n return environment.name === \"client\" || environment.name === \"ssr\";\n}\nfunction isNativeEnvironment(environment) {\n return environment.name === \"ios\" || environment.name === \"android\" || environment.name === \"macos\" || environment.name === \"linux\";\n}\nfunction isIOSEnvironment(environment) {\n return environment.name === \"ios\";\n}\nfunction isAndroidEnvironment(environment) {\n return environment.name === \"android\";\n}\nexport {\n isAndroidEnvironment,\n isIOSEnvironment,\n isNativeEnvironment,\n isWebEnvironment\n};\n//# sourceMappingURL=environmentUtils.js.map\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS,YAAY,YAAY,SAAS;AAC/D;AACA,SAAS,oBAAoB,aAAa;CACxC,OAAO,YAAY,SAAS,SAAS,YAAY,SAAS,aAAa,YAAY,SAAS,WAAW,YAAY,SAAS;AAC9H;AACA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS;AAC9B;AACA,SAAS,qBAAqB,aAAa;CACzC,OAAO,YAAY,SAAS;AAC9B"}
|
|
@@ -2,7 +2,7 @@ function isWebEnvironment(environment) {
|
|
|
2
2
|
return environment.name === "client" || environment.name === "ssr";
|
|
3
3
|
}
|
|
4
4
|
function isNativeEnvironment(environment) {
|
|
5
|
-
return environment.name === "ios" || environment.name === "android";
|
|
5
|
+
return environment.name === "ios" || environment.name === "android" || environment.name === "macos" || environment.name === "linux";
|
|
6
6
|
}
|
|
7
7
|
function isIOSEnvironment(environment) {
|
|
8
8
|
return environment.name === "ios";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentUtils.native.js","names":[],"sources":["utils/environmentUtils.native.js"],"sourcesContent":["function isWebEnvironment(environment) {\n return environment.name === \"client\" || environment.name === \"ssr\";\n}\nfunction isNativeEnvironment(environment) {\n return environment.name === \"ios\" || environment.name === \"android\";\n}\nfunction isIOSEnvironment(environment) {\n return environment.name === \"ios\";\n}\nfunction isAndroidEnvironment(environment) {\n return environment.name === \"android\";\n}\nexport {\n isAndroidEnvironment,\n isIOSEnvironment,\n isNativeEnvironment,\n isWebEnvironment\n};\n//# sourceMappingURL=environmentUtils.js.map\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS,YAAY,YAAY,SAAS;AAC/D;AACA,SAAS,oBAAoB,aAAa;CACxC,OAAO,YAAY,SAAS,SAAS,YAAY,SAAS;
|
|
1
|
+
{"version":3,"file":"environmentUtils.native.js","names":[],"sources":["utils/environmentUtils.native.js"],"sourcesContent":["function isWebEnvironment(environment) {\n return environment.name === \"client\" || environment.name === \"ssr\";\n}\nfunction isNativeEnvironment(environment) {\n return environment.name === \"ios\" || environment.name === \"android\" || environment.name === \"macos\" || environment.name === \"linux\";\n}\nfunction isIOSEnvironment(environment) {\n return environment.name === \"ios\";\n}\nfunction isAndroidEnvironment(environment) {\n return environment.name === \"android\";\n}\nexport {\n isAndroidEnvironment,\n isIOSEnvironment,\n isNativeEnvironment,\n isWebEnvironment\n};\n//# sourceMappingURL=environmentUtils.js.map\n"],"mappings":";AAAA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS,YAAY,YAAY,SAAS;AAC/D;AACA,SAAS,oBAAoB,aAAa;CACxC,OAAO,YAAY,SAAS,SAAS,YAAY,SAAS,aAAa,YAAY,SAAS,WAAW,YAAY,SAAS;AAC9H;AACA,SAAS,iBAAiB,aAAa;CACrC,OAAO,YAAY,SAAS;AAC9B;AACA,SAAS,qBAAqB,aAAa;CACzC,OAAO,YAAY,SAAS;AAC9B"}
|
|
@@ -77,6 +77,25 @@ const INCLUDE_LIST = [
|
|
|
77
77
|
];
|
|
78
78
|
const INCLUDE_LIST_SET = new Set(INCLUDE_LIST);
|
|
79
79
|
async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
80
|
+
return scanDeps(packageJsonPath, options, {
|
|
81
|
+
pathExists: memoizeRead((file) => FSExtra.pathExists(file)),
|
|
82
|
+
realpath: memoizeRead((file) => FSExtra.realpath(file)),
|
|
83
|
+
readJson: memoizeRead((file) => FSExtra.readJson(file))
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function memoizeRead(read) {
|
|
87
|
+
const pending = /* @__PURE__ */ new Map();
|
|
88
|
+
return (file) => {
|
|
89
|
+
const key = path.resolve(file);
|
|
90
|
+
let result = pending.get(key);
|
|
91
|
+
if (!result) {
|
|
92
|
+
result = read(key);
|
|
93
|
+
pending.set(key, result);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function scanDeps(packageJsonPath, options, fs) {
|
|
80
99
|
const { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;
|
|
81
100
|
const isRoot = !options.parentDepNames;
|
|
82
101
|
if (isRoot) {
|
|
@@ -84,10 +103,10 @@ async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
|
84
103
|
}
|
|
85
104
|
const noExternalDeps = /* @__PURE__ */ new Set();
|
|
86
105
|
const currentRoot = path.dirname(packageJsonPath);
|
|
87
|
-
const pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath);
|
|
106
|
+
const pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath, fs.readJson);
|
|
88
107
|
const deps = Object.keys(pkgJson.dependencies || {});
|
|
89
108
|
const needsWorklets = (json) => !!(json.dependencies?.["react-native-reanimated"] || json.dependencies?.["react-native-worklets"]);
|
|
90
|
-
let hasReanimated = isRoot ? (await Promise.all(["react-native-reanimated", "react-native-worklets"].map((dep) => resolveDepPkgJsonPath(dep, currentRoot)))).some(Boolean) : needsWorklets(pkgJson);
|
|
109
|
+
let hasReanimated = isRoot ? (await Promise.all(["react-native-reanimated", "react-native-worklets"].map((dep) => resolveDepPkgJsonPath(dep, currentRoot, fs.pathExists)))).some(Boolean) : needsWorklets(pkgJson);
|
|
91
110
|
const prebundleDeps = (await Promise.all(deps.map(async (dep) => {
|
|
92
111
|
if (parentDepNames.includes(dep)) {
|
|
93
112
|
return [];
|
|
@@ -99,13 +118,13 @@ async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
|
99
118
|
if (EXCLUDE_LIST_SET.has(dep)) {
|
|
100
119
|
return [];
|
|
101
120
|
}
|
|
102
|
-
const localPath = await
|
|
121
|
+
const localPath = await findDepPkgJsonPathWithFs(dep, currentRoot, fs.pathExists);
|
|
103
122
|
if (!localPath) return [];
|
|
104
|
-
const depPkgJsonPath = await
|
|
123
|
+
const depPkgJsonPath = await fs.realpath(localPath);
|
|
105
124
|
if (options.filter && !options.filter(depPkgJsonPath)) {
|
|
106
125
|
return [];
|
|
107
126
|
}
|
|
108
|
-
const depPkgJson = await readPackageJsonSafe(depPkgJsonPath);
|
|
127
|
+
const depPkgJson = await readPackageJsonSafe(depPkgJsonPath, fs.readJson);
|
|
109
128
|
if (needsWorklets(depPkgJson)) {
|
|
110
129
|
hasReanimated = true;
|
|
111
130
|
}
|
|
@@ -114,11 +133,11 @@ async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
|
114
133
|
debug?.(`${dep} skipped: declares codegenConfig (native codegen package)`);
|
|
115
134
|
return [];
|
|
116
135
|
}
|
|
117
|
-
const subDeps = await
|
|
136
|
+
const subDeps = await scanDeps(depPkgJsonPath, {
|
|
118
137
|
parentDepNames: [...parentDepNames, dep],
|
|
119
138
|
pkgJsonContent: depPkgJson,
|
|
120
139
|
proceededDeps
|
|
121
|
-
});
|
|
140
|
+
}, fs);
|
|
122
141
|
for (const dep2 of subDeps.noExternalDeps) noExternalDeps.add(dep2);
|
|
123
142
|
if (subDeps.hasReanimated) {
|
|
124
143
|
hasReanimated = true;
|
|
@@ -172,7 +191,7 @@ async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
|
172
191
|
].find((entry) => typeof entry === "string" && entry && isPrebundleableEntry(entry));
|
|
173
192
|
const exports = [...definedExports, ...specialExports].filter((d) => !EXCLUDE_LIST_SET.has(d));
|
|
174
193
|
if (mainExport) {
|
|
175
|
-
if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport))) {
|
|
194
|
+
if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport), fs.pathExists)) {
|
|
176
195
|
exports.unshift(dep);
|
|
177
196
|
}
|
|
178
197
|
}
|
|
@@ -194,28 +213,28 @@ async function scanDepsToOptimize(packageJsonPath, options = {}) {
|
|
|
194
213
|
hasNativewind
|
|
195
214
|
};
|
|
196
215
|
}
|
|
197
|
-
async function checkIfExportExists(pathIn) {
|
|
216
|
+
async function checkIfExportExists(pathIn, pathExists) {
|
|
198
217
|
const paths = [pathIn, ...extname(pathIn) ? [] : [pathIn + ".js", pathIn + sep + "index.js"]];
|
|
199
218
|
for (const path2 of paths) {
|
|
200
|
-
if (await
|
|
219
|
+
if (await pathExists(path2)) {
|
|
201
220
|
return true;
|
|
202
221
|
}
|
|
203
222
|
}
|
|
204
223
|
return false;
|
|
205
224
|
}
|
|
206
|
-
async function readPackageJsonSafe(packageJsonPath) {
|
|
225
|
+
async function readPackageJsonSafe(packageJsonPath, readJson) {
|
|
207
226
|
try {
|
|
208
|
-
return await
|
|
227
|
+
return await readJson(packageJsonPath);
|
|
209
228
|
} catch (e) {
|
|
210
229
|
console.error(`[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`);
|
|
211
230
|
return {};
|
|
212
231
|
}
|
|
213
232
|
}
|
|
214
|
-
async function resolveDepPkgJsonPath(dep, dependent) {
|
|
233
|
+
async function resolveDepPkgJsonPath(dep, dependent, pathExists) {
|
|
215
234
|
let root = dependent;
|
|
216
235
|
while (root) {
|
|
217
236
|
const possiblePkgJson = path.join(root, "node_modules", dep, "package.json");
|
|
218
|
-
if (await
|
|
237
|
+
if (await pathExists(possiblePkgJson)) {
|
|
219
238
|
return possiblePkgJson;
|
|
220
239
|
}
|
|
221
240
|
const nextRoot = path.dirname(root);
|
|
@@ -224,7 +243,10 @@ async function resolveDepPkgJsonPath(dep, dependent) {
|
|
|
224
243
|
}
|
|
225
244
|
}
|
|
226
245
|
async function findDepPkgJsonPath(dep, dependent) {
|
|
227
|
-
|
|
246
|
+
return findDepPkgJsonPathWithFs(dep, dependent, (file) => FSExtra.pathExists(file));
|
|
247
|
+
}
|
|
248
|
+
async function findDepPkgJsonPathWithFs(dep, dependent, pathExists) {
|
|
249
|
+
const found = await resolveDepPkgJsonPath(dep, dependent, pathExists);
|
|
228
250
|
if (found) return found;
|
|
229
251
|
console.error(`[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`);
|
|
230
252
|
return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanDepsToOptimize.js","names":[],"sources":["utils/scanDepsToOptimize.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path, { dirname, extname, join, sep } from \"node:path\";\nconst { debug, debugDetails } = createDebugger(`vxrn:scanDepsToOptimize`);\nfunction isPrebundleableEntry(file) {\n return !/\\.d\\.[cm]?ts$/i.test(file) && (!extname(file) || /\\.[cm]?[jt]s$/.test(file));\n}\nfunction getExportsMap(exports) {\n if (typeof exports === \"string\") return { \".\": exports };\n if (!exports || typeof exports !== \"object\" || Array.isArray(exports)) return {};\n return Object.keys(exports).some((k) => k.startsWith(\".\")) ? exports : { \".\": exports };\n}\nfunction getExportImport(target) {\n return typeof target === \"string\" ? target : target?.import;\n}\nconst EXCLUDE_LIST = [\n \"jsc-android\",\n \"react-shallow-renderer\",\n \"fsevents\",\n \"@swc/core\",\n \"@swc/core-darwin-arm64\",\n \"@swc/core-darwin-x64\",\n \"@swc/core-linux-arm-gnueabihf\",\n \"@swc/core-linux-arm64-gnu\",\n \"@swc/core-linux-arm64-musl\",\n \"@swc/core-linux-x64-gnu\",\n \"@swc/core-linux-x64-musl\",\n \"@swc/core-win32-arm64-msvc\",\n \"@swc/core-win32-ia32-msvc\",\n \"@swc/core-win32-x64-msvc\",\n \"lightningcss\",\n // this breaks fileToUrlPath in upstreams, like @discordjs/client\n \"url\",\n \"sharp\",\n \"@sentry/react-native\",\n // not used by web anyway\n // Could not read from file: /Users/n8/one/node_modules/react-native-web/dist/cjs/index.js/Libraries/Image/AssetRegistry\n // /lib/module/Platform/Platform.web.js:132:20\n \"@shopify/react-native-skia\",\n \"@react-native/virtualized-lists\",\n // Unexpected \"typeof\" in `node_modules/@react-native/virtualized-lists/index.js`\n // Native only, we don't expect SSR to use these packages.\n // Also, some of these packages might attempt to import from react-native internals, which will break in SSR while react-native is aliased to react-native-web.\n \"@vxrn/vite-native-hmr\",\n \"@vxrn/compiler\",\n \"@vxrn/vite-native-client\",\n // build-time only, and they load native .node addons the ssr dep optimizer\n // cannot parse. apps list vxrn as a dependency because it is their dev\n // server, which is exactly why it must never be pre-bundled for ssr.\n \"vxrn\",\n \"@vxrn/vite-plugin-metro\",\n \"oxc-transform\",\n \"oxc-parser\",\n \"react-native-ios-utilities\",\n \"react-native-ios-modal\",\n \"react-native-ios-context-menu\",\n \"react-native-haptic-feedback\",\n \"react-native-sortables\",\n \"react-native-image-colors\",\n \"react-native-fast-image\",\n \"react-native-fast-squircle\",\n \"react-native-device-info\",\n // CLI/scripts shouldn't be used in SSR runtime\n \"@tamagui/cli\",\n // only used by static/plugin\n \"@tamagui/static\",\n \"@tamagui/config-default\",\n \"@tamagui/vite-plugin\",\n \"@take-out/scripts\",\n \"@take-out/cli\",\n // Should be used on native only\n \"@tamagui/core/native-test\",\n \"@storybook/react\",\n // native-only or not needed in SSR\n \"@nandorojo/galeria\",\n \"react-native-pager-view\",\n \"@react-native/debugger-shell\",\n // expo's debugger is a standalone app, not an SSR runtime dependency.\n \"@expo/cli\",\n \"@expo/log-box\",\n \"@hot-updater/react-native\",\n \"@hot-updater/plugin-core\",\n \"validator\",\n \"zlib\"\n];\nconst EXCLUDE_LIST_SET = new Set(EXCLUDE_LIST);\nconst INCLUDE_LIST = [\n // ReferenceError: exports is not defined - at eval (.../node_modules/inline-style-prefixer/lib/createPrefixer.js:3:23)\n \"inline-style-prefixer\",\n \"react-native-vector-icons\",\n \"jotai\"\n];\nconst INCLUDE_LIST_SET = new Set(INCLUDE_LIST);\nasync function scanDepsToOptimize(packageJsonPath, options = {}) {\n const { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;\n const isRoot = !options.parentDepNames;\n if (isRoot) {\n console.info(`[one] Scanning node_modules to auto-optimize...`);\n }\n const noExternalDeps = /* @__PURE__ */ new Set();\n const currentRoot = path.dirname(packageJsonPath);\n const pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath);\n const deps = Object.keys(pkgJson.dependencies || {});\n const needsWorklets = (json) => !!(json.dependencies?.[\"react-native-reanimated\"] || json.dependencies?.[\"react-native-worklets\"]);\n let hasReanimated = isRoot ? (await Promise.all(\n [\"react-native-reanimated\", \"react-native-worklets\"].map(\n (dep) => resolveDepPkgJsonPath(dep, currentRoot)\n )\n )).some(Boolean) : needsWorklets(pkgJson);\n const prebundleDeps = (await Promise.all(\n deps.map(async (dep) => {\n if (parentDepNames.includes(dep)) {\n return [];\n }\n const cachedResult = proceededDeps.get(dep);\n if (cachedResult) {\n return cachedResult;\n }\n if (EXCLUDE_LIST_SET.has(dep)) {\n return [];\n }\n const localPath = await findDepPkgJsonPath(dep, currentRoot);\n if (!localPath) return [];\n const depPkgJsonPath = await FSExtra.realpath(localPath);\n if (options.filter && !options.filter(depPkgJsonPath)) {\n return [];\n }\n const depPkgJson = await readPackageJsonSafe(depPkgJsonPath);\n if (needsWorklets(depPkgJson)) {\n hasReanimated = true;\n }\n if (depPkgJson.codegenConfig != null) {\n noExternalDeps.add(dep);\n debug?.(`${dep} skipped: declares codegenConfig (native codegen package)`);\n return [];\n }\n const subDeps = await scanDepsToOptimize(depPkgJsonPath, {\n parentDepNames: [...parentDepNames, dep],\n pkgJsonContent: depPkgJson,\n proceededDeps\n });\n for (const dep2 of subDeps.noExternalDeps) noExternalDeps.add(dep2);\n if (subDeps.hasReanimated) {\n hasReanimated = true;\n }\n const shouldPreBundle = subDeps.prebundleDeps.length > 0 || INCLUDE_LIST_SET.has(\n dep\n ) || hasRequiredDep(depPkgJson, \"react\") || // an optional react peer still means the package ships react\n // entrypoints (e.g. better-auth/react). left external, those load a\n // second react copy in SSR and crash hooks with a null dispatcher.\n !!depPkgJson.peerDependencies?.react || hasRequiredDep(depPkgJson, \"react-native\") || hasRequiredDep(depPkgJson, \"expo-modules-core\") || // expo packages publish extensionless ESM imports that Node cannot\n // execute directly. Keep installed Expo modules inside Vite's SSR\n // graph without making Expo a framework dependency.\n dep.startsWith(\"@expo/\") || dep.startsWith(\"expo-\");\n debug?.(`${dep} shouldPreBundle? ${shouldPreBundle}`);\n const depsToPreBundle = await (async () => {\n if (!shouldPreBundle) {\n return [];\n }\n const depPkgJsonExports = getExportsMap(depPkgJson.exports);\n const definedExports = Object.keys(depPkgJsonExports).filter((k) => {\n const imp = getExportImport(depPkgJsonExports[k]);\n if (typeof imp !== \"string\") {\n return false;\n }\n if (!isPrebundleableEntry(imp)) {\n return false;\n }\n if (!k.match(/^(\\.\\/)?[a-zA-Z0-9-_]+$/)) {\n return false;\n }\n return true;\n }).map((k) => k.replace(/^\\.\\/?/, \"\")).map((k) => `${dep}/${k}`);\n const specialExports = (() => {\n switch (dep) {\n case \"react-native-vector-icons\":\n return [\n \"AntDesign\",\n \"Entypo\",\n \"EvilIcons\",\n \"Feather\",\n \"FontAwesome\",\n \"FontAwesome5\",\n \"FontAwesome5Pro\",\n \"Fontisto\",\n \"Foundation\",\n \"Ionicons\",\n \"MaterialCommunityIcons\",\n \"MaterialIcons\",\n \"Octicons\",\n \"SimpleLineIcons\",\n \"Zocial\"\n ].map((n) => `${dep}/${n}`);\n default:\n return [];\n }\n })();\n const mainExport = [\n depPkgJson[\"main\"],\n depPkgJson[\"module\"],\n getExportImport(depPkgJsonExports[\".\"])\n ].find(\n (entry) => typeof entry === \"string\" && entry && isPrebundleableEntry(entry)\n );\n const exports = [...definedExports, ...specialExports].filter(\n (d) => !EXCLUDE_LIST_SET.has(d)\n );\n if (mainExport) {\n if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport))) {\n exports.unshift(dep);\n }\n }\n return exports;\n })();\n const result = [...depsToPreBundle, ...subDeps.prebundleDeps];\n debugDetails?.(`final result ${JSON.stringify(result, null, 2)}`);\n proceededDeps.set(dep, result);\n return result;\n })\n )).flat().filter((dep, index, arr) => arr.indexOf(dep) === index);\n const hasNativewind = !!pkgJson.dependencies?.[\"nativewind\"];\n if ((hasNativewind || hasReanimated) && isRoot) {\n if (hasReanimated)\n console.info(\n `[one] Enabled babel plugins: ${[hasReanimated ? \"Reanimated\" : \"\", hasNativewind ? \"Nativewind\" : \"\"].filter(Boolean).join(\", \")}`\n );\n }\n return {\n prebundleDeps,\n noExternalDeps: [...noExternalDeps],\n hasReanimated,\n // only check if set in root, dont want to enable css mode too easily\n hasNativewind\n };\n}\nasync function checkIfExportExists(pathIn) {\n const paths = [\n pathIn,\n ...extname(pathIn) ? [] : [pathIn + \".js\", pathIn + sep + \"index.js\"]\n ];\n for (const path2 of paths) {\n if (await FSExtra.pathExists(path2)) {\n return true;\n }\n }\n return false;\n}\nasync function readPackageJsonSafe(packageJsonPath) {\n try {\n return await FSExtra.readJson(packageJsonPath);\n } catch (e) {\n console.error(\n `[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`\n );\n return {};\n }\n}\nasync function resolveDepPkgJsonPath(dep, dependent) {\n let root = dependent;\n while (root) {\n const possiblePkgJson = path.join(root, \"node_modules\", dep, \"package.json\");\n if (await FSExtra.pathExists(possiblePkgJson)) {\n return possiblePkgJson;\n }\n const nextRoot = path.dirname(root);\n if (nextRoot === root) break;\n root = nextRoot;\n }\n}\nasync function findDepPkgJsonPath(dep, dependent) {\n const found = await resolveDepPkgJsonPath(dep, dependent);\n if (found) return found;\n console.error(\n `[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`\n );\n return void 0;\n}\nfunction hasRequiredDep(pkgJson, depName) {\n return !!(pkgJson.dependencies?.[depName] || pkgJson.peerDependencies?.[depName] && !pkgJson.peerDependenciesMeta?.[depName]?.optional);\n}\nexport {\n EXCLUDE_LIST,\n EXCLUDE_LIST_SET,\n INCLUDE_LIST,\n INCLUDE_LIST_SET,\n findDepPkgJsonPath,\n scanDepsToOptimize\n};\n//# sourceMappingURL=scanDepsToOptimize.js.map\n"],"mappings":";;;;;AAGA,MAAM,EAAE,OAAO,iBAAiB,eAAe,yBAAyB;AACxE,SAAS,qBAAqB,MAAM;CAClC,OAAO,CAAC,iBAAiB,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,gBAAgB,KAAK,IAAI;AACrF;AACA,SAAS,cAAc,SAAS;CAC9B,IAAI,OAAO,YAAY,UAAU,OAAO,EAAE,KAAK,QAAQ;CACvD,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC;CAC/E,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM,EAAE,WAAW,GAAG,CAAC,IAAI,UAAU,EAAE,KAAK,QAAQ;AACxF;AACA,SAAS,gBAAgB,QAAQ;CAC/B,OAAO,OAAO,WAAW,WAAW,SAAS,QAAQ;AACvD;AACA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAIA;CACA;CAIA;CACA;CACA;CAIA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,mBAAmB,IAAI,IAAI,YAAY;AAC7C,MAAM,eAAe;CAEnB;CACA;CACA;AACF;AACA,MAAM,mBAAmB,IAAI,IAAI,YAAY;AAC7C,eAAe,mBAAmB,iBAAiB,UAAU,CAAC,GAAG;CAC/D,MAAM,EAAE,iBAAiB,CAAC,G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M,QAAQ,SAAS,eAAe;CAC/C,SAAS,GAAG;EACV,QAAQ,MACN,+DAA+D,gBAAgB,IAAI,GACrF;EACA,OAAO,CAAC;CACV;AACF;AACA,eAAe,sBAAsB,KAAK,WAAW;CACnD,IAAI,OAAO;CACX,OAAO,MAAM;EACX,MAAM,kBAAkB,KAAK,KAAK,MAAM,gBAAgB,KAAK,cAAc;EAC3E,IAAI,MAAM,QAAQ,WAAW,eAAe,GAAG;GAC7C,OAAO;EACT;EACA,MAAM,WAAW,KAAK,QAAQ,IAAI;EAClC,IAAI,aAAa,MAAM;EACvB,OAAO;CACT;AACF;AACA,eAAe,mBAAmB,KAAK,WAAW;CAChD,MAAM,QAAQ,MAAM,sBAAsB,KAAK,SAAS;CACxD,IAAI,OAAO,OAAO;CAClB,QAAQ,MACN,wDAAwD,IAAI,6BAA6B,WAC3F;CACA,OAAO,KAAK;AACd;AACA,SAAS,eAAe,SAAS,SAAS;CACxC,OAAO,CAAC,EAAE,QAAQ,eAAe,YAAY,QAAQ,mBAAmB,YAAY,CAAC,QAAQ,uBAAuB,QAAQ,EAAE;AAChI"}
|
|
1
|
+
{"version":3,"file":"scanDepsToOptimize.js","names":[],"sources":["utils/scanDepsToOptimize.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path, { dirname, extname, join, sep } from \"node:path\";\nconst { debug, debugDetails } = createDebugger(`vxrn:scanDepsToOptimize`);\nfunction isPrebundleableEntry(file) {\n return !/\\.d\\.[cm]?ts$/i.test(file) && (!extname(file) || /\\.[cm]?[jt]s$/.test(file));\n}\nfunction getExportsMap(exports) {\n if (typeof exports === \"string\") return { \".\": exports };\n if (!exports || typeof exports !== \"object\" || Array.isArray(exports)) return {};\n return Object.keys(exports).some((k) => k.startsWith(\".\")) ? exports : { \".\": exports };\n}\nfunction getExportImport(target) {\n return typeof target === \"string\" ? target : target?.import;\n}\nconst EXCLUDE_LIST = [\n \"jsc-android\",\n \"react-shallow-renderer\",\n \"fsevents\",\n \"@swc/core\",\n \"@swc/core-darwin-arm64\",\n \"@swc/core-darwin-x64\",\n \"@swc/core-linux-arm-gnueabihf\",\n \"@swc/core-linux-arm64-gnu\",\n \"@swc/core-linux-arm64-musl\",\n \"@swc/core-linux-x64-gnu\",\n \"@swc/core-linux-x64-musl\",\n \"@swc/core-win32-arm64-msvc\",\n \"@swc/core-win32-ia32-msvc\",\n \"@swc/core-win32-x64-msvc\",\n \"lightningcss\",\n // this breaks fileToUrlPath in upstreams, like @discordjs/client\n \"url\",\n \"sharp\",\n \"@sentry/react-native\",\n // not used by web anyway\n // Could not read from file: /Users/n8/one/node_modules/react-native-web/dist/cjs/index.js/Libraries/Image/AssetRegistry\n // /lib/module/Platform/Platform.web.js:132:20\n \"@shopify/react-native-skia\",\n \"@react-native/virtualized-lists\",\n // Unexpected \"typeof\" in `node_modules/@react-native/virtualized-lists/index.js`\n // Native only, we don't expect SSR to use these packages.\n // Also, some of these packages might attempt to import from react-native internals, which will break in SSR while react-native is aliased to react-native-web.\n \"@vxrn/vite-native-hmr\",\n \"@vxrn/compiler\",\n \"@vxrn/vite-native-client\",\n // build-time only, and they load native .node addons the ssr dep optimizer\n // cannot parse. apps list vxrn as a dependency because it is their dev\n // server, which is exactly why it must never be pre-bundled for ssr.\n \"vxrn\",\n \"@vxrn/vite-plugin-metro\",\n \"oxc-transform\",\n \"oxc-parser\",\n \"react-native-ios-utilities\",\n \"react-native-ios-modal\",\n \"react-native-ios-context-menu\",\n \"react-native-haptic-feedback\",\n \"react-native-sortables\",\n \"react-native-image-colors\",\n \"react-native-fast-image\",\n \"react-native-fast-squircle\",\n \"react-native-device-info\",\n // CLI/scripts shouldn't be used in SSR runtime\n \"@tamagui/cli\",\n // only used by static/plugin\n \"@tamagui/static\",\n \"@tamagui/config-default\",\n \"@tamagui/vite-plugin\",\n \"@take-out/scripts\",\n \"@take-out/cli\",\n // Should be used on native only\n \"@tamagui/core/native-test\",\n \"@storybook/react\",\n // native-only or not needed in SSR\n \"@nandorojo/galeria\",\n \"react-native-pager-view\",\n \"@react-native/debugger-shell\",\n // expo's debugger is a standalone app, not an SSR runtime dependency.\n \"@expo/cli\",\n \"@expo/log-box\",\n \"@hot-updater/react-native\",\n \"@hot-updater/plugin-core\",\n \"validator\",\n \"zlib\"\n];\nconst EXCLUDE_LIST_SET = new Set(EXCLUDE_LIST);\nconst INCLUDE_LIST = [\n // ReferenceError: exports is not defined - at eval (.../node_modules/inline-style-prefixer/lib/createPrefixer.js:3:23)\n \"inline-style-prefixer\",\n \"react-native-vector-icons\",\n \"jotai\"\n];\nconst INCLUDE_LIST_SET = new Set(INCLUDE_LIST);\nasync function scanDepsToOptimize(packageJsonPath, options = {}) {\n return scanDeps(packageJsonPath, options, {\n pathExists: memoizeRead((file) => FSExtra.pathExists(file)),\n realpath: memoizeRead((file) => FSExtra.realpath(file)),\n readJson: memoizeRead((file) => FSExtra.readJson(file))\n });\n}\nfunction memoizeRead(read) {\n const pending = /* @__PURE__ */ new Map();\n return (file) => {\n const key = path.resolve(file);\n let result = pending.get(key);\n if (!result) {\n result = read(key);\n pending.set(key, result);\n }\n return result;\n };\n}\nasync function scanDeps(packageJsonPath, options, fs) {\n const { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;\n const isRoot = !options.parentDepNames;\n if (isRoot) {\n console.info(`[one] Scanning node_modules to auto-optimize...`);\n }\n const noExternalDeps = /* @__PURE__ */ new Set();\n const currentRoot = path.dirname(packageJsonPath);\n const pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath, fs.readJson);\n const deps = Object.keys(pkgJson.dependencies || {});\n const needsWorklets = (json) => !!(json.dependencies?.[\"react-native-reanimated\"] || json.dependencies?.[\"react-native-worklets\"]);\n let hasReanimated = isRoot ? (await Promise.all(\n [\"react-native-reanimated\", \"react-native-worklets\"].map(\n (dep) => resolveDepPkgJsonPath(dep, currentRoot, fs.pathExists)\n )\n )).some(Boolean) : needsWorklets(pkgJson);\n const prebundleDeps = (await Promise.all(\n deps.map(async (dep) => {\n if (parentDepNames.includes(dep)) {\n return [];\n }\n const cachedResult = proceededDeps.get(dep);\n if (cachedResult) {\n return cachedResult;\n }\n if (EXCLUDE_LIST_SET.has(dep)) {\n return [];\n }\n const localPath = await findDepPkgJsonPathWithFs(dep, currentRoot, fs.pathExists);\n if (!localPath) return [];\n const depPkgJsonPath = await fs.realpath(localPath);\n if (options.filter && !options.filter(depPkgJsonPath)) {\n return [];\n }\n const depPkgJson = await readPackageJsonSafe(depPkgJsonPath, fs.readJson);\n if (needsWorklets(depPkgJson)) {\n hasReanimated = true;\n }\n if (depPkgJson.codegenConfig != null) {\n noExternalDeps.add(dep);\n debug?.(`${dep} skipped: declares codegenConfig (native codegen package)`);\n return [];\n }\n const subDeps = await scanDeps(\n depPkgJsonPath,\n {\n parentDepNames: [...parentDepNames, dep],\n pkgJsonContent: depPkgJson,\n proceededDeps\n },\n fs\n );\n for (const dep2 of subDeps.noExternalDeps) noExternalDeps.add(dep2);\n if (subDeps.hasReanimated) {\n hasReanimated = true;\n }\n const shouldPreBundle = subDeps.prebundleDeps.length > 0 || INCLUDE_LIST_SET.has(\n dep\n ) || hasRequiredDep(depPkgJson, \"react\") || // an optional react peer still means the package ships react\n // entrypoints (e.g. better-auth/react). left external, those load a\n // second react copy in SSR and crash hooks with a null dispatcher.\n !!depPkgJson.peerDependencies?.react || hasRequiredDep(depPkgJson, \"react-native\") || hasRequiredDep(depPkgJson, \"expo-modules-core\") || // expo packages publish extensionless ESM imports that Node cannot\n // execute directly. Keep installed Expo modules inside Vite's SSR\n // graph without making Expo a framework dependency.\n dep.startsWith(\"@expo/\") || dep.startsWith(\"expo-\");\n debug?.(`${dep} shouldPreBundle? ${shouldPreBundle}`);\n const depsToPreBundle = await (async () => {\n if (!shouldPreBundle) {\n return [];\n }\n const depPkgJsonExports = getExportsMap(depPkgJson.exports);\n const definedExports = Object.keys(depPkgJsonExports).filter((k) => {\n const imp = getExportImport(depPkgJsonExports[k]);\n if (typeof imp !== \"string\") {\n return false;\n }\n if (!isPrebundleableEntry(imp)) {\n return false;\n }\n if (!k.match(/^(\\.\\/)?[a-zA-Z0-9-_]+$/)) {\n return false;\n }\n return true;\n }).map((k) => k.replace(/^\\.\\/?/, \"\")).map((k) => `${dep}/${k}`);\n const specialExports = (() => {\n switch (dep) {\n case \"react-native-vector-icons\":\n return [\n \"AntDesign\",\n \"Entypo\",\n \"EvilIcons\",\n \"Feather\",\n \"FontAwesome\",\n \"FontAwesome5\",\n \"FontAwesome5Pro\",\n \"Fontisto\",\n \"Foundation\",\n \"Ionicons\",\n \"MaterialCommunityIcons\",\n \"MaterialIcons\",\n \"Octicons\",\n \"SimpleLineIcons\",\n \"Zocial\"\n ].map((n) => `${dep}/${n}`);\n default:\n return [];\n }\n })();\n const mainExport = [\n depPkgJson[\"main\"],\n depPkgJson[\"module\"],\n getExportImport(depPkgJsonExports[\".\"])\n ].find(\n (entry) => typeof entry === \"string\" && entry && isPrebundleableEntry(entry)\n );\n const exports = [...definedExports, ...specialExports].filter(\n (d) => !EXCLUDE_LIST_SET.has(d)\n );\n if (mainExport) {\n if (await checkIfExportExists(\n join(dirname(depPkgJsonPath), mainExport),\n fs.pathExists\n )) {\n exports.unshift(dep);\n }\n }\n return exports;\n })();\n const result = [...depsToPreBundle, ...subDeps.prebundleDeps];\n debugDetails?.(`final result ${JSON.stringify(result, null, 2)}`);\n proceededDeps.set(dep, result);\n return result;\n })\n )).flat().filter((dep, index, arr) => arr.indexOf(dep) === index);\n const hasNativewind = !!pkgJson.dependencies?.[\"nativewind\"];\n if ((hasNativewind || hasReanimated) && isRoot) {\n if (hasReanimated)\n console.info(\n `[one] Enabled babel plugins: ${[hasReanimated ? \"Reanimated\" : \"\", hasNativewind ? \"Nativewind\" : \"\"].filter(Boolean).join(\", \")}`\n );\n }\n return {\n prebundleDeps,\n noExternalDeps: [...noExternalDeps],\n hasReanimated,\n // only check if set in root, dont want to enable css mode too easily\n hasNativewind\n };\n}\nasync function checkIfExportExists(pathIn, pathExists) {\n const paths = [\n pathIn,\n ...extname(pathIn) ? [] : [pathIn + \".js\", pathIn + sep + \"index.js\"]\n ];\n for (const path2 of paths) {\n if (await pathExists(path2)) {\n return true;\n }\n }\n return false;\n}\nasync function readPackageJsonSafe(packageJsonPath, readJson) {\n try {\n return await readJson(packageJsonPath);\n } catch (e) {\n console.error(\n `[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`\n );\n return {};\n }\n}\nasync function resolveDepPkgJsonPath(dep, dependent, pathExists) {\n let root = dependent;\n while (root) {\n const possiblePkgJson = path.join(root, \"node_modules\", dep, \"package.json\");\n if (await pathExists(possiblePkgJson)) {\n return possiblePkgJson;\n }\n const nextRoot = path.dirname(root);\n if (nextRoot === root) break;\n root = nextRoot;\n }\n}\nasync function findDepPkgJsonPath(dep, dependent) {\n return findDepPkgJsonPathWithFs(dep, dependent, (file) => FSExtra.pathExists(file));\n}\nasync function findDepPkgJsonPathWithFs(dep, dependent, pathExists) {\n const found = await resolveDepPkgJsonPath(dep, dependent, pathExists);\n if (found) return found;\n console.error(\n `[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`\n );\n return void 0;\n}\nfunction hasRequiredDep(pkgJson, depName) {\n return !!(pkgJson.dependencies?.[depName] || pkgJson.peerDependencies?.[depName] && !pkgJson.peerDependenciesMeta?.[depName]?.optional);\n}\nexport {\n EXCLUDE_LIST,\n EXCLUDE_LIST_SET,\n INCLUDE_LIST,\n INCLUDE_LIST_SET,\n findDepPkgJsonPath,\n scanDepsToOptimize\n};\n//# sourceMappingURL=scanDepsToOptimize.js.map\n"],"mappings":";;;;;AAGA,MAAM,EAAE,OAAO,iBAAiB,eAAe,yBAAyB;AACxE,SAAS,qBAAqB,MAAM;CAClC,OAAO,CAAC,iBAAiB,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,gBAAgB,KAAK,IAAI;AACrF;AACA,SAA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MAAM,SAAS,OAAO;EACzB,IAAI,MAAM,WAAW,KAAK,GAAG;GAC3B,OAAO;EACT;CACF;CACA,OAAO;AACT;AACA,eAAe,oBAAoB,iBAAiB,UAAU;CAC5D,IAAI;EACF,OAAO,MAAM,SAAS,eAAe;CACvC,SAAS,GAAG;EACV,QAAQ,MACN,+DAA+D,gBAAgB,IAAI,GACrF;EACA,OAAO,CAAC;CACV;AACF;AACA,eAAe,sBAAsB,KAAK,WAAW,YAAY;CAC/D,IAAI,OAAO;CACX,OAAO,MAAM;EACX,MAAM,kBAAkB,KAAK,KAAK,MAAM,gBAAgB,KAAK,cAAc;EAC3E,IAAI,MAAM,WAAW,eAAe,GAAG;GACrC,OAAO;EACT;EACA,MAAM,WAAW,KAAK,QAAQ,IAAI;EAClC,IAAI,aAAa,MAAM;EACvB,OAAO;CACT;AACF;AACA,eAAe,mBAAmB,KAAK,WAAW;CAChD,OAAO,yBAAyB,KAAK,YAAY,SAAS,QAAQ,WAAW,IAAI,CAAC;AACpF;AACA,eAAe,yBAAyB,KAAK,WAAW,YAAY;CAClE,MAAM,QAAQ,MAAM,sBAAsB,KAAK,WAAW,UAAU;CACpE,IAAI,OAAO,OAAO;CAClB,QAAQ,MACN,wDAAwD,IAAI,6BAA6B,WAC3F;CACA,OAAO,KAAK;AACd;AACA,SAAS,eAAe,SAAS,SAAS;CACxC,OAAO,CAAC,EAAE,QAAQ,eAAe,YAAY,QAAQ,mBAAmB,YAAY,CAAC,QAAQ,uBAAuB,QAAQ,EAAE;AAChI"}
|
|
@@ -82,6 +82,31 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
82
82
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
83
83
|
/** If the content of the package.json is already read before calling this function, pass it here to avoid reading it again */
|
|
84
84
|
{};
|
|
85
|
+
return scanDeps(packageJsonPath, options, {
|
|
86
|
+
pathExists: memoizeRead(function(file) {
|
|
87
|
+
return FSExtra.pathExists(file);
|
|
88
|
+
}),
|
|
89
|
+
realpath: memoizeRead(function(file) {
|
|
90
|
+
return FSExtra.realpath(file);
|
|
91
|
+
}),
|
|
92
|
+
readJson: memoizeRead(function(file) {
|
|
93
|
+
return FSExtra.readJson(file);
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function memoizeRead(read) {
|
|
98
|
+
var pending = /* @__PURE__ */ new Map();
|
|
99
|
+
return function(file) {
|
|
100
|
+
var key = path.resolve(file);
|
|
101
|
+
var result = pending.get(key);
|
|
102
|
+
if (!result) {
|
|
103
|
+
result = read(key);
|
|
104
|
+
pending.set(key, result);
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async function scanDeps(packageJsonPath, options, fs) {
|
|
85
110
|
var _pkgJson_dependencies;
|
|
86
111
|
var { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;
|
|
87
112
|
var isRoot = !options.parentDepNames;
|
|
@@ -90,14 +115,14 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
90
115
|
}
|
|
91
116
|
var noExternalDeps = /* @__PURE__ */ new Set();
|
|
92
117
|
var currentRoot = path.dirname(packageJsonPath);
|
|
93
|
-
var pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath);
|
|
118
|
+
var pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath, fs.readJson);
|
|
94
119
|
var deps = Object.keys(pkgJson.dependencies || {});
|
|
95
120
|
var needsWorklets = function needsWorklets2(json) {
|
|
96
121
|
var _json_dependencies, _json_dependencies1;
|
|
97
122
|
return !!(((_json_dependencies = json.dependencies) === null || _json_dependencies === void 0 ? void 0 : _json_dependencies["react-native-reanimated"]) || ((_json_dependencies1 = json.dependencies) === null || _json_dependencies1 === void 0 ? void 0 : _json_dependencies1["react-native-worklets"]));
|
|
98
123
|
};
|
|
99
124
|
var hasReanimated = isRoot ? (await Promise.all(["react-native-reanimated", "react-native-worklets"].map(function(dep) {
|
|
100
|
-
return resolveDepPkgJsonPath(dep, currentRoot);
|
|
125
|
+
return resolveDepPkgJsonPath(dep, currentRoot, fs.pathExists);
|
|
101
126
|
}))).some(Boolean) : needsWorklets(pkgJson);
|
|
102
127
|
var prebundleDeps = (await Promise.all(deps.map(async function(dep) {
|
|
103
128
|
var _depPkgJson_peerDependencies;
|
|
@@ -111,13 +136,13 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
111
136
|
if (EXCLUDE_LIST_SET.has(dep)) {
|
|
112
137
|
return [];
|
|
113
138
|
}
|
|
114
|
-
var localPath = await
|
|
139
|
+
var localPath = await findDepPkgJsonPathWithFs(dep, currentRoot, fs.pathExists);
|
|
115
140
|
if (!localPath) return [];
|
|
116
|
-
var depPkgJsonPath = await
|
|
141
|
+
var depPkgJsonPath = await fs.realpath(localPath);
|
|
117
142
|
if (options.filter && !options.filter(depPkgJsonPath)) {
|
|
118
143
|
return [];
|
|
119
144
|
}
|
|
120
|
-
var depPkgJson = await readPackageJsonSafe(depPkgJsonPath);
|
|
145
|
+
var depPkgJson = await readPackageJsonSafe(depPkgJsonPath, fs.readJson);
|
|
121
146
|
if (needsWorklets(depPkgJson)) {
|
|
122
147
|
hasReanimated = true;
|
|
123
148
|
}
|
|
@@ -126,11 +151,11 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
126
151
|
debug === null || debug === void 0 ? void 0 : debug(`${dep} skipped: declares codegenConfig (native codegen package)`);
|
|
127
152
|
return [];
|
|
128
153
|
}
|
|
129
|
-
var subDeps = await
|
|
154
|
+
var subDeps = await scanDeps(depPkgJsonPath, {
|
|
130
155
|
parentDepNames: [...parentDepNames, dep],
|
|
131
156
|
pkgJsonContent: depPkgJson,
|
|
132
157
|
proceededDeps
|
|
133
|
-
});
|
|
158
|
+
}, fs);
|
|
134
159
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
135
160
|
try {
|
|
136
161
|
for (var _iterator = subDeps.noExternalDeps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
@@ -213,7 +238,7 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
213
238
|
return !EXCLUDE_LIST_SET.has(d);
|
|
214
239
|
});
|
|
215
240
|
if (mainExport) {
|
|
216
|
-
if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport))) {
|
|
241
|
+
if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport), fs.pathExists)) {
|
|
217
242
|
exports.unshift(dep);
|
|
218
243
|
}
|
|
219
244
|
}
|
|
@@ -237,13 +262,13 @@ async function scanDepsToOptimize(packageJsonPath) {
|
|
|
237
262
|
hasNativewind
|
|
238
263
|
};
|
|
239
264
|
}
|
|
240
|
-
async function checkIfExportExists(pathIn) {
|
|
265
|
+
async function checkIfExportExists(pathIn, pathExists) {
|
|
241
266
|
var paths = [pathIn, ...extname(pathIn) ? [] : [pathIn + ".js", pathIn + sep + "index.js"]];
|
|
242
267
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
243
268
|
try {
|
|
244
269
|
for (var _iterator = paths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
245
270
|
var path2 = _step.value;
|
|
246
|
-
if (await
|
|
271
|
+
if (await pathExists(path2)) {
|
|
247
272
|
return true;
|
|
248
273
|
}
|
|
249
274
|
}
|
|
@@ -263,19 +288,19 @@ async function checkIfExportExists(pathIn) {
|
|
|
263
288
|
}
|
|
264
289
|
return false;
|
|
265
290
|
}
|
|
266
|
-
async function readPackageJsonSafe(packageJsonPath) {
|
|
291
|
+
async function readPackageJsonSafe(packageJsonPath, readJson) {
|
|
267
292
|
try {
|
|
268
|
-
return await
|
|
293
|
+
return await readJson(packageJsonPath);
|
|
269
294
|
} catch (e) {
|
|
270
295
|
console.error(`[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`);
|
|
271
296
|
return {};
|
|
272
297
|
}
|
|
273
298
|
}
|
|
274
|
-
async function resolveDepPkgJsonPath(dep, dependent) {
|
|
299
|
+
async function resolveDepPkgJsonPath(dep, dependent, pathExists) {
|
|
275
300
|
var root = dependent;
|
|
276
301
|
while (root) {
|
|
277
302
|
var possiblePkgJson = path.join(root, "node_modules", dep, "package.json");
|
|
278
|
-
if (await
|
|
303
|
+
if (await pathExists(possiblePkgJson)) {
|
|
279
304
|
return possiblePkgJson;
|
|
280
305
|
}
|
|
281
306
|
var nextRoot = path.dirname(root);
|
|
@@ -284,7 +309,12 @@ async function resolveDepPkgJsonPath(dep, dependent) {
|
|
|
284
309
|
}
|
|
285
310
|
}
|
|
286
311
|
async function findDepPkgJsonPath(dep, dependent) {
|
|
287
|
-
|
|
312
|
+
return findDepPkgJsonPathWithFs(dep, dependent, function(file) {
|
|
313
|
+
return FSExtra.pathExists(file);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
async function findDepPkgJsonPathWithFs(dep, dependent, pathExists) {
|
|
317
|
+
var found = await resolveDepPkgJsonPath(dep, dependent, pathExists);
|
|
288
318
|
if (found) return found;
|
|
289
319
|
console.error(`[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`);
|
|
290
320
|
return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanDepsToOptimize.native.js","names":[],"sources":["utils/scanDepsToOptimize.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path, { dirname, extname, join, sep } from \"path\";\nvar { debug, debugDetails } = createDebugger(`vxrn:scanDepsToOptimize`);\nfunction isPrebundleableEntry(file) {\n return !/\\.d\\.[cm]?ts$/i.test(file) && (!extname(file) || /\\.[cm]?[jt]s$/.test(file));\n}\nfunction getExportsMap(exports) {\n if (typeof exports === \"string\") return {\n \".\": exports\n };\n if (!exports || typeof exports !== \"object\" || Array.isArray(exports)) return {};\n return Object.keys(exports).some(function(k) {\n return k.startsWith(\".\");\n }) ? exports : {\n \".\": exports\n };\n}\nfunction getExportImport(target) {\n return typeof target === \"string\" ? target : target === null || target === void 0 ? void 0 : target.import;\n}\nvar EXCLUDE_LIST = [\n \"jsc-android\",\n \"react-shallow-renderer\",\n \"fsevents\",\n \"@swc/core\",\n \"@swc/core-darwin-arm64\",\n \"@swc/core-darwin-x64\",\n \"@swc/core-linux-arm-gnueabihf\",\n \"@swc/core-linux-arm64-gnu\",\n \"@swc/core-linux-arm64-musl\",\n \"@swc/core-linux-x64-gnu\",\n \"@swc/core-linux-x64-musl\",\n \"@swc/core-win32-arm64-msvc\",\n \"@swc/core-win32-ia32-msvc\",\n \"@swc/core-win32-x64-msvc\",\n \"lightningcss\",\n // this breaks fileToUrlPath in upstreams, like @discordjs/client\n \"url\",\n \"sharp\",\n \"@sentry/react-native\",\n // not used by web anyway\n // Could not read from file: /Users/n8/one/node_modules/react-native-web/dist/cjs/index.js/Libraries/Image/AssetRegistry\n // /lib/module/Platform/Platform.web.js:132:20\n \"@shopify/react-native-skia\",\n \"@react-native/virtualized-lists\",\n // Unexpected \"typeof\" in `node_modules/@react-native/virtualized-lists/index.js`\n // Native only, we don't expect SSR to use these packages.\n // Also, some of these packages might attempt to import from react-native internals, which will break in SSR while react-native is aliased to react-native-web.\n \"@vxrn/vite-native-hmr\",\n \"@vxrn/compiler\",\n \"@vxrn/vite-native-client\",\n // build-time only, and they load native .node addons the ssr dep optimizer\n // cannot parse. apps list vxrn as a dependency because it is their dev\n // server, which is exactly why it must never be pre-bundled for ssr.\n \"vxrn\",\n \"@vxrn/vite-plugin-metro\",\n \"oxc-transform\",\n \"oxc-parser\",\n \"react-native-ios-utilities\",\n \"react-native-ios-modal\",\n \"react-native-ios-context-menu\",\n \"react-native-haptic-feedback\",\n \"react-native-sortables\",\n \"react-native-image-colors\",\n \"react-native-fast-image\",\n \"react-native-fast-squircle\",\n \"react-native-device-info\",\n // CLI/scripts shouldn't be used in SSR runtime\n \"@tamagui/cli\",\n // only used by static/plugin\n \"@tamagui/static\",\n \"@tamagui/config-default\",\n \"@tamagui/vite-plugin\",\n \"@take-out/scripts\",\n \"@take-out/cli\",\n // Should be used on native only\n \"@tamagui/core/native-test\",\n \"@storybook/react\",\n // native-only or not needed in SSR\n \"@nandorojo/galeria\",\n \"react-native-pager-view\",\n \"@react-native/debugger-shell\",\n // expo's debugger is a standalone app, not an SSR runtime dependency.\n \"@expo/cli\",\n \"@expo/log-box\",\n \"@hot-updater/react-native\",\n \"@hot-updater/plugin-core\",\n \"validator\",\n \"zlib\"\n];\nvar EXCLUDE_LIST_SET = new Set(EXCLUDE_LIST);\nvar INCLUDE_LIST = [\n // ReferenceError: exports is not defined - at eval (.../node_modules/inline-style-prefixer/lib/createPrefixer.js:3:23)\n \"inline-style-prefixer\",\n \"react-native-vector-icons\",\n \"jotai\"\n];\nvar INCLUDE_LIST_SET = new Set(INCLUDE_LIST);\nasync function scanDepsToOptimize(packageJsonPath) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (\n /** If the content of the package.json is already read before calling this function, pass it here to avoid reading it again */\n {}\n );\n var _pkgJson_dependencies;\n var { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;\n var isRoot = !options.parentDepNames;\n if (isRoot) {\n console.info(`[one] Scanning node_modules to auto-optimize...`);\n }\n var noExternalDeps = /* @__PURE__ */ new Set();\n var currentRoot = path.dirname(packageJsonPath);\n var pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath);\n var deps = Object.keys(pkgJson.dependencies || {});\n var needsWorklets = function needsWorklets2(json) {\n var _json_dependencies, _json_dependencies1;\n return !!(((_json_dependencies = json.dependencies) === null || _json_dependencies === void 0 ? void 0 : _json_dependencies[\"react-native-reanimated\"]) || ((_json_dependencies1 = json.dependencies) === null || _json_dependencies1 === void 0 ? void 0 : _json_dependencies1[\"react-native-worklets\"]));\n };\n var hasReanimated = isRoot ? (await Promise.all([\n \"react-native-reanimated\",\n \"react-native-worklets\"\n ].map(function(dep) {\n return resolveDepPkgJsonPath(dep, currentRoot);\n }))).some(Boolean) : needsWorklets(pkgJson);\n var prebundleDeps = (await Promise.all(deps.map(async function(dep) {\n var _depPkgJson_peerDependencies;\n if (parentDepNames.includes(dep)) {\n return [];\n }\n var cachedResult = proceededDeps.get(dep);\n if (cachedResult) {\n return cachedResult;\n }\n if (EXCLUDE_LIST_SET.has(dep)) {\n return [];\n }\n var localPath = await findDepPkgJsonPath(dep, currentRoot);\n if (!localPath) return [];\n var depPkgJsonPath = await FSExtra.realpath(localPath);\n if (options.filter && !options.filter(depPkgJsonPath)) {\n return [];\n }\n var depPkgJson = await readPackageJsonSafe(depPkgJsonPath);\n if (needsWorklets(depPkgJson)) {\n hasReanimated = true;\n }\n if (depPkgJson.codegenConfig != null) {\n noExternalDeps.add(dep);\n debug === null || debug === void 0 ? void 0 : debug(`${dep} skipped: declares codegenConfig (native codegen package)`);\n return [];\n }\n var subDeps = await scanDepsToOptimize(depPkgJsonPath, {\n parentDepNames: [\n ...parentDepNames,\n dep\n ],\n pkgJsonContent: depPkgJson,\n proceededDeps\n });\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = subDeps.noExternalDeps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _$dep = _step.value;\n noExternalDeps.add(_$dep);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (subDeps.hasReanimated) {\n hasReanimated = true;\n }\n var shouldPreBundle = subDeps.prebundleDeps.length > 0 || /* If this dep is depending on other deps that need pre-bundling, then also pre-bundle this dep */\n INCLUDE_LIST_SET.has(dep) || /* If this dep is in the include list, then pre-bundle it */\n hasRequiredDep(depPkgJson, \"react\") || // an optional react peer still means the package ships react\n // entrypoints (e.g. better-auth/react). left external, those load a\n // second react copy in SSR and crash hooks with a null dispatcher.\n !!((_depPkgJson_peerDependencies = depPkgJson.peerDependencies) === null || _depPkgJson_peerDependencies === void 0 ? void 0 : _depPkgJson_peerDependencies.react) || hasRequiredDep(depPkgJson, \"react-native\") || hasRequiredDep(depPkgJson, \"expo-modules-core\") || // expo packages publish extensionless ESM imports that Node cannot\n // execute directly. Keep installed Expo modules inside Vite's SSR\n // graph without making Expo a framework dependency.\n dep.startsWith(\"@expo/\") || dep.startsWith(\"expo-\");\n debug === null || debug === void 0 ? void 0 : debug(`${dep} shouldPreBundle? ${shouldPreBundle}`);\n var depsToPreBundle = await (async function() {\n if (!shouldPreBundle) {\n return [];\n }\n var depPkgJsonExports = getExportsMap(depPkgJson.exports);\n var definedExports = Object.keys(depPkgJsonExports).filter(function(k) {\n var imp = getExportImport(depPkgJsonExports[k]);\n if (typeof imp !== \"string\") {\n return false;\n }\n if (!isPrebundleableEntry(imp)) {\n return false;\n }\n if (!k.match(/^(\\.\\/)?[a-zA-Z0-9-_]+$/)) {\n return false;\n }\n return true;\n }).map(function(k) {\n return k.replace(/^\\.\\/?/, \"\");\n }).map(function(k) {\n return `${dep}/${k}`;\n });\n var specialExports = (function() {\n switch (dep) {\n case \"react-native-vector-icons\":\n return [\n \"AntDesign\",\n \"Entypo\",\n \"EvilIcons\",\n \"Feather\",\n \"FontAwesome\",\n \"FontAwesome5\",\n \"FontAwesome5Pro\",\n \"Fontisto\",\n \"Foundation\",\n \"Ionicons\",\n \"MaterialCommunityIcons\",\n \"MaterialIcons\",\n \"Octicons\",\n \"SimpleLineIcons\",\n \"Zocial\"\n ].map(function(n) {\n return `${dep}/${n}`;\n });\n default:\n return [];\n }\n })();\n var mainExport = [\n depPkgJson[\"main\"],\n depPkgJson[\"module\"],\n getExportImport(depPkgJsonExports[\".\"])\n ].find(function(entry) {\n return typeof entry === \"string\" && entry && isPrebundleableEntry(entry);\n });\n var exports = [\n ...definedExports,\n ...specialExports\n ].filter(function(d) {\n return !EXCLUDE_LIST_SET.has(d);\n });\n if (mainExport) {\n if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport))) {\n exports.unshift(dep);\n }\n }\n return exports;\n })();\n var result = [\n ...depsToPreBundle,\n ...subDeps.prebundleDeps\n ];\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`final result ${JSON.stringify(result, null, 2)}`);\n proceededDeps.set(dep, result);\n return result;\n }))).flat().filter(function(dep, index, arr) {\n return arr.indexOf(dep) === index;\n });\n var hasNativewind = !!((_pkgJson_dependencies = pkgJson.dependencies) === null || _pkgJson_dependencies === void 0 ? void 0 : _pkgJson_dependencies[\"nativewind\"]);\n if ((hasNativewind || hasReanimated) && isRoot) {\n if (hasReanimated) console.info(`[one] Enabled babel plugins: ${[\n hasReanimated ? \"Reanimated\" : \"\",\n hasNativewind ? \"Nativewind\" : \"\"\n ].filter(Boolean).join(\", \")}`);\n }\n return {\n prebundleDeps,\n noExternalDeps: [\n ...noExternalDeps\n ],\n hasReanimated,\n // only check if set in root, dont want to enable css mode too easily\n hasNativewind\n };\n}\nasync function checkIfExportExists(pathIn) {\n var paths = [\n pathIn,\n ...extname(pathIn) ? [] : [\n pathIn + \".js\",\n pathIn + sep + \"index.js\"\n ]\n ];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = paths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var path2 = _step.value;\n if (await FSExtra.pathExists(path2)) {\n return true;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return false;\n}\nasync function readPackageJsonSafe(packageJsonPath) {\n try {\n return await FSExtra.readJson(packageJsonPath);\n } catch (e) {\n console.error(`[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`);\n return {};\n }\n}\nasync function resolveDepPkgJsonPath(dep, dependent) {\n var root = dependent;\n while (root) {\n var possiblePkgJson = path.join(root, \"node_modules\", dep, \"package.json\");\n if (await FSExtra.pathExists(possiblePkgJson)) {\n return possiblePkgJson;\n }\n var nextRoot = path.dirname(root);\n if (nextRoot === root) break;\n root = nextRoot;\n }\n}\nasync function findDepPkgJsonPath(dep, dependent) {\n var found = await resolveDepPkgJsonPath(dep, dependent);\n if (found) return found;\n console.error(`[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`);\n return void 0;\n}\nfunction hasRequiredDep(pkgJson, depName) {\n var _pkgJson_dependencies, _pkgJson_peerDependencies, _pkgJson_peerDependenciesMeta_depName, _pkgJson_peerDependenciesMeta;\n return !!(((_pkgJson_dependencies = pkgJson.dependencies) === null || _pkgJson_dependencies === void 0 ? void 0 : _pkgJson_dependencies[depName]) || ((_pkgJson_peerDependencies = pkgJson.peerDependencies) === null || _pkgJson_peerDependencies === void 0 ? void 0 : _pkgJson_peerDependencies[depName]) && !((_pkgJson_peerDependenciesMeta = pkgJson.peerDependenciesMeta) === null || _pkgJson_peerDependenciesMeta === void 0 ? void 0 : (_pkgJson_peerDependenciesMeta_depName = _pkgJson_peerDependenciesMeta[depName]) === null || _pkgJson_peerDependenciesMeta_depName === void 0 ? void 0 : _pkgJson_peerDependenciesMeta_depName.optional));\n}\nexport {\n EXCLUDE_LIST,\n EXCLUDE_LIST_SET,\n INCLUDE_LIST,\n INCLUDE_LIST_SET,\n findDepPkgJsonPath,\n scanDepsToOptimize\n};\n//# sourceMappingURL=scanDepsToOptimize.js.map\n"],"mappings":";;;;;AAGA,IAAI,EAAE,OAAO,iBAAiB,eAAe,yBAAyB;AACtE,SAAS,qBAAqB,MAAM;CAClC,OAAO,CAAC,iBAAiB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AAgB,IAAI,GAAG;EACpG,OAAO,CAAC;CACV;AACF;AACA,eAAe,sBAAsB,KAAK,WAAW;CACnD,IAAI,OAAO;CACX,OAAO,MAAM;EACX,IAAI,kBAAkB,KAAK,KAAK,MAAM,gBAAgB,KAAK,cAAc;EACzE,IAAI,MAAM,QAAQ,WAAW,eAAe,GAAG;GAC7C,OAAO;EACT;EACA,IAAI,WAAW,KAAK,QAAQ,IAAI;EAChC,IAAI,aAAa,MAAM;EACvB,OAAO;CACT;AACF;AACA,eAAe,mBAAmB,KAAK,WAAW;CAChD,IAAI,QAAQ,MAAM,sBAAsB,KAAK,SAAS;CACtD,IAAI,OAAO,OAAO;CAClB,QAAQ,MAAM,wDAAwD,IAAI,6BAA6B,WAAW;CAClH,OAAO,KAAK;AACd;AACA,SAAS,eAAe,SAAS,SAAS;CACxC,IAAI,uBAAuB,2BAA2B,uCAAuC;CAC7F,OAAO,CAAC,IAAI,wBAAwB,QAAQ,kBAAkB,QAAQ,0BAA0B,KAAK,IAAI,KAAK,IAAI,sBAAsB,eAAe,4BAA4B,QAAQ,sBAAsB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,aAAa,GAAG,gCAAgC,QAAQ,0BAA0B,QAAQ,kCAAkC,KAAK,IAAI,KAAK,KAAK,wCAAwC,8BAA8B,cAAc,QAAQ,0CAA0C,KAAK,IAAI,KAAK,IAAI,sCAAsC;AAClnB"}
|
|
1
|
+
{"version":3,"file":"scanDepsToOptimize.native.js","names":[],"sources":["utils/scanDepsToOptimize.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path, { dirname, extname, join, sep } from \"path\";\nvar { debug, debugDetails } = createDebugger(`vxrn:scanDepsToOptimize`);\nfunction isPrebundleableEntry(file) {\n return !/\\.d\\.[cm]?ts$/i.test(file) && (!extname(file) || /\\.[cm]?[jt]s$/.test(file));\n}\nfunction getExportsMap(exports) {\n if (typeof exports === \"string\") return {\n \".\": exports\n };\n if (!exports || typeof exports !== \"object\" || Array.isArray(exports)) return {};\n return Object.keys(exports).some(function(k) {\n return k.startsWith(\".\");\n }) ? exports : {\n \".\": exports\n };\n}\nfunction getExportImport(target) {\n return typeof target === \"string\" ? target : target === null || target === void 0 ? void 0 : target.import;\n}\nvar EXCLUDE_LIST = [\n \"jsc-android\",\n \"react-shallow-renderer\",\n \"fsevents\",\n \"@swc/core\",\n \"@swc/core-darwin-arm64\",\n \"@swc/core-darwin-x64\",\n \"@swc/core-linux-arm-gnueabihf\",\n \"@swc/core-linux-arm64-gnu\",\n \"@swc/core-linux-arm64-musl\",\n \"@swc/core-linux-x64-gnu\",\n \"@swc/core-linux-x64-musl\",\n \"@swc/core-win32-arm64-msvc\",\n \"@swc/core-win32-ia32-msvc\",\n \"@swc/core-win32-x64-msvc\",\n \"lightningcss\",\n // this breaks fileToUrlPath in upstreams, like @discordjs/client\n \"url\",\n \"sharp\",\n \"@sentry/react-native\",\n // not used by web anyway\n // Could not read from file: /Users/n8/one/node_modules/react-native-web/dist/cjs/index.js/Libraries/Image/AssetRegistry\n // /lib/module/Platform/Platform.web.js:132:20\n \"@shopify/react-native-skia\",\n \"@react-native/virtualized-lists\",\n // Unexpected \"typeof\" in `node_modules/@react-native/virtualized-lists/index.js`\n // Native only, we don't expect SSR to use these packages.\n // Also, some of these packages might attempt to import from react-native internals, which will break in SSR while react-native is aliased to react-native-web.\n \"@vxrn/vite-native-hmr\",\n \"@vxrn/compiler\",\n \"@vxrn/vite-native-client\",\n // build-time only, and they load native .node addons the ssr dep optimizer\n // cannot parse. apps list vxrn as a dependency because it is their dev\n // server, which is exactly why it must never be pre-bundled for ssr.\n \"vxrn\",\n \"@vxrn/vite-plugin-metro\",\n \"oxc-transform\",\n \"oxc-parser\",\n \"react-native-ios-utilities\",\n \"react-native-ios-modal\",\n \"react-native-ios-context-menu\",\n \"react-native-haptic-feedback\",\n \"react-native-sortables\",\n \"react-native-image-colors\",\n \"react-native-fast-image\",\n \"react-native-fast-squircle\",\n \"react-native-device-info\",\n // CLI/scripts shouldn't be used in SSR runtime\n \"@tamagui/cli\",\n // only used by static/plugin\n \"@tamagui/static\",\n \"@tamagui/config-default\",\n \"@tamagui/vite-plugin\",\n \"@take-out/scripts\",\n \"@take-out/cli\",\n // Should be used on native only\n \"@tamagui/core/native-test\",\n \"@storybook/react\",\n // native-only or not needed in SSR\n \"@nandorojo/galeria\",\n \"react-native-pager-view\",\n \"@react-native/debugger-shell\",\n // expo's debugger is a standalone app, not an SSR runtime dependency.\n \"@expo/cli\",\n \"@expo/log-box\",\n \"@hot-updater/react-native\",\n \"@hot-updater/plugin-core\",\n \"validator\",\n \"zlib\"\n];\nvar EXCLUDE_LIST_SET = new Set(EXCLUDE_LIST);\nvar INCLUDE_LIST = [\n // ReferenceError: exports is not defined - at eval (.../node_modules/inline-style-prefixer/lib/createPrefixer.js:3:23)\n \"inline-style-prefixer\",\n \"react-native-vector-icons\",\n \"jotai\"\n];\nvar INCLUDE_LIST_SET = new Set(INCLUDE_LIST);\nasync function scanDepsToOptimize(packageJsonPath) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : (\n /** If the content of the package.json is already read before calling this function, pass it here to avoid reading it again */\n {}\n );\n return scanDeps(packageJsonPath, options, {\n pathExists: memoizeRead(function(file) {\n return FSExtra.pathExists(file);\n }),\n realpath: memoizeRead(function(file) {\n return FSExtra.realpath(file);\n }),\n readJson: memoizeRead(function(file) {\n return FSExtra.readJson(file);\n })\n });\n}\nfunction memoizeRead(read) {\n var pending = /* @__PURE__ */ new Map();\n return function(file) {\n var key = path.resolve(file);\n var result = pending.get(key);\n if (!result) {\n result = read(key);\n pending.set(key, result);\n }\n return result;\n };\n}\nasync function scanDeps(packageJsonPath, options, fs) {\n var _pkgJson_dependencies;\n var { parentDepNames = [], proceededDeps = /* @__PURE__ */ new Map(), pkgJsonContent } = options;\n var isRoot = !options.parentDepNames;\n if (isRoot) {\n console.info(`[one] Scanning node_modules to auto-optimize...`);\n }\n var noExternalDeps = /* @__PURE__ */ new Set();\n var currentRoot = path.dirname(packageJsonPath);\n var pkgJson = pkgJsonContent || await readPackageJsonSafe(packageJsonPath, fs.readJson);\n var deps = Object.keys(pkgJson.dependencies || {});\n var needsWorklets = function needsWorklets2(json) {\n var _json_dependencies, _json_dependencies1;\n return !!(((_json_dependencies = json.dependencies) === null || _json_dependencies === void 0 ? void 0 : _json_dependencies[\"react-native-reanimated\"]) || ((_json_dependencies1 = json.dependencies) === null || _json_dependencies1 === void 0 ? void 0 : _json_dependencies1[\"react-native-worklets\"]));\n };\n var hasReanimated = isRoot ? (await Promise.all([\n \"react-native-reanimated\",\n \"react-native-worklets\"\n ].map(function(dep) {\n return resolveDepPkgJsonPath(dep, currentRoot, fs.pathExists);\n }))).some(Boolean) : needsWorklets(pkgJson);\n var prebundleDeps = (await Promise.all(deps.map(async function(dep) {\n var _depPkgJson_peerDependencies;\n if (parentDepNames.includes(dep)) {\n return [];\n }\n var cachedResult = proceededDeps.get(dep);\n if (cachedResult) {\n return cachedResult;\n }\n if (EXCLUDE_LIST_SET.has(dep)) {\n return [];\n }\n var localPath = await findDepPkgJsonPathWithFs(dep, currentRoot, fs.pathExists);\n if (!localPath) return [];\n var depPkgJsonPath = await fs.realpath(localPath);\n if (options.filter && !options.filter(depPkgJsonPath)) {\n return [];\n }\n var depPkgJson = await readPackageJsonSafe(depPkgJsonPath, fs.readJson);\n if (needsWorklets(depPkgJson)) {\n hasReanimated = true;\n }\n if (depPkgJson.codegenConfig != null) {\n noExternalDeps.add(dep);\n debug === null || debug === void 0 ? void 0 : debug(`${dep} skipped: declares codegenConfig (native codegen package)`);\n return [];\n }\n var subDeps = await scanDeps(depPkgJsonPath, {\n parentDepNames: [\n ...parentDepNames,\n dep\n ],\n pkgJsonContent: depPkgJson,\n proceededDeps\n }, fs);\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = subDeps.noExternalDeps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _$dep = _step.value;\n noExternalDeps.add(_$dep);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (subDeps.hasReanimated) {\n hasReanimated = true;\n }\n var shouldPreBundle = subDeps.prebundleDeps.length > 0 || /* If this dep is depending on other deps that need pre-bundling, then also pre-bundle this dep */\n INCLUDE_LIST_SET.has(dep) || /* If this dep is in the include list, then pre-bundle it */\n hasRequiredDep(depPkgJson, \"react\") || // an optional react peer still means the package ships react\n // entrypoints (e.g. better-auth/react). left external, those load a\n // second react copy in SSR and crash hooks with a null dispatcher.\n !!((_depPkgJson_peerDependencies = depPkgJson.peerDependencies) === null || _depPkgJson_peerDependencies === void 0 ? void 0 : _depPkgJson_peerDependencies.react) || hasRequiredDep(depPkgJson, \"react-native\") || hasRequiredDep(depPkgJson, \"expo-modules-core\") || // expo packages publish extensionless ESM imports that Node cannot\n // execute directly. Keep installed Expo modules inside Vite's SSR\n // graph without making Expo a framework dependency.\n dep.startsWith(\"@expo/\") || dep.startsWith(\"expo-\");\n debug === null || debug === void 0 ? void 0 : debug(`${dep} shouldPreBundle? ${shouldPreBundle}`);\n var depsToPreBundle = await (async function() {\n if (!shouldPreBundle) {\n return [];\n }\n var depPkgJsonExports = getExportsMap(depPkgJson.exports);\n var definedExports = Object.keys(depPkgJsonExports).filter(function(k) {\n var imp = getExportImport(depPkgJsonExports[k]);\n if (typeof imp !== \"string\") {\n return false;\n }\n if (!isPrebundleableEntry(imp)) {\n return false;\n }\n if (!k.match(/^(\\.\\/)?[a-zA-Z0-9-_]+$/)) {\n return false;\n }\n return true;\n }).map(function(k) {\n return k.replace(/^\\.\\/?/, \"\");\n }).map(function(k) {\n return `${dep}/${k}`;\n });\n var specialExports = (function() {\n switch (dep) {\n case \"react-native-vector-icons\":\n return [\n \"AntDesign\",\n \"Entypo\",\n \"EvilIcons\",\n \"Feather\",\n \"FontAwesome\",\n \"FontAwesome5\",\n \"FontAwesome5Pro\",\n \"Fontisto\",\n \"Foundation\",\n \"Ionicons\",\n \"MaterialCommunityIcons\",\n \"MaterialIcons\",\n \"Octicons\",\n \"SimpleLineIcons\",\n \"Zocial\"\n ].map(function(n) {\n return `${dep}/${n}`;\n });\n default:\n return [];\n }\n })();\n var mainExport = [\n depPkgJson[\"main\"],\n depPkgJson[\"module\"],\n getExportImport(depPkgJsonExports[\".\"])\n ].find(function(entry) {\n return typeof entry === \"string\" && entry && isPrebundleableEntry(entry);\n });\n var exports = [\n ...definedExports,\n ...specialExports\n ].filter(function(d) {\n return !EXCLUDE_LIST_SET.has(d);\n });\n if (mainExport) {\n if (await checkIfExportExists(join(dirname(depPkgJsonPath), mainExport), fs.pathExists)) {\n exports.unshift(dep);\n }\n }\n return exports;\n })();\n var result = [\n ...depsToPreBundle,\n ...subDeps.prebundleDeps\n ];\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`final result ${JSON.stringify(result, null, 2)}`);\n proceededDeps.set(dep, result);\n return result;\n }))).flat().filter(function(dep, index, arr) {\n return arr.indexOf(dep) === index;\n });\n var hasNativewind = !!((_pkgJson_dependencies = pkgJson.dependencies) === null || _pkgJson_dependencies === void 0 ? void 0 : _pkgJson_dependencies[\"nativewind\"]);\n if ((hasNativewind || hasReanimated) && isRoot) {\n if (hasReanimated) console.info(`[one] Enabled babel plugins: ${[\n hasReanimated ? \"Reanimated\" : \"\",\n hasNativewind ? \"Nativewind\" : \"\"\n ].filter(Boolean).join(\", \")}`);\n }\n return {\n prebundleDeps,\n noExternalDeps: [\n ...noExternalDeps\n ],\n hasReanimated,\n // only check if set in root, dont want to enable css mode too easily\n hasNativewind\n };\n}\nasync function checkIfExportExists(pathIn, pathExists) {\n var paths = [\n pathIn,\n ...extname(pathIn) ? [] : [\n pathIn + \".js\",\n pathIn + sep + \"index.js\"\n ]\n ];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = paths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var path2 = _step.value;\n if (await pathExists(path2)) {\n return true;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return false;\n}\nasync function readPackageJsonSafe(packageJsonPath, readJson) {\n try {\n return await readJson(packageJsonPath);\n } catch (e) {\n console.error(`[scanDepsToPreBundleForSsr] Error reading package.json from ${packageJsonPath}: ${e}`);\n return {};\n }\n}\nasync function resolveDepPkgJsonPath(dep, dependent, pathExists) {\n var root = dependent;\n while (root) {\n var possiblePkgJson = path.join(root, \"node_modules\", dep, \"package.json\");\n if (await pathExists(possiblePkgJson)) {\n return possiblePkgJson;\n }\n var nextRoot = path.dirname(root);\n if (nextRoot === root) break;\n root = nextRoot;\n }\n}\nasync function findDepPkgJsonPath(dep, dependent) {\n return findDepPkgJsonPathWithFs(dep, dependent, function(file) {\n return FSExtra.pathExists(file);\n });\n}\nasync function findDepPkgJsonPathWithFs(dep, dependent, pathExists) {\n var found = await resolveDepPkgJsonPath(dep, dependent, pathExists);\n if (found) return found;\n console.error(`[findDepPkgJsonPath] Could not find package.json for ${dep}, which is a dependency of ${dependent}`);\n return void 0;\n}\nfunction hasRequiredDep(pkgJson, depName) {\n var _pkgJson_dependencies, _pkgJson_peerDependencies, _pkgJson_peerDependenciesMeta_depName, _pkgJson_peerDependenciesMeta;\n return !!(((_pkgJson_dependencies = pkgJson.dependencies) === null || _pkgJson_dependencies === void 0 ? void 0 : _pkgJson_dependencies[depName]) || ((_pkgJson_peerDependencies = pkgJson.peerDependencies) === null || _pkgJson_peerDependencies === void 0 ? void 0 : _pkgJson_peerDependencies[depName]) && !((_pkgJson_peerDependenciesMeta = pkgJson.peerDependenciesMeta) === null || _pkgJson_peerDependenciesMeta === void 0 ? void 0 : (_pkgJson_peerDependenciesMeta_depName = _pkgJson_peerDependenciesMeta[depName]) === null || _pkgJson_peerDependenciesMeta_depName === void 0 ? void 0 : _pkgJson_peerDependenciesMeta_depName.optional));\n}\nexport {\n EXCLUDE_LIST,\n EXCLUDE_LIST_SET,\n INCLUDE_LIST,\n INCLUDE_LIST_SET,\n findDepPkgJsonPath,\n scanDepsToOptimize\n};\n//# sourceMappingURL=scanDepsToOptimize.js.map\n"],"mappings":";;;;;AAGA,IAAI,EAAE,OAAO,iBAAiB,eAAe,yBAAyB;AACtE,SAAS,qBAAqB,MAAM;CAClC,OAAO,CAAC,iBAAiB,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,gBAAgB,KAAK,IAAI;AACrF;AACA,SAAS,cAAc,SAAS;CAC9B,IAAI,OAAO,YAAY,UAAU,OAAO,EACtC,KAAK,QACP;CACA,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC;CAC/E,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS,GAAG;EAC3C,OAAO,EAAE,WAAW,GAAG;CACzB,CAAC,IAAI,UAAU,EACb,KAAK,QACP;AACF;AACA,SAAS,gBAAgB,QAAQ;CAC/B,OAAO,OAAO,WAAW,WAAW,SAAS,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO;AACtG;AACA,IAAI,eAAe;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAIA;CACA;CAIA;CACA;CACA;CAIA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA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Y;CAC/D,IAAI,OAAO;CACX,OAAO,MAAM;EACX,IAAI,kBAAkB,KAAK,KAAK,MAAM,gBAAgB,KAAK,cAAc;EACzE,IAAI,MAAM,WAAW,eAAe,GAAG;GACrC,OAAO;EACT;EACA,IAAI,WAAW,KAAK,QAAQ,IAAI;EAChC,IAAI,aAAa,MAAM;EACvB,OAAO;CACT;AACF;AACA,eAAe,mBAAmB,KAAK,WAAW;CAChD,OAAO,yBAAyB,KAAK,WAAW,SAAS,MAAM;EAC7D,OAAO,QAAQ,WAAW,IAAI;CAChC,CAAC;AACH;AACA,eAAe,yBAAyB,KAAK,WAAW,YAAY;CAClE,IAAI,QAAQ,MAAM,sBAAsB,KAAK,WAAW,UAAU;CAClE,IAAI,OAAO,OAAO;CAClB,QAAQ,MAAM,wDAAwD,IAAI,6BAA6B,WAAW;CAClH,OAAO,KAAK;AACd;AACA,SAAS,eAAe,SAAS,SAAS;CACxC,IAAI,uBAAuB,2BAA2B,uCAAuC;CAC7F,OAAO,CAAC,IAAI,wBAAwB,QAAQ,kBAAkB,QAAQ,0BAA0B,KAAK,IAAI,KAAK,IAAI,sBAAsB,eAAe,4BAA4B,QAAQ,sBAAsB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,aAAa,GAAG,gCAAgC,QAAQ,0BAA0B,QAAQ,kCAAkC,KAAK,IAAI,KAAK,KAAK,wCAAwC,8BAA8B,cAAc,QAAQ,0CAA0C,KAAK,IAAI,KAAK,IAAI,sCAAsC;AAClnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxrn",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
"@react-native-community/cli": "^20.2.0",
|
|
81
81
|
"@react-native-community/cli-config": "^20.2.0",
|
|
82
82
|
"@react-native/dev-middleware": "^0.88.0",
|
|
83
|
-
"@vxrn/compiler": "2.
|
|
84
|
-
"@vxrn/debug": "2.
|
|
85
|
-
"@vxrn/query-string": "2.
|
|
86
|
-
"@vxrn/resolve": "2.
|
|
87
|
-
"@vxrn/url-parse": "2.
|
|
88
|
-
"@vxrn/utils": "2.
|
|
89
|
-
"@vxrn/vendor": "2.
|
|
90
|
-
"@vxrn/vite-flow": "2.
|
|
83
|
+
"@vxrn/compiler": "2.11.0",
|
|
84
|
+
"@vxrn/debug": "2.11.0",
|
|
85
|
+
"@vxrn/query-string": "2.11.0",
|
|
86
|
+
"@vxrn/resolve": "2.11.0",
|
|
87
|
+
"@vxrn/url-parse": "2.11.0",
|
|
88
|
+
"@vxrn/utils": "2.11.0",
|
|
89
|
+
"@vxrn/vendor": "2.11.0",
|
|
90
|
+
"@vxrn/vite-flow": "2.11.0",
|
|
91
91
|
"citty": "^0.1.6",
|
|
92
92
|
"dotenv": "^17.2.1",
|
|
93
93
|
"dotenv-expand": "^12.0.2",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@biomejs/biome": "2.5.15",
|
|
119
119
|
"@jridgewell/gen-mapping": "^0.3.5",
|
|
120
|
-
"@tamagui/build": "3.1.
|
|
120
|
+
"@tamagui/build": "3.1.4",
|
|
121
121
|
"@types/find-node-modules": "^2.1.2",
|
|
122
122
|
"@types/node": "^24.10.0",
|
|
123
123
|
"@types/ws": "^8.18.1",
|
|
@@ -127,20 +127,20 @@
|
|
|
127
127
|
"react-native": "0.88.0",
|
|
128
128
|
"typescript": "7.0.2",
|
|
129
129
|
"vitest": "^4.1.0",
|
|
130
|
-
"@vxrn/vite-plugin-metro": "2.
|
|
130
|
+
"@vxrn/vite-plugin-metro": "2.11.0"
|
|
131
131
|
},
|
|
132
132
|
"publishConfig": {
|
|
133
133
|
"access": "public"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
|
-
"@vxrn/vite-plugin-metro": "2.
|
|
136
|
+
"@vxrn/vite-plugin-metro": "2.11.0"
|
|
137
137
|
},
|
|
138
138
|
"peerDependenciesMeta": {
|
|
139
139
|
"@vxrn/vite-plugin-metro": {
|
|
140
140
|
"optional": true
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
|
-
"releaseSourceCommit": "
|
|
143
|
+
"releaseSourceCommit": "bf80198102404c68db48c370ca8c888b515afdec",
|
|
144
144
|
"repository": {
|
|
145
145
|
"type": "git",
|
|
146
146
|
"url": "git+https://github.com/onejs/one.git",
|
|
@@ -20,6 +20,8 @@ const PLATFORM_EXTENSIONS_BY_ENVIRONMENT = {
|
|
|
20
20
|
worker: ['server', 'web'],
|
|
21
21
|
ios: ['ios', 'native'],
|
|
22
22
|
android: ['android', 'native'],
|
|
23
|
+
macos: ['macos', 'native'],
|
|
24
|
+
linux: ['linux', 'native'],
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export function getBaseVitePlugins(): PluginOption[] {
|
package/src/constants.ts
CHANGED
|
@@ -42,3 +42,27 @@ export const androidExtensions = [
|
|
|
42
42
|
'.native.js',
|
|
43
43
|
...viteDefaultExtensions,
|
|
44
44
|
]
|
|
45
|
+
|
|
46
|
+
export const macosExtensions = [
|
|
47
|
+
'.macos.tsx',
|
|
48
|
+
'.macos.ts',
|
|
49
|
+
'.macos.mjs',
|
|
50
|
+
'.macos.js',
|
|
51
|
+
'.native.tsx',
|
|
52
|
+
'.native.ts',
|
|
53
|
+
'.native.mjs',
|
|
54
|
+
'.native.js',
|
|
55
|
+
...viteDefaultExtensions,
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
export const linuxExtensions = [
|
|
59
|
+
'.linux.tsx',
|
|
60
|
+
'.linux.ts',
|
|
61
|
+
'.linux.mjs',
|
|
62
|
+
'.linux.js',
|
|
63
|
+
'.native.tsx',
|
|
64
|
+
'.native.ts',
|
|
65
|
+
'.native.mjs',
|
|
66
|
+
'.native.js',
|
|
67
|
+
...viteDefaultExtensions,
|
|
68
|
+
]
|