vxrn 2.7.6 → 2.8.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.
Files changed (53) hide show
  1. package/dist/config/getBaseViteConfigOnly.mjs +1 -1
  2. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  3. package/dist/config/getBaseViteConfigOnly.native.js +1 -1
  4. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  5. package/dist/config/getOptimizeDeps.mjs +1 -1
  6. package/dist/config/getOptimizeDeps.mjs.map +1 -1
  7. package/dist/config/getOptimizeDeps.native.js +3 -1
  8. package/dist/config/getOptimizeDeps.native.js.map +1 -1
  9. package/dist/config/getReactNativePlugins.mjs +1 -2
  10. package/dist/config/getReactNativePlugins.mjs.map +1 -1
  11. package/dist/config/getReactNativePlugins.native.js +4 -2
  12. package/dist/config/getReactNativePlugins.native.js.map +1 -1
  13. package/dist/exports/prebuildWithoutExpo.mjs +26 -97
  14. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  15. package/dist/exports/prebuildWithoutExpo.native.js +47 -133
  16. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  17. package/dist/plugins/autoDepOptimizePlugin.mjs +5 -2
  18. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  19. package/dist/plugins/autoDepOptimizePlugin.native.js +10 -7
  20. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  21. package/dist/rn-commands/bundle/buildBundle.mjs +5 -4
  22. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  23. package/dist/rn-commands/bundle/buildBundle.native.js +5 -4
  24. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  25. package/dist/utils/createNativeDevEngine.mjs +30 -7
  26. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  27. package/dist/utils/createNativeDevEngine.native.js +64 -10
  28. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  29. package/package.json +27 -20
  30. package/src/config/getBaseViteConfigOnly.ts +1 -1
  31. package/src/config/getOptimizeDeps.ts +3 -1
  32. package/src/config/getReactNativePlugins.ts +8 -4
  33. package/src/config/ssrVendorOptimization.test.ts +115 -0
  34. package/src/exports/prebuildWithoutExpo.test.ts +62 -157
  35. package/src/exports/prebuildWithoutExpo.ts +31 -125
  36. package/src/plugins/autoDepOptimizeExternal.test.ts +101 -0
  37. package/src/plugins/autoDepOptimizePlugin.ts +12 -6
  38. package/src/plugins/rnCodegenPlugin.ts +1 -2
  39. package/src/rn-commands/bundle/buildBundle.ts +8 -7
  40. package/src/utils/createNativeDevEngine.test.ts +308 -9
  41. package/src/utils/createNativeDevEngine.ts +71 -29
  42. package/types/config/getOptimizeDeps.d.ts.map +1 -1
  43. package/types/config/getReactNativePlugins.d.ts +3 -2
  44. package/types/config/getReactNativePlugins.d.ts.map +1 -1
  45. package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
  46. package/types/plugins/autoDepOptimizePlugin.d.ts +1 -0
  47. package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
  48. package/types/plugins/rnCodegenPlugin.d.ts.map +1 -1
  49. package/types/rn-commands/bundle/buildBundle.d.ts +1 -1
  50. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  51. package/types/utils/createNativeDevEngine.d.ts +3 -4
  52. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  53. package/src/plugins/autoDepOptimizePlugin.test.ts +0 -42
@@ -23,6 +23,7 @@ function autoDepOptimizePlugin(props) {
23
23
  const finalConfig = await getScannedOptimizeDepsConfig({
24
24
  ...props,
25
25
  mode: env.mode,
26
+ external: cfg.ssr?.external,
26
27
  exclude: [
27
28
  ...exclude,
28
29
  ...userExcludes,
@@ -45,13 +46,15 @@ async function getScannedOptimizeDepsConfig(props) {
45
46
  const excludeArray = Array.isArray(props.exclude) ? props.exclude : [props.exclude];
46
47
  const excludeStrings = excludeArray.filter((e) => typeof e === "string");
47
48
  const excludeSet = new Set(excludeStrings);
48
- const filteredDeps = result.prebundleDeps.filter((dep) => !excludeSet.has(dep));
49
+ const external = props.external;
50
+ const shouldOptimize = (dep) => !excludeSet.has(dep) && external !== true && !external?.some((name2) => dep === name2 || dep.startsWith(`${name2}/`));
51
+ const filteredDeps = result.prebundleDeps.filter(shouldOptimize);
49
52
  return { ssr: {
50
53
  optimizeDeps: {
51
54
  include: filteredDeps,
52
55
  exclude: EXCLUDE_LIST
53
56
  },
54
- noExternal: [...filteredDeps, ...result.noExternalDeps.filter((dep) => !excludeSet.has(dep))]
57
+ noExternal: [...filteredDeps, ...result.noExternalDeps.filter(shouldOptimize)]
55
58
  } };
56
59
  }
57
60
  let sessionCacheVal = null;
@@ -1 +1 @@
1
- {"version":3,"file":"autoDepOptimizePlugin.js","names":[],"sources":["plugins/autoDepOptimizePlugin.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"node:path\";\nimport { createFilter } from \"vite\";\nimport {\n EXCLUDE_LIST,\n scanDepsToOptimize\n} from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nconst name = \"vxrn:auto-dep-optimize\";\nconst { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n debug?.(\"Config hook called\");\n const userOptions = globalThis.__oneOptions;\n const depsConfig = userOptions?.deps;\n const exclude = depsConfig ? Object.entries(depsConfig).filter(([_, value]) => value === false).map(([k]) => k) : [];\n const userExcludes = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const userViteExcludes = cfg.optimizeDeps?.exclude || [];\n const userSsrExcludes = cfg.ssr?.optimizeDeps?.exclude || [];\n const finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails?.(\n `Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`\n );\n return finalConfig;\n }\n };\n}\nconst getSSRExternalsCachePath = (root) => {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n const result = await findDepsToOptimize(props);\n props.onScannedDeps?.(result);\n const excludeArray = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const excludeStrings = excludeArray.filter((e) => typeof e === \"string\");\n const excludeSet = new Set(excludeStrings);\n const filteredDeps = result.prebundleDeps.filter((dep) => !excludeSet.has(dep));\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [\n ...filteredDeps,\n ...result.noExternalDeps.filter((dep) => !excludeSet.has(dep))\n ]\n }\n };\n}\nlet sessionCacheVal = null;\nasync function findDepsToOptimize({\n root,\n mode,\n exclude,\n include\n}) {\n const cacheFilePath = getSSRExternalsCachePath(root);\n const startedAt = debug ? Date.now() : 0;\n const noCache = mode === \"production\";\n const sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n const lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n const lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n let value;\n if (lockFileHash && !noCache) {\n try {\n const {\n lockFileHash: cachedLockFileHash,\n depsToPreBundleForSsr: cachedDepsToPreBundle\n } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug?.(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug?.(`${err}`);\n }\n }\n const filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, { filter });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug?.(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug?.(\n `${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`)\n );\n debugDetails?.(\n `Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`\n );\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAUA,MAAM,OAAO;AACb,MAAM,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACnD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,QAAQ,oBAAoB;GAC5B,MAAM,cAAc,WAAW;GAC/B,MAAM,aAAa,aAAa;GAChC,MAAM,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;GACnH,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,MAAM,OAAO;GAClF,MAAM,mBAAmB,IAAI,cAAc,WAAW,CAAC;GACvD,MAAM,kBAAkB,IAAI,KAAK,cAAc,WAAW,CAAC;GAC3D,MAAM,cAAc,MAAM,6BAA6B;IACrD,GAAG;IACH,MAAM,IAAI;IACV,SAAS;KACP,GAAG;KACH,GAAG;KACH,GAAG;KACH,GAAG;IACL,CAAC,CAAC,OAAO,OAAO;GAClB,CA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AAC,CAAC,yBAAyB,mBAAmB,yBAAyB,MAAM,QAAQ,sBAAsB,cAAc,GAAG;IACrK,QAAQ;IACR,QAAQ,kCAAkC,eAAe;GAC3D;EACF,SAAS,KAAK;GACZ,QAAQ,GAAG,KAAK;EAClB;CACF;CACA,MAAM,SAAS,aAAa,SAAS,OAAO;CAC5C,IAAI,CAAC,OAAO;EACV,QAAQ,MAAM,mBAAmB,GAAG,KAAK,gBAAgB,EAAE,OAAO,CAAC;EACnE,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,QAAQ,WAAW,eAAe;IACrC;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,QAAQ,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CAC3D,QACE,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BACrK;CACA,eACE,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAC7E;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"autoDepOptimizePlugin.js","names":[],"sources":["plugins/autoDepOptimizePlugin.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"node:path\";\nimport { createFilter } from \"vite\";\nimport {\n EXCLUDE_LIST,\n scanDepsToOptimize\n} from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nconst name = \"vxrn:auto-dep-optimize\";\nconst { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n debug?.(\"Config hook called\");\n const userOptions = globalThis.__oneOptions;\n const depsConfig = userOptions?.deps;\n const exclude = depsConfig ? Object.entries(depsConfig).filter(([_, value]) => value === false).map(([k]) => k) : [];\n const userExcludes = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const userViteExcludes = cfg.optimizeDeps?.exclude || [];\n const userSsrExcludes = cfg.ssr?.optimizeDeps?.exclude || [];\n const finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: cfg.ssr?.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails?.(\n `Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`\n );\n return finalConfig;\n }\n };\n}\nconst getSSRExternalsCachePath = (root) => {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n const result = await findDepsToOptimize(props);\n props.onScannedDeps?.(result);\n const excludeArray = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const excludeStrings = excludeArray.filter((e) => typeof e === \"string\");\n const excludeSet = new Set(excludeStrings);\n const external = props.external;\n const shouldOptimize = (dep) => !excludeSet.has(dep) && external !== true && !external?.some((name2) => dep === name2 || dep.startsWith(`${name2}/`));\n const filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [...filteredDeps, ...result.noExternalDeps.filter(shouldOptimize)]\n }\n };\n}\nlet sessionCacheVal = null;\nasync function findDepsToOptimize({\n root,\n mode,\n exclude,\n include\n}) {\n const cacheFilePath = getSSRExternalsCachePath(root);\n const startedAt = debug ? Date.now() : 0;\n const noCache = mode === \"production\";\n const sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n const lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n const lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n let value;\n if (lockFileHash && !noCache) {\n try {\n const {\n lockFileHash: cachedLockFileHash,\n depsToPreBundleForSsr: cachedDepsToPreBundle\n } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug?.(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug?.(`${err}`);\n }\n }\n const filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, { filter });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug?.(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug?.(\n `${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`)\n );\n debugDetails?.(\n `Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`\n );\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAUA,MAAM,OAAO;AACb,MAAM,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACnD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,QAAQ,oBAAoB;GAC5B,MAAM,cAAc,WAAW;GAC/B,MAAM,aAAa,aAAa;GAChC,MAAM,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;GACnH,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU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AQ,KAAK,IAAI,IAAI;CACvC,MAAM,UAAU,SAAS;CACzB,MAAM,eAAe,SAAS;CAC9B,IAAI,gBAAgB,iBAAiB;EACnC,OAAO;CACT;CACA,MAAM,WAAW,MAAM,WAAW,MAAM;EACtC;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,eAAe,WAAW,MAAM,YAAY,QAAQ,IAAI,KAAK;CACnE,IAAI;CACJ,IAAI,gBAAgB,CAAC,SAAS;EAC5B,IAAI;GACF,MAAM,EACJ,cAAc,oBACd,uBAAuB,0BACrB,MAAM,QAAQ,SAAS,aAAa;GACxC,IAAI,iBAAiB,sBAAsB,CAAC,CAAC,yBAAyB,mBAAmB,yBAAyB,MAAM,QAAQ,sBAAsB,cAAc,GAAG;IACrK,QAAQ;IACR,QAAQ,kCAAkC,eAAe;GAC3D;EACF,SAAS,KAAK;GACZ,QAAQ,GAAG,KAAK;EAClB;CACF;CACA,MAAM,SAAS,aAAa,SAAS,OAAO;CAC5C,IAAI,CAAC,OAAO;EACV,QAAQ,MAAM,mBAAmB,GAAG,KAAK,gBAAgB,EAAE,OAAO,CAAC;EACnE,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,QAAQ,WAAW,eAAe;IACrC;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,QAAQ,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CAC3D,QACE,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BACrK;CACA,eACE,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAC7E;CACA,OAAO;AACT"}
@@ -13,7 +13,7 @@ function autoDepOptimizePlugin(props) {
13
13
  name,
14
14
  enforce: "pre",
15
15
  async config(cfg, env) {
16
- var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr;
16
+ var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr, _cfg_ssr1;
17
17
  debug === null || debug === void 0 ? void 0 : debug("Config hook called");
18
18
  var userOptions = globalThis.__oneOptions;
19
19
  var depsConfig = userOptions === null || userOptions === void 0 ? void 0 : userOptions.deps;
@@ -30,6 +30,7 @@ function autoDepOptimizePlugin(props) {
30
30
  var finalConfig = await getScannedOptimizeDepsConfig({
31
31
  ...props,
32
32
  mode: env.mode,
33
+ external: (_cfg_ssr1 = cfg.ssr) === null || _cfg_ssr1 === void 0 ? void 0 : _cfg_ssr1.external,
33
34
  exclude: [
34
35
  ...exclude,
35
36
  ...userExcludes,
@@ -55,17 +56,19 @@ async function getScannedOptimizeDepsConfig(props) {
55
56
  return typeof e === "string";
56
57
  });
57
58
  var excludeSet = new Set(excludeStrings);
58
- var filteredDeps = result.prebundleDeps.filter(function(dep) {
59
- return !excludeSet.has(dep);
60
- });
59
+ var external = props.external;
60
+ var shouldOptimize = function shouldOptimize2(dep) {
61
+ return !excludeSet.has(dep) && external !== true && !(external === null || external === void 0 ? void 0 : external.some(function(name2) {
62
+ return dep === name2 || dep.startsWith(`${name2}/`);
63
+ }));
64
+ };
65
+ var filteredDeps = result.prebundleDeps.filter(shouldOptimize);
61
66
  return { ssr: {
62
67
  optimizeDeps: {
63
68
  include: filteredDeps,
64
69
  exclude: EXCLUDE_LIST
65
70
  },
66
- noExternal: [...filteredDeps, ...result.noExternalDeps.filter(function(dep) {
67
- return !excludeSet.has(dep);
68
- })]
71
+ noExternal: [...filteredDeps, ...result.noExternalDeps.filter(shouldOptimize)]
69
72
  } };
70
73
  }
71
74
  var sessionCacheVal = null;
@@ -1 +1 @@
1
- {"version":3,"file":"autoDepOptimizePlugin.native.js","names":[],"sources":["plugins/autoDepOptimizePlugin.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"path\";\nimport { createFilter } from \"vite\";\nimport { EXCLUDE_LIST, scanDepsToOptimize } from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nvar name = \"vxrn:auto-dep-optimize\";\nvar { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr;\n debug === null || debug === void 0 ? void 0 : debug(\"Config hook called\");\n var userOptions = globalThis.__oneOptions;\n var depsConfig = userOptions === null || userOptions === void 0 ? void 0 : userOptions.deps;\n var exclude = depsConfig ? Object.entries(depsConfig).filter(function(param) {\n var [_, value] = param;\n return value === false;\n }).map(function(param) {\n var [k] = param;\n return k;\n }) : [];\n var userExcludes = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var userViteExcludes = ((_cfg_optimizeDeps = cfg.optimizeDeps) === null || _cfg_optimizeDeps === void 0 ? void 0 : _cfg_optimizeDeps.exclude) || [];\n var userSsrExcludes = ((_cfg_ssr = cfg.ssr) === null || _cfg_ssr === void 0 ? void 0 : (_cfg_ssr_optimizeDeps = _cfg_ssr.optimizeDeps) === null || _cfg_ssr_optimizeDeps === void 0 ? void 0 : _cfg_ssr_optimizeDeps.exclude) || [];\n var finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`);\n return finalConfig;\n }\n };\n}\nvar getSSRExternalsCachePath = function getSSRExternalsCachePath2(root) {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n var _props_onScannedDeps;\n var result = await findDepsToOptimize(props);\n (_props_onScannedDeps = props.onScannedDeps) === null || _props_onScannedDeps === void 0 ? void 0 : _props_onScannedDeps.call(props, result);\n var excludeArray = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var excludeStrings = excludeArray.filter(function(e) {\n return typeof e === \"string\";\n });\n var excludeSet = new Set(excludeStrings);\n var filteredDeps = result.prebundleDeps.filter(function(dep) {\n return !excludeSet.has(dep);\n });\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [\n ...filteredDeps,\n ...result.noExternalDeps.filter(function(dep) {\n return !excludeSet.has(dep);\n })\n ]\n }\n };\n}\nvar sessionCacheVal = null;\nasync function findDepsToOptimize(param) {\n var { root, mode, exclude, include } = param;\n var cacheFilePath = getSSRExternalsCachePath(root);\n var startedAt = debug ? Date.now() : 0;\n var noCache = mode === \"production\";\n var sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n var lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n var lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n var value;\n if (lockFileHash && !noCache) {\n try {\n var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug === null || debug === void 0 ? void 0 : debug(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug === null || debug === void 0 ? void 0 : debug(`${err}`);\n }\n }\n var filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, {\n filter\n });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug === null || debug === void 0 ? void 0 : debug(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug === null || debug === void 0 ? void 0 : debug(`${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`));\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`);\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAOA,IAAI,OAAO;AACX,IAAI,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACjD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,IAAI,mBAAmB,uBAAuB;GAC9C,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,oBAAoB;GACxE,IAAI,cAAc,WAAW;GAC7B,IAAI,aAAa,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI,KAAK,IAAI,YAAY;GACvF,IAAI,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,OAAO,SAAS,OAAO;IAC3E,IAAI,CAAC,GAAG,SAAS;IACjB,OAAO,UAAU;GACnB,CAAC,CAAC,CAAC,IAAI,SAAS,OAAO;IACrB,IAAI,CAAC,KAAK;IACV,OAAO;GACT,CAAC,IAAI,CAAC;GACN,IAAI,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU,CAChE,MAAM,OACR;GACA,IAAI,qBAAqB,oBAAoB,IAAI,kBAAkB,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,YAAY,CAAC;GAClJ,IAAI,oBAAoB,WAAW,IAAI,SAAS,QAAQ,aAAa,KAAK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P,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAAG;CACvJ,OAAO;AACT"}
1
+ {"version":3,"file":"autoDepOptimizePlugin.native.js","names":[],"sources":["plugins/autoDepOptimizePlugin.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"path\";\nimport { createFilter } from \"vite\";\nimport { EXCLUDE_LIST, scanDepsToOptimize } from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nvar name = \"vxrn:auto-dep-optimize\";\nvar { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr, _cfg_ssr1;\n debug === null || debug === void 0 ? void 0 : debug(\"Config hook called\");\n var userOptions = globalThis.__oneOptions;\n var depsConfig = userOptions === null || userOptions === void 0 ? void 0 : userOptions.deps;\n var exclude = depsConfig ? Object.entries(depsConfig).filter(function(param) {\n var [_, value] = param;\n return value === false;\n }).map(function(param) {\n var [k] = param;\n return k;\n }) : [];\n var userExcludes = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var userViteExcludes = ((_cfg_optimizeDeps = cfg.optimizeDeps) === null || _cfg_optimizeDeps === void 0 ? void 0 : _cfg_optimizeDeps.exclude) || [];\n var userSsrExcludes = ((_cfg_ssr = cfg.ssr) === null || _cfg_ssr === void 0 ? void 0 : (_cfg_ssr_optimizeDeps = _cfg_ssr.optimizeDeps) === null || _cfg_ssr_optimizeDeps === void 0 ? void 0 : _cfg_ssr_optimizeDeps.exclude) || [];\n var finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: (_cfg_ssr1 = cfg.ssr) === null || _cfg_ssr1 === void 0 ? void 0 : _cfg_ssr1.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`);\n return finalConfig;\n }\n };\n}\nvar getSSRExternalsCachePath = function getSSRExternalsCachePath2(root) {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n var _props_onScannedDeps;\n var result = await findDepsToOptimize(props);\n (_props_onScannedDeps = props.onScannedDeps) === null || _props_onScannedDeps === void 0 ? void 0 : _props_onScannedDeps.call(props, result);\n var excludeArray = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var excludeStrings = excludeArray.filter(function(e) {\n return typeof e === \"string\";\n });\n var excludeSet = new Set(excludeStrings);\n var external = props.external;\n var shouldOptimize = function shouldOptimize2(dep) {\n return !excludeSet.has(dep) && external !== true && !(external === null || external === void 0 ? void 0 : external.some(function(name2) {\n return dep === name2 || dep.startsWith(`${name2}/`);\n }));\n };\n var filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [\n ...filteredDeps,\n ...result.noExternalDeps.filter(shouldOptimize)\n ]\n }\n };\n}\nvar sessionCacheVal = null;\nasync function findDepsToOptimize(param) {\n var { root, mode, exclude, include } = param;\n var cacheFilePath = getSSRExternalsCachePath(root);\n var startedAt = debug ? Date.now() : 0;\n var noCache = mode === \"production\";\n var sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n var lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n var lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n var value;\n if (lockFileHash && !noCache) {\n try {\n var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug === null || debug === void 0 ? void 0 : debug(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug === null || debug === void 0 ? void 0 : debug(`${err}`);\n }\n }\n var filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, {\n filter\n });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug === null || debug === void 0 ? void 0 : debug(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug === null || debug === void 0 ? void 0 : debug(`${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`));\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`);\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAOA,IAAI,OAAO;AACX,IAAI,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACjD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,IAAI,mBAAmB,uBAAuB,UAAU;GACxD,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,oBAAoB;GACxE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,SAAS,aAAa;GAC7H,IAAI,iBAAiB,sBAAsB,CAAC,CAAC,yBAAyB,mBAAmB,yBAAyB,MAAM,QAAQ,sBAAsB,cAAc,GAAG;IACrK,QAAQ;IACR,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,kCAAkC,eAAe;GACvG;EACF,SAAS,KAAK;GACZ,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,KAAK;EAC9D;CACF;CACA,IAAI,SAAS,aAAa,SAAS,OAAO;CAC1C,IAAI,CAAC,OAAO;EACV,QAAQ,MAAM,mBAAmB,GAAG,KAAK,gBAAgB,EACvD,OACF,CAAC;EACD,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,QAAQ,WAAW,eAAe;IACrC;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CACvG,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BAA0B;CACjP,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAAG;CACvJ,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  import FSExtra from "fs-extra";
2
2
  import { clearTransformCache } from "@vxrn/compiler";
3
- import { bundle } from "@vxrn/vite-plugin-metro/rn-commands";
3
+ import { resolveConfig } from "vite";
4
4
  import { loadEnv } from "../../exports/loadEnv.mjs";
5
5
  import { buildNativeBundle } from "../../utils/createNativeDevEngine.mjs";
6
6
 
@@ -10,10 +10,11 @@ async function buildBundle(_argv, ctx, args, bundleImpl = null) {
10
10
  if (typeof root !== "string") {
11
11
  throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);
12
12
  }
13
- const metroBuildBundleFn = await bundle.getBuildBundleFn();
14
- if (metroBuildBundleFn) {
13
+ const viteConfig = await resolveConfig({}, "build", "production");
14
+ if (globalThis["__viteMetroPluginOptions__"]) {
15
15
  console.info("Using @vxrn/vite-plugin-metro to build the bundle.");
16
- await metroBuildBundleFn(_argv, ctx, args, bundleImpl);
16
+ const { bundle } = await import("@vxrn/vite-plugin-metro/rn-commands");
17
+ await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);
17
18
  return;
18
19
  }
19
20
  process.env.IS_VXRN_CLI = "true";
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.js","names":["metroBundle"],"sources":["rn-commands/bundle/buildBundle.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport {\n bundle as metroBundle\n} from \"@vxrn/vite-plugin-metro/rn-commands\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args, bundleImpl = null) {\n const {\n platform,\n // Android is not supported yet.\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n } = args;\n const { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n const metroBuildBundleFn = await metroBundle.getBuildBundleFn();\n if (metroBuildBundleFn) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n await metroBuildBundleFn(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n const nativeEntryFile = ctx.vxrnEntries?.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n const result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n const builtBundle = result.code;\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: \"utf8\" });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });\n console.info(\"Done.\");\n setTimeout(() => {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;AAOA,eAAe,YAAY,OAAO,KAAK,MAAM,aAAa,MAAM;CAC9D,MAAM,EACJ,UAEA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAcE;CACJ,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,MAAM,qBAAqB,MAAMA,OAAY,iBAAiB;CAC9D,IAAI,oBAAoB;EACtB,QAAQ,KAAK,oDAAoD;EACjE,MAAM,mBAAmB,OAAO,KAAK,MAAM,UAAU;EACrD;CACF;CACA,QAAQ,IAAI,cAAc;CAC1B,QAAQ,MAAM,gBAAgB,cAAc,IAAI;CAChD,IAAI,CAAC,KAAK;EACR,QAAQ,IAAI,WAAW;CACzB;CACA,IAAI,YAAY;EACd,oBAAoB;CACtB;CACA,QAAQ,KAAK,qCAAqC,SAAS,IAAI;CAC/D,MAAM,kBAAkB,IAAI,aAAa;CACzC,IAAI,oBAAoB,KAAK,KAAK,OAAO,oBAAoB,UAAU;EACrE,MAAM,IAAI,MAAM,wCAAwC;CAC1D;CACA,MAAM,SAAS,MAAM,kBAAkB;EACrC;EACA;EACA;EACA,WAAW;EAIX,WAAW,QAAQ,IAAI;EACvB;EACA,WAAW,CAAC,CAAC,KAAK;EAClB;CACF,CAAC;CACD,MAAM,cAAc,OAAO;CAC3B,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,QAAQ,eAAe,KAAK,iBAAiB,OAAO,KAAK,EAAE,UAAU,OAAO,CAAC;CAC/E;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAAE,UAAU,eAAe,CAAC;CAC9E,QAAQ,KAAK,OAAO;CACpB,iBAAiB;EACf,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
1
+ {"version":3,"file":"buildBundle.js","names":[],"sources":["rn-commands/bundle/buildBundle.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport { resolveConfig } from \"vite\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args, bundleImpl = null) {\n const {\n platform,\n // Android is not supported yet.\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n } = args;\n const { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n const viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n const { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n const nativeEntryFile = ctx.vxrnEntries?.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n const result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n const builtBundle = result.code;\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: \"utf8\" });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });\n console.info(\"Done.\");\n setTimeout(() => {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;AAKA,eAAe,YAAY,OAAO,KAAK,MAAM,aAAa,MAAM;CAC9D,MAAM,EACJ,UAEA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAcE;CACJ,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,MAAM,aAAa,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY;CAChE,IAAI,WAAW,+BAA+B;EAC5C,QAAQ,KAAK,oDAAoD;EACjE,MAAM,EAAE,WAAW,MAAM,OAAO;EAChC,MAAM,OAAO,iBAAiB,UAAU,CAAC,CAAC,OAAO,KAAK,MAAM,UAAU;EACtE;CACF;CACA,QAAQ,IAAI,cAAc;CAC1B,QAAQ,MAAM,gBAAgB,cAAc,IAAI;CAChD,IAAI,CAAC,KAAK;EACR,QAAQ,IAAI,WAAW;CACzB;CACA,IAAI,YAAY;EACd,oBAAoB;CACtB;CACA,QAAQ,KAAK,qCAAqC,SAAS,IAAI;CAC/D,MAAM,kBAAkB,IAAI,aAAa;CACzC,IAAI,oBAAoB,KAAK,KAAK,OAAO,oBAAoB,UAAU;EACrE,MAAM,IAAI,MAAM,wCAAwC;CAC1D;CACA,MAAM,SAAS,MAAM,kBAAkB;EACrC;EACA;EACA;EACA,WAAW;EAIX,WAAW,QAAQ,IAAI;EACvB;EACA,WAAW,CAAC,CAAC,KAAK;EAClB;CACF,CAAC;CACD,MAAM,cAAc,OAAO;CAC3B,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,QAAQ,eAAe,KAAK,iBAAiB,OAAO,KAAK,EAAE,UAAU,OAAO,CAAC;CAC/E;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAAE,UAAU,eAAe,CAAC;CAC9E,QAAQ,KAAK,OAAO;CACpB,iBAAiB;EACf,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
@@ -1,6 +1,6 @@
1
1
  import FSExtra from "fs-extra";
2
2
  import { clearTransformCache } from "@vxrn/compiler";
3
- import { bundle } from "@vxrn/vite-plugin-metro/rn-commands";
3
+ import { resolveConfig } from "vite";
4
4
  import { loadEnv } from "../../exports/loadEnv.native.js";
5
5
  import { buildNativeBundle } from "../../utils/createNativeDevEngine.native.js";
6
6
 
@@ -12,10 +12,11 @@ async function buildBundle(_argv, ctx, args) {
12
12
  if (typeof root !== "string") {
13
13
  throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);
14
14
  }
15
- var metroBuildBundleFn = await bundle.getBuildBundleFn();
16
- if (metroBuildBundleFn) {
15
+ var viteConfig = await resolveConfig({}, "build", "production");
16
+ if (globalThis["__viteMetroPluginOptions__"]) {
17
17
  console.info("Using @vxrn/vite-plugin-metro to build the bundle.");
18
- await metroBuildBundleFn(_argv, ctx, args, bundleImpl);
18
+ var { bundle } = await import("@vxrn/vite-plugin-metro/rn-commands");
19
+ await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);
19
20
  return;
20
21
  }
21
22
  process.env.IS_VXRN_CLI = "true";
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.native.js","names":["metroBundle"],"sources":["rn-commands/bundle/buildBundle.native.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport { bundle as metroBundle } from \"@vxrn/vite-plugin-metro/rn-commands\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args) {\n var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;\n var _ctx_vxrnEntries;\n var {\n platform,\n // Android is not supported yet.\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n } = (\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n args\n );\n var { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n var metroBuildBundleFn = await metroBundle.getBuildBundleFn();\n if (metroBuildBundleFn) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n await metroBuildBundleFn(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n var nativeEntryFile = (_ctx_vxrnEntries = ctx.vxrnEntries) === null || _ctx_vxrnEntries === void 0 ? void 0 : _ctx_vxrnEntries.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n var result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n var builtBundle = result.code;\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, {\n encoding: \"utf8\"\n });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, {\n encoding: bundleEncoding\n });\n console.info(\"Done.\");\n setTimeout(function() {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;AAKA,eAAe,YAAY,OAAO,KAAK,MAAM;CAC3C,IAAI,aAAa,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAClF,IAAI;CACJ,IAAI,EACF,UAEA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAeA;CAEF,IAAI,EAAE,SAAS;CACf,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,IAAI,qBAAqB,MAAMA,OAAY,iBAAiB;CAC5D,IAAI,oBAAoB;EACtB,QAAQ,KAAK,oDAAoD;EACjE,MAAM,mBAAmB,OAAO,KAAK,MAAM,UAAU;EACrD;CACF;CACA,QAAQ,IAAI,cAAc;CAC1B,QAAQ,MAAM,gBAAgB,cAAc,IAAI;CAChD,IAAI,CAAC,KAAK;EACR,QAAQ,IAAI,WAAW;CACzB;CACA,IAAI,YAAY;EACd,oBAAoB;CACtB;CACA,QAAQ,KAAK,qCAAqC,SAAS,IAAI;CAC/D,IAAI,mBAAmB,mBAAmB,IAAI,iBAAiB,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB;CAC/H,IAAI,oBAAoB,KAAK,KAAK,OAAO,oBAAoB,UAAU;EACrE,MAAM,IAAI,MAAM,wCAAwC;CAC1D;CACA,IAAI,SAAS,MAAM,kBAAkB;EACnC;EACA;EACA;EACA,WAAW;EAIX,WAAW,QAAQ,IAAI;EACvB;EACA,WAAW,CAAC,CAAC,KAAK;EAClB;CACF,CAAC;CACD,IAAI,cAAc,OAAO;CACzB,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,QAAQ,eAAe,KAAK,iBAAiB,OAAO,KAAK,EACvD,UAAU,OACZ,CAAC;CACH;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAChD,UAAU,eACZ,CAAC;CACD,QAAQ,KAAK,OAAO;CACpB,WAAW,WAAW;EACpB,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
1
+ {"version":3,"file":"buildBundle.native.js","names":[],"sources":["rn-commands/bundle/buildBundle.native.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport { resolveConfig } from \"vite\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args) {\n var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;\n var _ctx_vxrnEntries;\n var {\n platform,\n // Android is not supported yet.\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n } = (\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n args\n );\n var { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n var viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n var { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n var nativeEntryFile = (_ctx_vxrnEntries = ctx.vxrnEntries) === null || _ctx_vxrnEntries === void 0 ? void 0 : _ctx_vxrnEntries.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n var result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n var builtBundle = result.code;\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, {\n encoding: \"utf8\"\n });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, {\n encoding: bundleEncoding\n });\n console.info(\"Done.\");\n setTimeout(function() {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;AAKA,eAAe,YAAY,OAAO,KAAK,MAAM;CAC3C,IAAI,aAAa,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAClF,IAAI;CACJ,IAAI,EACF,UAEA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAeA;CAEF,IAAI,EAAE,SAAS;CACf,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,IAAI,aAAa,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY;CAC9D,IAAI,WAAW,+BAA+B;EAC5C,QAAQ,KAAK,oDAAoD;EACjE,IAAI,EAAE,WAAW,MAAM,OAAO;EAC9B,MAAM,OAAO,iBAAiB,UAAU,CAAC,CAAC,OAAO,KAAK,MAAM,UAAU;EACtE;CACF;CACA,QAAQ,IAAI,cAAc;CAC1B,QAAQ,MAAM,gBAAgB,cAAc,IAAI;CAChD,IAAI,CAAC,KAAK;EACR,QAAQ,IAAI,WAAW;CACzB;CACA,IAAI,YAAY;EACd,oBAAoB;CACtB;CACA,QAAQ,KAAK,qCAAqC,SAAS,IAAI;CAC/D,IAAI,mBAAmB,mBAAmB,IAAI,iBAAiB,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB;CAC/H,IAAI,oBAAoB,KAAK,KAAK,OAAO,oBAAoB,UAAU;EACrE,MAAM,IAAI,MAAM,wCAAwC;CAC1D;CACA,IAAI,SAAS,MAAM,kBAAkB;EACnC;EACA;EACA;EACA,WAAW;EAIX,WAAW,QAAQ,IAAI;EACvB;EACA,WAAW,CAAC,CAAC,KAAK;EAClB;CACF,CAAC;CACD,IAAI,cAAc,OAAO;CACzB,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,QAAQ,eAAe,KAAK,iBAAiB,OAAO,KAAK,EACvD,UAAU,OACZ,CAAC;CACH;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAChD,UAAU,eACZ,CAAC;CACD,QAAQ,KAAK,OAAO;CACpB,WAAW,WAAW;EACpB,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
@@ -168,9 +168,9 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
168
168
  nativePackageDedupePlugin(root),
169
169
  cssStubPlugin(),
170
170
  viteImportGlobPlugin({ root }),
171
- vxrnCompilerPlugin(platform, dev, root, sourceMaps),
172
171
  rnCodegenPlugin({ projectRoot: root }),
173
172
  flowStripPlugin(),
173
+ vxrnCompilerPlugin(platform, dev, root, sourceMaps),
174
174
  nativeAnimatedGuardPlugin(),
175
175
  assetPlugin({
176
176
  root,
@@ -197,7 +197,7 @@ function getNativeOutputOptions(prelude, sourcemap, minify) {
197
197
  };
198
198
  }
199
199
  function normalizeNativeCommonJSInterop(code) {
200
- return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
200
+ return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|[\w$]+|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
201
201
  }
202
202
  function blankPreservingLines(match) {
203
203
  return "\n".repeat(match.match(/\n/g)?.length ?? 0);
@@ -363,12 +363,19 @@ try {
363
363
  },
364
364
  onHmrUpdates: async (result) => {
365
365
  await engine?.ensureCurrentBuildFinish();
366
+ if (await rebuildIfRouteGraphChanged()) return;
366
367
  if (result instanceof Error) {
368
+ const { removedFiles, registryId } = virtualEntry.routes;
369
+ const errors = result.errors ?? [];
370
+ if (registryId && errors.length && errors.every((e) => {
371
+ if (e.code !== "UNRESOLVED_IMPORT" || e.id !== registryId || !e.exporter) return false;
372
+ const file = normalizePath(resolve(dirname(e.id), e.exporter));
373
+ return removedFiles.has(file);
374
+ })) return;
367
375
  console.error("[vxrn] HMR error:", result.message);
368
376
  onHmrUpdate?.({ type: "hmr:error" });
369
377
  return;
370
378
  }
371
- if (await rebuildIfRouteGraphChanged()) return;
372
379
  for (const { clientId, update } of result.updates) if (update.type === "Patch" && update.code) {
373
380
  await engine.notifyPayloadDelivered(update.filename);
374
381
  onHmrUpdate?.({
@@ -567,14 +574,16 @@ globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
567
574
  ` : "";
568
575
  const entryCode = () => `
569
576
  ${refreshSetup}
570
- import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
577
+ // retain the namespace so rolldown dev eagerly initializes the RN environment
578
+ // before app modules, even when the renderer also requires this entry.
579
+ import * as ReactNativeEnvironment from 'react-native/setup-env';
571
580
  import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
572
581
  import DevSettings from 'react-native/Libraries/Utilities/DevSettings';
573
582
  ${setupFileImport}
574
583
  ${routeImports}
575
584
  import { createApp } from 'one';
576
585
 
577
- void ReactNativeInitializeCore;
586
+ void ReactNativeEnvironment;
578
587
  globalThis.WebSocket = NativeWebSocket;
579
588
  globalThis.__VXRN_RELOAD_NATIVE_DEV_BUNDLE__ = function(reason) {
580
589
  DevSettings.reload(reason);
@@ -618,13 +627,17 @@ ${routeHmr}
618
627
  const routes = {
619
628
  routeRoot,
620
629
  files: /* @__PURE__ */ new Set(),
630
+ removedFiles: /* @__PURE__ */ new Set(),
621
631
  isRouteFile,
622
632
  scanFiles,
623
633
  updateFiles(files) {
634
+ for (const file of routes.files) if (!files.has(file)) routes.removedFiles.add(file);
635
+ for (const file of files) routes.removedFiles.delete(file);
624
636
  routes.files = files;
625
637
  if (!useDynamicRouteRegistry) return;
626
638
  mkdirSync(dirname(registryPath), { recursive: true });
627
639
  const registryDir = realpathSync(dirname(registryPath));
640
+ routes.registryId = join(registryDir, basename(registryPath));
628
641
  const source = `export const routes = {
629
642
  ${[...files].sort().map((file) => {
630
643
  const routeKey = `/${normalizePath(relative(root, file))}`;
@@ -944,7 +957,7 @@ function reactNativeDedupePlugin(root) {
944
957
  let reactNativeRoot;
945
958
  return {
946
959
  name: "vxrn:react-native-dedupe",
947
- async resolveId(source, importer) {
960
+ async resolveId(source, importer, options) {
948
961
  if (source !== "react-native" && !source.startsWith("react-native/")) return;
949
962
  if (reactNativeRoot === void 0) try {
950
963
  reactNativeRoot = realpathSync(dirname(resolvePath("react-native/package.json", root)));
@@ -952,8 +965,18 @@ function reactNativeDedupePlugin(root) {
952
965
  reactNativeRoot = null;
953
966
  }
954
967
  if (!reactNativeRoot) return;
968
+ const exported = await this.resolve(source, join(root, "package.json"), {
969
+ skipSelf: true,
970
+ kind: options.kind
971
+ });
972
+ if (exported) return exported;
955
973
  const subpath = source === "react-native" ? "index.js" : source.slice(13);
956
- return this.resolve(normalizePath(resolve(reactNativeRoot, subpath)), importer, { skipSelf: true });
974
+ const unified = await this.resolve(normalizePath(resolve(reactNativeRoot, subpath)), importer, {
975
+ skipSelf: true,
976
+ kind: options.kind
977
+ });
978
+ if (unified) return unified;
979
+ this.error(`[vxrn] '${source}' is missing from the app's react-native (${reactNativeRoot}), imported by '${importer}'. refusing the nested copy so the native runtime stays a singleton.`);
957
980
  }
958
981
  };
959
982
  }