peachsim 0.1.755 → 0.1.757
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/cli/app-config.ts +4 -29
- package/cli/commands/telemetry.ts +5 -2
- package/cli/privacy.ts +10 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +88 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +47 -36
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +13 -5
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +2551 -2220
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +914 -584
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +4 -4
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +104 -69
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1 -1
- package/dist-lib/vite.cjs +10 -4
- package/package.json +1 -1
- package/src/config.ts +92 -0
- package/src/configured-bundle-producer.ts +110 -0
- package/src/host/replacement-module-handler.ts +8 -2
- package/src/metro-plugin.ts +27 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.757 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.757 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.757 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.757 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -371,6 +371,7 @@ function compileReplacementModule(input) {
|
|
|
371
371
|
return code.slice(token.start + 1, token.end - 1);
|
|
372
372
|
};
|
|
373
373
|
const bridgeNames = /* @__PURE__ */ new Map();
|
|
374
|
+
const bareSpecifiers = /* @__PURE__ */ new Set();
|
|
374
375
|
const declarations = [];
|
|
375
376
|
let needsDefaultInterop = false;
|
|
376
377
|
const bridgeFor = (specifier) => {
|
|
@@ -471,6 +472,7 @@ function compileReplacementModule(input) {
|
|
|
471
472
|
if (specifier !== "react" && specifier !== "react-native" && !JSX_RUNTIME_SPECIFIERS.has(specifier) && !isPeachKitSpecifier(specifier) && !input.runtimePackages.has(specifier)) {
|
|
472
473
|
throw unsupportedSpecifier(specifier);
|
|
473
474
|
}
|
|
475
|
+
bareSpecifiers.add(specifier);
|
|
474
476
|
const bridge = bindings.length > 0 ? bridgeFor(specifier) : null;
|
|
475
477
|
const replacement = bindings.map((binding) => {
|
|
476
478
|
if (binding.imported === null) return `const ${binding.local} = ${bridge};`;
|
|
@@ -493,6 +495,7 @@ function compileReplacementModule(input) {
|
|
|
493
495
|
const preamble = declarations.join(" ");
|
|
494
496
|
return {
|
|
495
497
|
code: preamble ? `${preamble} ${out}` : out,
|
|
498
|
+
bareSpecifiers: [...bareSpecifiers],
|
|
496
499
|
sourceMap: { ...sourceMap, sourcesContent: [input.source] }
|
|
497
500
|
};
|
|
498
501
|
}
|
|
@@ -524,7 +527,7 @@ function sendJavaScript(req, res, source) {
|
|
|
524
527
|
});
|
|
525
528
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
526
529
|
}
|
|
527
|
-
function
|
|
530
|
+
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
528
531
|
const base = import_node_path3.default.resolve(import_node_path3.default.dirname(fromFile), specifier);
|
|
529
532
|
const candidates = [
|
|
530
533
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
@@ -629,7 +632,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
629
632
|
// so the token, cache key and runtime packages carry over.
|
|
630
633
|
localModuleUrl: (specifier) => {
|
|
631
634
|
const local = new URL(url.href);
|
|
632
|
-
local.searchParams.set(
|
|
635
|
+
local.searchParams.set(
|
|
636
|
+
"path",
|
|
637
|
+
resolveReplacementModuleFile(targetPath, specifier)
|
|
638
|
+
);
|
|
633
639
|
return `${local.pathname}${local.search}`;
|
|
634
640
|
}
|
|
635
641
|
});
|
|
@@ -654,7 +660,7 @@ var import_fs = __toESM(require("fs"), 1);
|
|
|
654
660
|
var import_path = __toESM(require("path"), 1);
|
|
655
661
|
var import_url = require("url");
|
|
656
662
|
|
|
657
|
-
// ../contrast-runtime-delivery/src/
|
|
663
|
+
// ../contrast-runtime-delivery/src/version.ts
|
|
658
664
|
function isValidRuntimeVersion(value) {
|
|
659
665
|
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
660
666
|
}
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// import { defineConfig } from 'peachsim/config'
|
|
5
5
|
// export default defineConfig({ modules: { ... }, env: { ... } })
|
|
6
6
|
|
|
7
|
+
import { isValidRuntimeVersion } from '@contrast/runtime-delivery/version'
|
|
8
|
+
import { isRecord } from './is-record'
|
|
7
9
|
import type { RevenueCatTestStoreConfig } from '@peach/compat/revenuecat-test-store'
|
|
8
10
|
|
|
9
11
|
export type ModuleResolution =
|
|
@@ -54,6 +56,96 @@ export interface PeachConfig<Settings extends Record<string, any> = Record<strin
|
|
|
54
56
|
|
|
55
57
|
export const PEACH_CONFIG_QUERY_PARAM = 'peachConfig'
|
|
56
58
|
|
|
59
|
+
export function collectConfiguredFileModules(config?: PeachConfig): string[] {
|
|
60
|
+
return [
|
|
61
|
+
...new Set(
|
|
62
|
+
['modules', 'turboModules', 'nativeModules', 'nativeViews'].flatMap((key) => {
|
|
63
|
+
const entries: unknown = config && Reflect.get(config, key)
|
|
64
|
+
if (!isRecord(entries)) return []
|
|
65
|
+
return Object.values(entries).flatMap((entry) =>
|
|
66
|
+
isRecord(entry) && typeof entry.file === 'string' ? [entry.file] : [],
|
|
67
|
+
)
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isPeachConfig(value: unknown): value is PeachConfig {
|
|
74
|
+
if (!isRecord(value)) return false
|
|
75
|
+
return (
|
|
76
|
+
(value.runtimeVersion === undefined ||
|
|
77
|
+
(typeof value.runtimeVersion === 'string' &&
|
|
78
|
+
value.runtimeVersion === value.runtimeVersion.trim() &&
|
|
79
|
+
isValidRuntimeVersion(value.runtimeVersion))) &&
|
|
80
|
+
[
|
|
81
|
+
'modules',
|
|
82
|
+
'turboModules',
|
|
83
|
+
'nativeModules',
|
|
84
|
+
'nativeViews',
|
|
85
|
+
'env',
|
|
86
|
+
'network',
|
|
87
|
+
'settings',
|
|
88
|
+
'initialState',
|
|
89
|
+
].every((key) => value[key] === undefined || isRecord(value[key]))
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface PeachBundleConfig {
|
|
94
|
+
config: PeachConfig
|
|
95
|
+
runtimePackages: string[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const BUNDLE_CONFIG_PREFIX = 'globalThis.__peachBundleConfig='
|
|
99
|
+
export const PEACH_CONFIGURED_FILES_HOOK = '__peachInstallConfiguredFiles'
|
|
100
|
+
|
|
101
|
+
export function readPeachBundleConfig(value: unknown): PeachBundleConfig | null {
|
|
102
|
+
if (value === undefined || value === null) return null
|
|
103
|
+
if (
|
|
104
|
+
!isRecord(value) ||
|
|
105
|
+
!isPeachConfig(value.config) ||
|
|
106
|
+
!Array.isArray(value.runtimePackages) ||
|
|
107
|
+
!value.runtimePackages.every((name) => typeof name === 'string')
|
|
108
|
+
) {
|
|
109
|
+
throw new Error('configured bundle metadata is malformed')
|
|
110
|
+
}
|
|
111
|
+
return { config: value.config, runtimePackages: [...value.runtimePackages] }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function readPeachBundleConfigFooter(source: string): PeachBundleConfig | null {
|
|
115
|
+
const start = source.lastIndexOf('\n' + BUNDLE_CONFIG_PREFIX)
|
|
116
|
+
if (start < 0) return null
|
|
117
|
+
const end = source.indexOf('\n', start + 1)
|
|
118
|
+
const line = source.slice(start + 1, end < 0 ? undefined : end)
|
|
119
|
+
if (!line.endsWith(';')) throw new Error('configured bundle footer is truncated')
|
|
120
|
+
const result = readPeachBundleConfig(
|
|
121
|
+
JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1)),
|
|
122
|
+
)
|
|
123
|
+
if (!result) throw new Error('configured bundle footer is empty')
|
|
124
|
+
return result
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function createPeachBundleConfigFooter(config: PeachBundleConfig): string {
|
|
128
|
+
const json = JSON.stringify(config)
|
|
129
|
+
.replace(/\u2028/g, '\\u2028')
|
|
130
|
+
.replace(/\u2029/g, '\\u2029')
|
|
131
|
+
.replace(/<\//g, '<\\/')
|
|
132
|
+
return '\n' + BUNDLE_CONFIG_PREFIX + json + ';'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function detachPeachBundleConfigFooter(source: string): {
|
|
136
|
+
source: string
|
|
137
|
+
configuredBundle: PeachBundleConfig | null
|
|
138
|
+
} {
|
|
139
|
+
const configuredBundle = readPeachBundleConfigFooter(source)
|
|
140
|
+
if (!configuredBundle) return { source, configuredBundle }
|
|
141
|
+
const start = source.lastIndexOf('\n' + BUNDLE_CONFIG_PREFIX)
|
|
142
|
+
const end = source.indexOf('\n', start + 1)
|
|
143
|
+
return {
|
|
144
|
+
source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
|
|
145
|
+
configuredBundle,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
57
149
|
export function defineConfig<Settings extends Record<string, any> = Record<string, any>>(
|
|
58
150
|
config: PeachConfig<Settings>,
|
|
59
151
|
): PeachConfig<Settings> {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// packages the app's configured native files, never the guest's module factories.
|
|
2
|
+
// the generated prefix runs as ordinary bundle code in browser and workerd tenants.
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { transform } from 'sucrase'
|
|
6
|
+
import { minify } from 'terser'
|
|
7
|
+
import { compileReplacementModule } from '../../contrast-bundler/src/replacementModule'
|
|
8
|
+
import {
|
|
9
|
+
collectConfiguredFileModules,
|
|
10
|
+
createPeachBundleConfigFooter,
|
|
11
|
+
PEACH_CONFIGURED_FILES_HOOK,
|
|
12
|
+
isPeachConfig,
|
|
13
|
+
} from './config'
|
|
14
|
+
import { resolveReplacementModuleFile } from './host/replacement-module-handler'
|
|
15
|
+
import type { PeachConfig } from './config'
|
|
16
|
+
|
|
17
|
+
export async function produceConfiguredBundle(
|
|
18
|
+
source: string,
|
|
19
|
+
config: PeachConfig | undefined,
|
|
20
|
+
runtimePackages: ReadonlySet<string>,
|
|
21
|
+
): Promise<string> {
|
|
22
|
+
if (!config) return source
|
|
23
|
+
// functions cannot cross JSON. executable native bindings belong in file entries.
|
|
24
|
+
const json = JSON.stringify(config, (_key, value: unknown) => {
|
|
25
|
+
if (
|
|
26
|
+
typeof value === 'function' ||
|
|
27
|
+
typeof value === 'bigint' ||
|
|
28
|
+
typeof value === 'symbol'
|
|
29
|
+
)
|
|
30
|
+
throw new Error(
|
|
31
|
+
'configured bundle values must be JSON; native functions must use file entries',
|
|
32
|
+
)
|
|
33
|
+
return value
|
|
34
|
+
})
|
|
35
|
+
const packagedConfig: unknown = JSON.parse(json)
|
|
36
|
+
if (!isPeachConfig(packagedConfig))
|
|
37
|
+
throw new Error('configured bundle config is malformed')
|
|
38
|
+
const files = new Map<string, string>()
|
|
39
|
+
const neededPackages = new Set<string>()
|
|
40
|
+
const factories: string[] = []
|
|
41
|
+
const visit = (filePath: string): string => {
|
|
42
|
+
const real = fs.realpathSync(filePath)
|
|
43
|
+
const previous = files.get(real)
|
|
44
|
+
if (previous !== undefined) return previous
|
|
45
|
+
const id = 'peach-config-file:' + files.size
|
|
46
|
+
files.set(real, id)
|
|
47
|
+
const compiled = compileReplacementModule({
|
|
48
|
+
filePath: real,
|
|
49
|
+
source: fs.readFileSync(real, 'utf8'),
|
|
50
|
+
runtimePackages,
|
|
51
|
+
localModuleUrl: (specifier) => visit(resolveReplacementModuleFile(real, specifier)),
|
|
52
|
+
})
|
|
53
|
+
const commonJs = transform(compiled.code, { transforms: ['imports'] }).code
|
|
54
|
+
for (const specifier of compiled.bareSpecifiers) neededPackages.add(specifier)
|
|
55
|
+
factories.push(
|
|
56
|
+
JSON.stringify(id) + ':function(require,module,exports){' + commonJs + '\n}',
|
|
57
|
+
)
|
|
58
|
+
return id
|
|
59
|
+
}
|
|
60
|
+
for (const key of ['modules', 'turboModules', 'nativeModules', 'nativeViews']) {
|
|
61
|
+
const entries: unknown = Reflect.get(packagedConfig, key)
|
|
62
|
+
if (!entries || typeof entries !== 'object') continue
|
|
63
|
+
for (const resolution of Object.values(entries)) {
|
|
64
|
+
if (
|
|
65
|
+
resolution &&
|
|
66
|
+
typeof resolution === 'object' &&
|
|
67
|
+
'file' in resolution &&
|
|
68
|
+
typeof resolution.file === 'string'
|
|
69
|
+
) {
|
|
70
|
+
resolution.file = visit(path.resolve(resolution.file))
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const roots = collectConfiguredFileModules(packagedConfig)
|
|
75
|
+
let prefix = ''
|
|
76
|
+
if (roots.length > 0) {
|
|
77
|
+
const code =
|
|
78
|
+
'(function(){const factories={' +
|
|
79
|
+
factories.join(',') +
|
|
80
|
+
'};const cache=Object.create(null);function require(id){if(cache[id])return cache[id].exports;' +
|
|
81
|
+
'const factory=factories[id];if(!factory)throw new Error("missing configured file "+id);' +
|
|
82
|
+
'const module={exports:{}};cache[id]=module;try{factory(require,module,module.exports);' +
|
|
83
|
+
'return module.exports;}catch(error){delete cache[id];throw error;}}' +
|
|
84
|
+
'const loaded=Object.create(null);for(const id of ' +
|
|
85
|
+
JSON.stringify(roots) +
|
|
86
|
+
')loaded[id]=require(id);const install=globalThis[' +
|
|
87
|
+
JSON.stringify(PEACH_CONFIGURED_FILES_HOOK) +
|
|
88
|
+
'];if(typeof install!=="function")throw new Error("runtime cannot install configured bundle files");' +
|
|
89
|
+
'install(loaded);})();'
|
|
90
|
+
const compact = await minify(code, {
|
|
91
|
+
compress: false,
|
|
92
|
+
mangle: false,
|
|
93
|
+
format: { comments: false, beautify: false },
|
|
94
|
+
})
|
|
95
|
+
if (!compact.code || /[\n\r]/.test(compact.code))
|
|
96
|
+
throw new Error('configured bundle prefix must preserve the guest source lines')
|
|
97
|
+
prefix = compact.code
|
|
98
|
+
}
|
|
99
|
+
const footer = createPeachBundleConfigFooter({
|
|
100
|
+
config: packagedConfig,
|
|
101
|
+
runtimePackages: [...neededPackages].sort(),
|
|
102
|
+
})
|
|
103
|
+
const identityStart = source.lastIndexOf('\nglobalThis.__sootsimModulePaths=')
|
|
104
|
+
return (
|
|
105
|
+
prefix +
|
|
106
|
+
(identityStart < 0
|
|
107
|
+
? source + footer
|
|
108
|
+
: source.slice(0, identityStart) + footer + source.slice(identityStart))
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -37,7 +37,10 @@ function sendJavaScript(req: IncomingMessage, res: ServerResponse, source: strin
|
|
|
37
37
|
// a relative import resolves the way the app's own files do: the exact path
|
|
38
38
|
// when it names an allowed extension, else each extension in turn, else the
|
|
39
39
|
// directory's index file.
|
|
40
|
-
function
|
|
40
|
+
export function resolveReplacementModuleFile(
|
|
41
|
+
fromFile: string,
|
|
42
|
+
specifier: string,
|
|
43
|
+
): string {
|
|
41
44
|
const base = path.resolve(path.dirname(fromFile), specifier)
|
|
42
45
|
const candidates = [
|
|
43
46
|
...(REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
@@ -170,7 +173,10 @@ export async function handleReplacementModuleRequest(
|
|
|
170
173
|
// so the token, cache key and runtime packages carry over.
|
|
171
174
|
localModuleUrl: (specifier) => {
|
|
172
175
|
const local = new URL(url.href)
|
|
173
|
-
local.searchParams.set(
|
|
176
|
+
local.searchParams.set(
|
|
177
|
+
'path',
|
|
178
|
+
resolveReplacementModuleFile(targetPath, specifier),
|
|
179
|
+
)
|
|
174
180
|
return `${local.pathname}${local.search}`
|
|
175
181
|
},
|
|
176
182
|
})
|
package/src/metro-plugin.ts
CHANGED
|
@@ -12,6 +12,7 @@ import fs from 'fs'
|
|
|
12
12
|
import { createRequire } from 'module'
|
|
13
13
|
import { randomUUID } from 'node:crypto'
|
|
14
14
|
import path from 'path'
|
|
15
|
+
import { resolveAppProject } from '../cli/app-project'
|
|
15
16
|
import { tagRnxBundleForPlugin } from './dev-server-open'
|
|
16
17
|
import {
|
|
17
18
|
handleReplacementModuleRequest,
|
|
@@ -282,6 +283,32 @@ export function withRNX<T extends Record<string, unknown>>(config: T): T {
|
|
|
282
283
|
code: insertNativeFirebaseFooter(annotated.code, firebase),
|
|
283
284
|
}
|
|
284
285
|
}
|
|
286
|
+
const project = resolveAppProject(cfgProjectRoot)
|
|
287
|
+
const appConfig = project?.configPath
|
|
288
|
+
? await (await import('../cli/app-config')).loadRNXAppConfig(project)
|
|
289
|
+
: undefined
|
|
290
|
+
if (appConfig) {
|
|
291
|
+
const { produceConfiguredBundle } = await import('./configured-bundle-producer')
|
|
292
|
+
const runtimePackages = new Set<string>()
|
|
293
|
+
for (const module of graph.dependencies?.values() ?? []) {
|
|
294
|
+
for (const [key, dependency] of module.dependencies ?? []) {
|
|
295
|
+
const specifier = dependency.data?.name ?? key
|
|
296
|
+
if (!specifier.startsWith('.') && !specifier.startsWith('/'))
|
|
297
|
+
runtimePackages.add(specifier)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
annotated =
|
|
301
|
+
typeof annotated === 'string'
|
|
302
|
+
? await produceConfiguredBundle(annotated, appConfig, runtimePackages)
|
|
303
|
+
: {
|
|
304
|
+
...annotated,
|
|
305
|
+
code: await produceConfiguredBundle(
|
|
306
|
+
annotated.code,
|
|
307
|
+
appConfig,
|
|
308
|
+
runtimePackages,
|
|
309
|
+
),
|
|
310
|
+
}
|
|
311
|
+
}
|
|
285
312
|
return annotated
|
|
286
313
|
},
|
|
287
314
|
},
|