@wavemaker/rn-codegen 11.15.5-rc.647813 → 11.15.5-rc.647878
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/command.js +94 -232
- package/command.js.map +1 -1
- package/index.js +131 -125
- package/index.js.map +1 -1
- package/npm-shrinkwrap.json +567 -548
- package/package-lock.json +567 -548
- package/package.json +14 -10
- package/scripts/check-deps-compat.js +579 -0
- package/src/app.generator.js +457 -137
- package/src/app.generator.js.map +1 -1
- package/src/increment-builder.js +2 -1
- package/src/increment-builder.js.map +1 -1
- package/src/pipeline/build-common.js +63 -0
- package/src/pipeline/build-common.js.map +1 -0
- package/src/pipeline/build-pipeline.js +169 -0
- package/src/pipeline/build-pipeline.js.map +1 -0
- package/src/pipeline/generation-store.js +309 -0
- package/src/pipeline/generation-store.js.map +1 -0
- package/src/pipeline/shared-node-modules.js +934 -0
- package/src/pipeline/shared-node-modules.js.map +1 -0
- package/src/pipeline/web-preview-templates.js +80 -0
- package/src/pipeline/web-preview-templates.js.map +1 -0
- package/src/pipeline/working-set.js +103 -0
- package/src/pipeline/working-set.js.map +1 -0
- package/src/profiles/legacy-web-preview.profile.js +15 -0
- package/src/profiles/legacy-web-preview.profile.js.map +1 -0
- package/src/project.service.js +14 -0
- package/src/project.service.js.map +1 -1
- package/src/templates/app.template +74 -2
- package/src/templates/babel.config.js.template +3 -6
- package/src/templates/bootstrap.template +12 -1
- package/src/templates/component/component.template +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/dist/android/style.css +23 -5
- package/src/templates/foundation-theme/dist/android/style.js +200 -59
- package/src/templates/foundation-theme/dist/android/tokens.js +21 -3
- package/src/templates/foundation-theme/dist/ios/style.css +23 -5
- package/src/templates/foundation-theme/dist/ios/style.js +200 -59
- package/src/templates/foundation-theme/dist/ios/tokens.js +21 -3
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/package.web.json +17 -7
- package/src/templates/page-stub.template +27 -0
- package/src/templates/project/.npmrc +1 -0
- package/src/templates/project/app.json +2 -1
- package/src/templates/project/esbuild/esbuild.script.js +57 -8
- package/src/templates/project/metro/container-limits.js +195 -0
- package/src/templates/project/metro/metro.script.js +850 -0
- package/src/templates/project/metro/module-path.js +237 -0
- package/src/templates/project/metro/split.serializer.js +184 -0
- package/src/templates/project/metro/split.static.js +633 -0
- package/src/templates/project/metro/stable-module-ids.js +54 -0
- package/src/templates/project/metro/vendor-cache.js +475 -0
- package/src/templates/project/metro/wm-boundary.js +150 -0
- package/src/templates/project/metro/wm-crawl-override.js +161 -0
- package/src/templates/project/metro/wm-fastbuild.js +196 -0
- package/src/templates/project/metro/wm-live-reload.js +482 -0
- package/src/templates/project/metro/wm-metro-adapter.js +25 -0
- package/src/templates/project/metro/wm-prebuilt.js +31 -0
- package/src/templates/project/metro.config.js +13 -2
- package/src/templates/project/package-lock.json +15308 -0
- package/src/templates/project/package.json +14 -6
- package/src/templates/project/patch-utils.js +331 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/build.gradle +15 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshModule.kt +21 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshView.kt +221 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/expo-module.config.json +16 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefresh.podspec +24 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift +17 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift +92 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/package.json +15 -0
- package/src/templates/project/scripts/wm-babel.transform.plugin.js +11 -1
- package/src/templates/project/wavepulse/rn2css.json +5 -0
- package/src/theme/app-override-css.generator.js +10 -4
- package/src/theme/app-override-css.generator.js.map +1 -1
- package/src/theme/components/input/epoch/datetime.styledef.js +5 -0
- package/src/theme/components/input/epoch/datetime.styledef.js.map +1 -1
- package/src/theme/components/input/number.styledef.js +10 -0
- package/src/theme/components/input/number.styledef.js.map +1 -1
- package/src/theme/rn-stylesheet.transpiler.js +30 -6
- package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
- package/src/theme/theme.service.js +3 -2
- package/src/theme/theme.service.js.map +1 -1
- package/src/transpile/bind.ex.transformer.js +55 -37
- package/src/transpile/bind.ex.transformer.js.map +1 -1
- package/src/transpile/components/container/wizard/wizardstep.transformer.js +10 -2
- package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-field.transformer.js +36 -1
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
- package/src/transpile/components/page/page.transformer.js +11 -1
- package/src/transpile/components/page/page.transformer.js.map +1 -1
- package/src/transpile/property/property-parser.js +7 -1
- package/src/transpile/property/property-parser.js.map +1 -1
- package/src/transpile/style.transformer.js +1 -0
- package/src/transpile/style.transformer.js.map +1 -1
- package/src/transpile/transpile.js +10 -1
- package/src/transpile/transpile.js.map +1 -1
- package/src/utils.js +8 -1
- package/src/utils.js.map +1 -1
- package/src/variables/variable.transformer.js +7 -7
- package/src/variables/variable.transformer.js.map +1 -1
- package/src/wm-namespace.js +14 -0
- package/src/wm-namespace.js.map +1 -0
- package/test/pipeline/build-leftovers.test.js +172 -0
- package/test/pipeline/build-leftovers.test.js.map +1 -0
- package/test/pipeline/chmod-tree.test.js +54 -0
- package/test/pipeline/chmod-tree.test.js.map +1 -0
- package/test/pipeline/crawl-override.test.js +53 -0
- package/test/pipeline/crawl-override.test.js.map +1 -0
- package/test/pipeline/live-reload-pacing.test.js +76 -0
- package/test/pipeline/live-reload-pacing.test.js.map +1 -0
- package/test/pipeline/npm-install-retry.test.js +57 -0
- package/test/pipeline/npm-install-retry.test.js.map +1 -0
- package/test/pipeline/repair-vendor-packages.test.js +134 -0
- package/test/pipeline/repair-vendor-packages.test.js.map +1 -0
- package/test/pipeline/web-preview-files.test.js +48 -0
- package/test/pipeline/web-preview-files.test.js.map +1 -0
- package/web-preview.js +155 -0
- package/web-preview.js.map +1 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const cacache = require('cacache');
|
|
7
|
+
const { topLevelPackageName, normalizeKey, normalizeWmxKey, IS_NODE_MODULE, IS_WMX_MODULE, withLock } = require('./module-path');
|
|
8
|
+
|
|
9
|
+
// Hashes the split-bundle source files so any logic change auto-invalidates stale caches.
|
|
10
|
+
const MODULE_ID_SCHEME_VERSION = (() => {
|
|
11
|
+
try {
|
|
12
|
+
const h = crypto.createHash('md5');
|
|
13
|
+
/* Every file here can change what a chunk CONTAINS, so a change to any of them must invalidate
|
|
14
|
+
cached chunks. wm-boundary.js and wm-crawl-override.js decide which modules reach the graph at
|
|
15
|
+
all, and wm-fastbuild.js emits chunk bytes directly — leaving them out let chunks built under
|
|
16
|
+
different rules share one cache key. wm-live-reload.js is deliberately absent: it is a client
|
|
17
|
+
script injected into index.html and never affects chunk contents, so including it would bust
|
|
18
|
+
every cache for a cosmetic edit. */
|
|
19
|
+
for (const f of ['vendor-cache.js', 'split.serializer.js', 'stable-module-ids.js', 'split.static.js', 'module-path.js', 'wm-metro-adapter.js', 'wm-boundary.js', 'wm-crawl-override.js', 'wm-prebuilt.js', 'wm-fastbuild.js']) {
|
|
20
|
+
const p = path.join(__dirname, f);
|
|
21
|
+
if (fs.existsSync(p)) {
|
|
22
|
+
h.update(f);
|
|
23
|
+
h.update(fs.readFileSync(p));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return h.digest('hex').slice(0, 12);
|
|
27
|
+
} catch {
|
|
28
|
+
return 'scheme-fallback';
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
const PROJECT_ROOT = path.resolve(__dirname, '..');
|
|
33
|
+
|
|
34
|
+
// command.ts writes <projectRoot>/.wm-vendor-base.json from the rnApp's package-lock.json — the vendor package set + a content hash, shareable across every project on the same rnApp version.
|
|
35
|
+
const BASE_MANIFEST_FILE = '.wm-vendor-base.json';
|
|
36
|
+
let _baseManifest;
|
|
37
|
+
|
|
38
|
+
function loadBaseManifest(projectRoot = PROJECT_ROOT) {
|
|
39
|
+
if (_baseManifest && _baseManifest.projectRoot === projectRoot) {
|
|
40
|
+
return _baseManifest.value;
|
|
41
|
+
}
|
|
42
|
+
let value = null;
|
|
43
|
+
try {
|
|
44
|
+
const p = path.join(projectRoot, BASE_MANIFEST_FILE);
|
|
45
|
+
if (fs.existsSync(p)) {
|
|
46
|
+
const json = fs.readJSONSync(p);
|
|
47
|
+
if (Array.isArray(json.packages) && json.packages.length) {
|
|
48
|
+
value = { packages: new Set(json.packages), hash: json.hash || '' };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
value = null;
|
|
53
|
+
}
|
|
54
|
+
_baseManifest = { projectRoot, value };
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Without a manifest the build falls back to exact mode (vendor = every node_module).
|
|
59
|
+
function baseModeEnabled(projectRoot = PROJECT_ROOT) {
|
|
60
|
+
return loadBaseManifest(projectRoot) != null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function extrasSplitEnabled() {
|
|
64
|
+
return baseModeEnabled();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isVendorPkgName(name) {
|
|
68
|
+
const base = loadBaseManifest();
|
|
69
|
+
return base != null && base.packages.has(name);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isBaselineModule(filePath) {
|
|
73
|
+
if (isWmxModule(filePath)) return false;
|
|
74
|
+
const name = topLevelPackageName(filePath);
|
|
75
|
+
return name != null && isVendorPkgName(name);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isWmxModule(filePath) {
|
|
79
|
+
return IS_WMX_MODULE.test(filePath);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isExtraModule(filePath) {
|
|
83
|
+
return IS_NODE_MODULE.test(filePath) && baseModeEnabled() && !isBaselineModule(filePath) && !isWmxModule(filePath);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isProjectSourceModule(filePath) {
|
|
87
|
+
return !IS_NODE_MODULE.test(filePath) && !isWmxModule(filePath);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// A module Metro synthesises rather than reads from disk (e.g. '\0shim:react-native-web/...').
|
|
91
|
+
function isVirtualModule(filePath) {
|
|
92
|
+
if (filePath.charCodeAt(0) === 0) return true;
|
|
93
|
+
try { return !fs.existsSync(filePath); } catch { return true; }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// The packages that SEED the vendor chunk: the rn-app baseline (or every node_module when baseline
|
|
97
|
+
// mode is off).
|
|
98
|
+
function isVendorSeed(filePath) {
|
|
99
|
+
return IS_NODE_MODULE.test(filePath) && !isWmxModule(filePath)
|
|
100
|
+
&& (!baseModeEnabled() || isBaselineModule(filePath));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Library code rather than the project's own: node_modules (except wmx components) plus Metro's
|
|
104
|
+
// virtual modules ('\0shim:react-native-web/...'), which are not under node_modules.
|
|
105
|
+
function isLibraryModule(filePath) {
|
|
106
|
+
return IS_NODE_MODULE.test(filePath) ? !isWmxModule(filePath) : isVirtualModule(filePath);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Chunks form strict layers, decided from the dependency graph rather than from package names:
|
|
110
|
+
// vendor -> vendor only (shared across projects, so it may know nothing else)
|
|
111
|
+
// extras -> vendor + extras (this project's extra packages)
|
|
112
|
+
// user -> anything
|
|
113
|
+
// Deciding by package name alone broke both rules — measured on a real preview: vendor had 71 edges
|
|
114
|
+
// into extras (baseline packages importing packages outside the base manifest) and 13 into user (the
|
|
115
|
+
// react-native-web shims). A cached chunk requiring an id that lives in a later layer is how
|
|
116
|
+
// "Requiring unknown module" is thrown.
|
|
117
|
+
// 1. A library module that transitively reaches project code or wmx cannot sit in vendor or extras
|
|
118
|
+
// without breaking the rule, so it (and every library module depending on it) goes to user.
|
|
119
|
+
// 2. vendor = closure of the baseline seed over the remaining library modules. Closed by
|
|
120
|
+
// construction: a dependency of an untainted module is itself untainted library code.
|
|
121
|
+
// 3. extras = every other untainted library module; its dependencies are in vendor or extras.
|
|
122
|
+
// With the extras split off, (3) lands in user, which is still a valid layering.
|
|
123
|
+
function computeChunkLayers(graph) {
|
|
124
|
+
const dependents = new Map();
|
|
125
|
+
const queue = [];
|
|
126
|
+
for (const m of graph.dependencies.values()) {
|
|
127
|
+
for (const d of m.dependencies.values()) {
|
|
128
|
+
const p = d.absolutePath;
|
|
129
|
+
if (!p || !graph.dependencies.has(p)) continue;
|
|
130
|
+
if (!dependents.has(p)) dependents.set(p, []);
|
|
131
|
+
dependents.get(p).push(m.path);
|
|
132
|
+
}
|
|
133
|
+
if (!isLibraryModule(m.path)) queue.push(m.path);
|
|
134
|
+
}
|
|
135
|
+
const tainted = new Set();
|
|
136
|
+
while (queue.length) {
|
|
137
|
+
for (const parent of dependents.get(queue.pop()) || []) {
|
|
138
|
+
if (tainted.has(parent) || !isLibraryModule(parent)) continue;
|
|
139
|
+
tainted.add(parent);
|
|
140
|
+
queue.push(parent);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const vendor = new Set();
|
|
145
|
+
for (const m of graph.dependencies.values()) {
|
|
146
|
+
if (isVendorSeed(m.path) && !tainted.has(m.path)) { vendor.add(m.path); queue.push(m); }
|
|
147
|
+
}
|
|
148
|
+
while (queue.length) {
|
|
149
|
+
for (const d of queue.pop().dependencies.values()) {
|
|
150
|
+
const p = d.absolutePath;
|
|
151
|
+
if (!p || vendor.has(p) || tainted.has(p) || !isLibraryModule(p)) continue;
|
|
152
|
+
const target = graph.dependencies.get(p);
|
|
153
|
+
if (!target) continue;
|
|
154
|
+
vendor.add(p);
|
|
155
|
+
queue.push(target);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const extras = new Set();
|
|
160
|
+
if (extrasSplitEnabled()) {
|
|
161
|
+
for (const m of graph.dependencies.values()) {
|
|
162
|
+
if (isLibraryModule(m.path) && !vendor.has(m.path) && !tainted.has(m.path)) extras.add(m.path);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { vendor, extras, tainted };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function computeReachableSetHash(modulePaths, isMember) {
|
|
169
|
+
const keys = [];
|
|
170
|
+
for (const p of modulePaths) {
|
|
171
|
+
if (isMember(p)) keys.push(normalizeKey(p));
|
|
172
|
+
}
|
|
173
|
+
if (!keys.length) return '';
|
|
174
|
+
keys.sort();
|
|
175
|
+
return crypto.createHash('md5').update(keys.join('\n')).digest('hex');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function computeVendorSetHash(modulePaths) {
|
|
179
|
+
return computeReachableSetHash(modulePaths, isBaselineModule);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function computeExtrasSetHash(modulePaths) {
|
|
183
|
+
return computeReachableSetHash(modulePaths, isExtraModule);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function computeWmxContentHash(modulePaths) {
|
|
187
|
+
const keys = [];
|
|
188
|
+
for (const p of modulePaths) {
|
|
189
|
+
if (!isWmxModule(p)) continue;
|
|
190
|
+
let content;
|
|
191
|
+
try {
|
|
192
|
+
content = fs.readFileSync(p);
|
|
193
|
+
} catch {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
keys.push(`${normalizeWmxKey(p)}:${crypto.createHash('md5').update(content).digest('hex')}`);
|
|
197
|
+
}
|
|
198
|
+
if (!keys.length) return '';
|
|
199
|
+
keys.sort();
|
|
200
|
+
return crypto.createHash('md5').update(keys.join('\n')).digest('hex');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function servedBundleDir() {
|
|
204
|
+
const webappRoot = process.env.WM_PROJECT_SRC
|
|
205
|
+
? path.resolve(process.env.WM_PROJECT_SRC)
|
|
206
|
+
: path.resolve(PROJECT_ROOT, '..', 'src', 'main', 'webapp');
|
|
207
|
+
return path.join(webappRoot, 'rn-bundle');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function sharedVendorGenerationDir() {
|
|
211
|
+
try {
|
|
212
|
+
const p = path.join(PROJECT_ROOT, '.wm-vendor-generation');
|
|
213
|
+
if (fs.existsSync(p)) {
|
|
214
|
+
const dir = fs.readFileSync(p, 'utf8').trim();
|
|
215
|
+
if (dir) return dir;
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
// fall through to per-project
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function cacheRoot(kind = 'vendor') {
|
|
224
|
+
if (kind === 'vendor') {
|
|
225
|
+
const sharedDir = sharedVendorGenerationDir();
|
|
226
|
+
if (sharedDir) {
|
|
227
|
+
return path.join(sharedDir, '.vendor-cache');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return path.join(servedBundleDir(), `.${kind}-cache`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Hashes lock CONTENTS (not mtimes) so timestamp churn doesn't bust the cache.
|
|
234
|
+
function computeKey(projectRoot, platform, dev, kind = 'vendor', reachableSetHash = '') {
|
|
235
|
+
const h = crypto.createHash('md5');
|
|
236
|
+
h.update(`scheme:${MODULE_ID_SCHEME_VERSION}|platform:${platform}|dev:${dev ? 1 : 0}|kind:${kind}`);
|
|
237
|
+
|
|
238
|
+
if (reachableSetHash) {
|
|
239
|
+
h.update(`${kind}Set:${reachableSetHash}`);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const base = loadBaseManifest(projectRoot);
|
|
243
|
+
const files = [];
|
|
244
|
+
if (base) {
|
|
245
|
+
h.update(`baseLock:${base.hash}`);
|
|
246
|
+
files.push('yalc.lock');
|
|
247
|
+
} else {
|
|
248
|
+
files.push('package-lock.json', 'npm-shrinkwrap.json', 'yalc.lock');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
for (const f of files) {
|
|
252
|
+
const p = path.join(projectRoot, f);
|
|
253
|
+
if (fs.existsSync(p)) {
|
|
254
|
+
h.update(f);
|
|
255
|
+
h.update(fs.readFileSync(p));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return h.digest('hex');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function readMapIfPresent(mapFile) {
|
|
262
|
+
try {
|
|
263
|
+
return fs.existsSync(mapFile) ? fs.readFileSync(mapFile, 'utf8') : null;
|
|
264
|
+
} catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// One entry kept per kind (MAX_ENTRIES was always 1), so eviction is "remove whatever the
|
|
270
|
+
// previous key was", tracked in this sibling marker file next to cacache's own directory.
|
|
271
|
+
function currentKeyFile(kind) {
|
|
272
|
+
return `${cacheRoot(kind)}.current-key`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
async function evictStaleEntry(kind, keptKey) {
|
|
277
|
+
const marker = currentKeyFile(kind);
|
|
278
|
+
let previousKey = '';
|
|
279
|
+
try {
|
|
280
|
+
previousKey = fs.readFileSync(marker, 'utf8').trim();
|
|
281
|
+
} catch {
|
|
282
|
+
// no prior entry
|
|
283
|
+
}
|
|
284
|
+
if (previousKey && previousKey !== keptKey) {
|
|
285
|
+
const cache = cacheRoot(kind);
|
|
286
|
+
try {
|
|
287
|
+
await cacache.rm.entry(cache, previousKey);
|
|
288
|
+
if (kind !== 'extras' && kind !== 'wmx') {
|
|
289
|
+
await cacache.rm.entry(cache, `${previousKey}:map`).catch(() => {});
|
|
290
|
+
}
|
|
291
|
+
// rm.entry only drops the index row; verify() reclaims the now-orphaned content bytes.
|
|
292
|
+
await cacache.verify(cache);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
console.warn(`[vendor-cache] failed to evict stale ${kind} entry:`, err.message);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
fs.mkdirpSync(path.dirname(marker));
|
|
298
|
+
fs.writeFileSync(marker, keptKey);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// cacache.get() throws (ENOENT) rather than returning null on a miss.
|
|
302
|
+
async function lookup(projectRoot, platform, dev, kind = 'vendor', vendorSetHash = '') {
|
|
303
|
+
const key = computeKey(projectRoot, platform, dev, kind, vendorSetHash);
|
|
304
|
+
const cache = cacheRoot(kind);
|
|
305
|
+
|
|
306
|
+
let entry;
|
|
307
|
+
try {
|
|
308
|
+
entry = await cacache.get(cache, key);
|
|
309
|
+
} catch {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
const meta = entry.metadata || {};
|
|
313
|
+
|
|
314
|
+
if (kind === 'extras' || kind === 'wmx') {
|
|
315
|
+
// Extras/wmx bytes live in rn-bundle, not in the cache — this entry is metadata-only.
|
|
316
|
+
const servedFile = meta.filename
|
|
317
|
+
? path.join(servedBundleDir(), path.basename(meta.filename))
|
|
318
|
+
: null;
|
|
319
|
+
if (!servedFile || !fs.existsSync(servedFile)) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
key,
|
|
324
|
+
bundlePath: servedFile,
|
|
325
|
+
mapPath: null,
|
|
326
|
+
source: fs.readFileSync(servedFile, 'utf8'),
|
|
327
|
+
map: readMapIfPresent(`${servedFile}.map`),
|
|
328
|
+
meta,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let map = null;
|
|
333
|
+
let mapPath = null;
|
|
334
|
+
try {
|
|
335
|
+
const mapEntry = await cacache.get(cache, `${key}:map`);
|
|
336
|
+
map = mapEntry.data.toString('utf8');
|
|
337
|
+
mapPath = (await cacache.get.info(cache, `${key}:map`)).path;
|
|
338
|
+
} catch {
|
|
339
|
+
// no map cached — the JS is still servable without one
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const info = await cacache.get.info(cache, key);
|
|
343
|
+
return {
|
|
344
|
+
key,
|
|
345
|
+
bundlePath: info.path,
|
|
346
|
+
mapPath,
|
|
347
|
+
source: entry.data.toString('utf8'),
|
|
348
|
+
map,
|
|
349
|
+
meta,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// vendor/extras' actual bytes and integrity are cacache's job now; this only tracks which
|
|
354
|
+
// key is current so the previous generation's entry gets evicted (see evictStaleEntry).
|
|
355
|
+
async function store(key, platform, source, meta, kind = 'vendor', map = null) {
|
|
356
|
+
const cache = cacheRoot(kind);
|
|
357
|
+
|
|
358
|
+
return withLock(cache, async () => {
|
|
359
|
+
if (kind === 'extras' || kind === 'wmx') {
|
|
360
|
+
await cacache.put(cache, key, Buffer.alloc(0), { metadata: meta });
|
|
361
|
+
await evictStaleEntry(kind, key);
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
await cacache.put(cache, key, Buffer.from(source, 'utf8'), { metadata: meta });
|
|
366
|
+
let mapPath = null;
|
|
367
|
+
if (map) {
|
|
368
|
+
await cacache.put(cache, `${key}:map`, Buffer.from(map, 'utf8'), { metadata: {} });
|
|
369
|
+
mapPath = (await cacache.get.info(cache, `${key}:map`)).path;
|
|
370
|
+
}
|
|
371
|
+
await evictStaleEntry(kind, key);
|
|
372
|
+
const info = await cacache.get.info(cache, key);
|
|
373
|
+
return { bundlePath: info.path, mapPath };
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// 'user' is a single evolving baseline per project+platform, forced to fully refresh every WM_USER_CACHE_REFRESH_INTERVAL builds.
|
|
378
|
+
const USER_CACHE_REFRESH_INTERVAL = parseInt(process.env.WM_USER_CACHE_REFRESH_INTERVAL, 10) || 20;
|
|
379
|
+
|
|
380
|
+
function userCacheDir() {
|
|
381
|
+
return path.join(servedBundleDir(), '.user-cache');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function userMetaPath(platform) {
|
|
385
|
+
return path.join(userCacheDir(), `meta.${platform}.json`);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function loadUserMeta(platform) {
|
|
389
|
+
let meta;
|
|
390
|
+
try {
|
|
391
|
+
meta = fs.readJSONSync(userMetaPath(platform));
|
|
392
|
+
} catch {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
if (meta.schemeVersion !== MODULE_ID_SCHEME_VERSION) return null;
|
|
396
|
+
const servedFile = meta.filename ? path.join(servedBundleDir(), path.basename(meta.filename)) : null;
|
|
397
|
+
if (!servedFile || !fs.existsSync(servedFile)) return null;
|
|
398
|
+
return meta;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function shouldForceFullUserRefresh(meta) {
|
|
402
|
+
// A baseline from before content hashes were recorded can only be judged by mtime, which a clean
|
|
403
|
+
// preview defeats — recapture it once rather than ship the whole app as `modified` for 20 builds.
|
|
404
|
+
return !meta || !meta.stableHashes || (meta.buildsSinceRefresh ?? 0) >= USER_CACHE_REFRESH_INTERVAL;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function readCachedUserSource(meta) {
|
|
408
|
+
return fs.readFileSync(path.join(servedBundleDir(), path.basename(meta.filename)), 'utf8');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function readCachedUserMap(meta) {
|
|
412
|
+
return readMapIfPresent(path.join(servedBundleDir(), `${path.basename(meta.filename)}.map`));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const md5File = (filePath) => crypto.createHash('md5').update(fs.readFileSync(filePath)).digest('hex');
|
|
416
|
+
|
|
417
|
+
// Stable = in stableKeys and same content as the baseline. Codegen rewrites every file on a clean preview,
|
|
418
|
+
// so mtime alone flagged the whole app as modified; it stays only as the cheap first check.
|
|
419
|
+
function isStableModule(filePath, stableKeySet, builtAt, stableHashes) {
|
|
420
|
+
const key = normalizeKey(filePath);
|
|
421
|
+
if (!stableKeySet.has(key)) return false;
|
|
422
|
+
try {
|
|
423
|
+
if (fs.statSync(filePath).mtimeMs <= builtAt) return true;
|
|
424
|
+
return !!stableHashes && stableHashes[key] === md5File(filePath);
|
|
425
|
+
} catch {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function storeUserBaseline(platform, filename, stableKeys, builtAt) {
|
|
431
|
+
const stableHashes = {};
|
|
432
|
+
for (const key of stableKeys) {
|
|
433
|
+
try { stableHashes[key] = md5File(key); } catch {}
|
|
434
|
+
}
|
|
435
|
+
fs.ensureDirSync(userCacheDir());
|
|
436
|
+
fs.writeJSONSync(userMetaPath(platform), {
|
|
437
|
+
filename,
|
|
438
|
+
schemeVersion: MODULE_ID_SCHEME_VERSION,
|
|
439
|
+
stableKeys,
|
|
440
|
+
stableHashes,
|
|
441
|
+
builtAt,
|
|
442
|
+
buildsSinceRefresh: 0,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function bumpUserBuildCount(platform, meta) {
|
|
447
|
+
fs.writeJSONSync(userMetaPath(platform), { ...meta, buildsSinceRefresh: (meta.buildsSinceRefresh ?? 0) + 1 });
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
module.exports = {
|
|
451
|
+
computeKey,
|
|
452
|
+
lookup,
|
|
453
|
+
store,
|
|
454
|
+
baseModeEnabled,
|
|
455
|
+
extrasSplitEnabled,
|
|
456
|
+
isBaselineModule,
|
|
457
|
+
isExtraModule,
|
|
458
|
+
isWmxModule,
|
|
459
|
+
isProjectSourceModule,
|
|
460
|
+
isVirtualModule,
|
|
461
|
+
isVendorSeed,
|
|
462
|
+
computeChunkLayers,
|
|
463
|
+
isLibraryModule,
|
|
464
|
+
computeVendorSetHash,
|
|
465
|
+
computeExtrasSetHash,
|
|
466
|
+
computeWmxContentHash,
|
|
467
|
+
USER_CACHE_REFRESH_INTERVAL,
|
|
468
|
+
loadUserMeta,
|
|
469
|
+
shouldForceFullUserRefresh,
|
|
470
|
+
readCachedUserSource,
|
|
471
|
+
readCachedUserMap,
|
|
472
|
+
isStableModule,
|
|
473
|
+
storeUserBaseline,
|
|
474
|
+
bumpUserBuildCount,
|
|
475
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Stops Metro's graph traversal at the node_modules boundary.
|
|
5
|
+
*
|
|
6
|
+
* User code reaches ~2650 node_modules modules, but only ~85 of them DIRECTLY — the rest are
|
|
7
|
+
* transitive. Those transitive modules are already in the cached vendor/extras chunks, complete with
|
|
8
|
+
* their own `d` arrays baked in when those chunks were built, so re-walking them every build derives
|
|
9
|
+
* nothing new. This preload short-circuits their transform to a stub with no dependencies, which is
|
|
10
|
+
* what makes Metro stop recursing: the graph collapses from 2730 modules to ~159.
|
|
11
|
+
*
|
|
12
|
+
* It ONLY stubs a module whose normalized key is already in the served vendor manifest. Anything not
|
|
13
|
+
* in the manifest is transformed for real and recursed into as usual, so a newly added package is
|
|
14
|
+
* still discovered — and split.static.js then refuses the boundary build and falls back to a full one.
|
|
15
|
+
*
|
|
16
|
+
* Loaded via NODE_OPTIONS=--require from metro.script.js. On by default; disable with WM_BOUNDARY=0.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const Module = require('module');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const STUB_CODE = '__d(function(g,r,i,a,m,e,d){});';
|
|
24
|
+
const EMPTY_SOURCE = Buffer.from('');
|
|
25
|
+
|
|
26
|
+
function servedBundleDir() {
|
|
27
|
+
const webapp = process.env.WM_PROJECT_SRC
|
|
28
|
+
? path.resolve(process.env.WM_PROJECT_SRC)
|
|
29
|
+
: path.resolve(process.env.WM_BOUNDARY_PROJECT_ROOT || process.cwd(), '..', 'src', 'main', 'webapp');
|
|
30
|
+
return path.join(webapp, 'rn-bundle');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The manifest is the authoritative list of what the cached vendor chunk actually contains.
|
|
34
|
+
function readKeys(file) {
|
|
35
|
+
try {
|
|
36
|
+
const keys = JSON.parse(fs.readFileSync(path.join(servedBundleDir(), file), 'utf8'));
|
|
37
|
+
return Array.isArray(keys) ? keys : [];
|
|
38
|
+
} catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Extras hang off vendor parents, so stubbing vendor alone would make traversal never reach them and
|
|
44
|
+
// the extras chunk would silently vanish from the bundle. Both lists are cached chunks; treat both
|
|
45
|
+
// as safe to stop at.
|
|
46
|
+
function loadVendorManifestKeys() {
|
|
47
|
+
const keys = [...readKeys('vendor-manifest.json'), ...readKeys('extras-manifest.json')];
|
|
48
|
+
return keys.length ? new Set(keys) : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Mirrors the real result shape exactly: dependencies, output, unstable_transformResultKey and
|
|
52
|
+
// getSource. Omitting getSource is what made an earlier probe die on `module.getSource is not a function`.
|
|
53
|
+
function stubResult(filePath) {
|
|
54
|
+
return {
|
|
55
|
+
dependencies: [],
|
|
56
|
+
output: [{
|
|
57
|
+
type: 'js/module',
|
|
58
|
+
data: { code: STUB_CODE, lineCount: 1, map: [], functionMap: null },
|
|
59
|
+
}],
|
|
60
|
+
unstable_transformResultKey: `wm-boundary-stub:${filePath}`,
|
|
61
|
+
getSource: () => EMPTY_SOURCE,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const stats = { stubbed: 0, realNodeModules: 0, project: 0 };
|
|
66
|
+
|
|
67
|
+
// handle(filePath) returns a result to skip the transform, or nothing to fall through.
|
|
68
|
+
function wrapTransformFile(TransformerClass, flag, handle) {
|
|
69
|
+
const proto = TransformerClass && TransformerClass.prototype;
|
|
70
|
+
if (!proto || typeof proto.transformFile !== 'function' || proto.transformFile[flag]) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const original = proto.transformFile;
|
|
74
|
+
const patched = async function transformFile(filePath, ...rest) {
|
|
75
|
+
return handle(filePath) || original.apply(this, [filePath, ...rest]);
|
|
76
|
+
};
|
|
77
|
+
patched[flag] = true;
|
|
78
|
+
Object.defineProperty(proto, 'transformFile', { value: patched, writable: true, configurable: true });
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function whenTransformerLoads(onLoad) {
|
|
83
|
+
const originalLoad = Module._load;
|
|
84
|
+
Module._load = function (request, parent) {
|
|
85
|
+
const exported = originalLoad.apply(this, arguments);
|
|
86
|
+
let filename = '';
|
|
87
|
+
try { filename = Module._resolveFilename(request, parent) || ''; } catch {}
|
|
88
|
+
if (/DeltaBundler[/\\]Transformer\.js$/.test(filename)) {
|
|
89
|
+
onLoad(exported && (exported.Transformer || exported.default || exported));
|
|
90
|
+
}
|
|
91
|
+
return exported;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function install(TransformerClass, manifestKeys, normalizeKey) {
|
|
96
|
+
return wrapTransformFile(TransformerClass, '__wmBoundary', (filePath) => {
|
|
97
|
+
if (typeof filePath === 'string' && filePath.includes('node_modules')) {
|
|
98
|
+
let key = null;
|
|
99
|
+
try { key = normalizeKey(filePath); } catch { key = null; }
|
|
100
|
+
if (key && manifestKeys.has(key)) {
|
|
101
|
+
stats.stubbed++;
|
|
102
|
+
return stubResult(filePath);
|
|
103
|
+
}
|
|
104
|
+
stats.realNodeModules++;
|
|
105
|
+
} else {
|
|
106
|
+
stats.project++;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (process.env.WM_BOUNDARY !== '0') {
|
|
112
|
+
const manifestKeys = loadVendorManifestKeys();
|
|
113
|
+
if (!manifestKeys) {
|
|
114
|
+
console.log('[boundary] no served vendor manifest — running a normal full traversal');
|
|
115
|
+
} else {
|
|
116
|
+
let normalizeKey;
|
|
117
|
+
try {
|
|
118
|
+
({ normalizeKey } = require('./module-path'));
|
|
119
|
+
} catch {
|
|
120
|
+
normalizeKey = null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!normalizeKey) {
|
|
124
|
+
console.log('[boundary] could not load module-path.js — running a normal full traversal');
|
|
125
|
+
} else {
|
|
126
|
+
whenTransformerLoads((TransformerClass) => {
|
|
127
|
+
try {
|
|
128
|
+
if (install(TransformerClass, manifestKeys, normalizeKey)) {
|
|
129
|
+
/* The serializer runs in this same process and must gate its safety checks on whether
|
|
130
|
+
the graph is ACTUALLY truncated, not on WM_BOUNDARY. The env var only says the
|
|
131
|
+
optimisation is permitted; every path above this line declines it and still leaves
|
|
132
|
+
a complete graph, and a serializer that assumed otherwise would refuse builds that
|
|
133
|
+
were never truncated (and, worse, trust a full graph to be small). */
|
|
134
|
+
globalThis.__WM_BOUNDARY_ACTIVE__ = true;
|
|
135
|
+
console.log(`[boundary] traversal will stop at node_modules (${manifestKeys.size} vendor keys known)`);
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
console.warn('[boundary] could not install:', err.message);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
process.on('exit', () => {
|
|
143
|
+
console.log(`[boundary] stubbed ${stats.stubbed} vendor module(s), `
|
|
144
|
+
+ `transformed ${stats.realNodeModules} unlisted node_modules + ${stats.project} project file(s)`);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
module.exports = { stubResult, loadVendorManifestKeys, wrapTransformFile, whenTransformerLoads };
|