@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.16 → 3.9.0-ultramodern.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/backend-federation-build/codegen.js +22 -16
- package/dist/cjs/build-config/build-environment.js +2 -141
- package/dist/cjs/build-config/public.js +2 -5
- package/dist/cjs/cloudflare-builder.js +0 -30
- package/dist/cjs/config.js +2 -5
- package/dist/cjs/deploy-output/trace-files.js +90 -0
- package/dist/cjs/release-identity.js +2 -0
- package/dist/cjs/templates/cloudflare-entry.002-assets-routes.mjs +1 -1
- package/dist/cjs/templates/cloudflare-entry.004-rendering-css.mjs +1 -1
- package/dist/esm/backend-federation-build/codegen.mjs +22 -16
- package/dist/esm/build-config/build-environment.mjs +1 -137
- package/dist/esm/build-config/public.mjs +1 -1
- package/dist/esm/cloudflare-builder.mjs +0 -30
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/deploy-output/trace-files.mjs +38 -0
- package/dist/esm/release-identity.mjs +2 -0
- package/dist/esm/templates/cloudflare-entry.002-assets-routes.mjs +1 -1
- package/dist/esm/templates/cloudflare-entry.004-rendering-css.mjs +1 -1
- package/dist/esm-node/backend-federation-build/codegen.mjs +22 -16
- package/dist/esm-node/build-config/build-environment.mjs +1 -137
- package/dist/esm-node/build-config/public.mjs +1 -1
- package/dist/esm-node/cloudflare-builder.mjs +0 -30
- package/dist/esm-node/config.mjs +1 -1
- package/dist/esm-node/deploy-output/trace-files.mjs +39 -0
- package/dist/esm-node/release-identity.mjs +2 -0
- package/dist/esm-node/templates/cloudflare-entry.002-assets-routes.mjs +1 -1
- package/dist/esm-node/templates/cloudflare-entry.004-rendering-css.mjs +1 -1
- package/dist/types/build-config/build-environment.d.ts +0 -8
- package/dist/types/build-config/public.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/deploy-output/trace-files.d.ts +17 -0
- package/package.json +34 -16
- package/src/backend-federation-build/codegen.ts +22 -17
- package/src/build-config/build-environment.ts +0 -244
- package/src/build-config/public.ts +0 -1
- package/src/cloudflare/index.ts +0 -3
- package/src/cloudflare-builder.ts +0 -85
- package/src/config.ts +0 -1
- package/src/deploy-output/trace-files.ts +67 -0
- package/src/release-identity.ts +10 -0
- package/src/templates/cloudflare-entry.002-assets-routes.mjs +1 -1
- package/src/templates/cloudflare-entry.004-rendering-css.mjs +1 -1
- package/dist/cjs/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/cjs/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/cjs/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm-node/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm-node/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm-node/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/types/templates/cloudflare-worker-fs-promises.d.mts +0 -5
- package/dist/types/templates/cloudflare-worker-loadable-server.d.mts +0 -48
- package/dist/types/templates/cloudflare-worker-path.d.mts +0 -21
- package/src/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/src/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/src/templates/cloudflare-worker-path.mjs +0 -98
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import {
|
|
3
3
|
BACKEND_FEDERATION_EFFECT_EXPOSE as BACKEND_EXPOSE,
|
|
4
|
-
BACKEND_FEDERATION_MANIFEST_FILE as BACKEND_MANIFEST_FILE,
|
|
5
4
|
BACKEND_FEDERATION_REMOTE_ENTRY_FILE as BACKEND_REMOTE_ENTRY_FILE,
|
|
6
5
|
BACKEND_FEDERATION_CONTRACT_VERSION as CONTRACT_VERSION,
|
|
7
6
|
formatBackendFederationValidationErrors,
|
|
@@ -65,28 +64,34 @@ export const createBackendRemoteEntrySource = async (
|
|
|
65
64
|
...(app.sourceRevision ? { sourceRevision: app.sourceRevision } : {}),
|
|
66
65
|
};
|
|
67
66
|
const source = `// Generated by Modern.js backend federation build.
|
|
68
|
-
import
|
|
67
|
+
import { adoptEffectBffShareScope } from '@modern-js/bff-effect/effect-edge';
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
// The expose evaluates lazily so defineEffectBff registers its handler
|
|
70
|
+
// factories with the registry the host shares through init().
|
|
71
|
+
let exposedModule;
|
|
72
|
+
const loadExposedModule = () =>
|
|
73
|
+
(exposedModule ??= import(${JSON.stringify(effectApiSpecifier)}).then(exposedNamespace => ({
|
|
74
|
+
...exposedNamespace,
|
|
75
|
+
backendFederationContract: {
|
|
76
|
+
...(exposedNamespace.backendFederationContract ?? {}),
|
|
77
|
+
compatibility: {
|
|
78
|
+
...(exposedNamespace.backendFederationContract?.compatibility ?? {}),
|
|
79
|
+
...${JSON.stringify(compatibility)},
|
|
80
|
+
},
|
|
81
|
+
name: ${JSON.stringify(app.backendName)},
|
|
82
|
+
role: 'microvertical-server',
|
|
83
|
+
runtimeFramework: 'effect',
|
|
84
|
+
strictEffectApproach: true,
|
|
77
85
|
},
|
|
78
|
-
|
|
79
|
-
role: 'microvertical-server',
|
|
80
|
-
runtimeFramework: 'effect',
|
|
81
|
-
strictEffectApproach: true,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
86
|
+
})));
|
|
84
87
|
const exposedModules = {
|
|
85
|
-
${JSON.stringify(BACKEND_EXPOSE)}:
|
|
88
|
+
${JSON.stringify(BACKEND_EXPOSE)}: loadExposedModule,
|
|
86
89
|
};
|
|
87
90
|
const __modernjsBackendFederation = ${JSON.stringify(containerMetadata)};
|
|
88
91
|
|
|
89
|
-
function init() {
|
|
92
|
+
function init(shareScope) {
|
|
93
|
+
return adoptEffectBffShareScope(shareScope);
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
function get(id) {
|
|
92
97
|
const load = exposedModules[id];
|
|
@@ -16,230 +16,17 @@ import { createRequire } from 'node:module';
|
|
|
16
16
|
import { tmpdir } from 'node:os';
|
|
17
17
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
18
18
|
import type { URL } from 'node:url';
|
|
19
|
-
import type { Rspack } from '@rsbuild/core';
|
|
20
19
|
|
|
21
20
|
const EFFECT_TSGO_PACKAGE = '@effect/tsgo';
|
|
22
21
|
const EFFECT_TSGO_BIN = 'effect-tsgo';
|
|
23
22
|
const EFFECT_TSGO_RESOLUTION_ERROR =
|
|
24
23
|
'Unable to resolve the Effect TS-Go compiler. Install "@effect/tsgo" and a native TypeScript backend for this build config, or set EFFECT_TSGO_BIN.';
|
|
25
24
|
const executableEffectTsgoCompilers = new Map<string, string>();
|
|
26
|
-
const BUILD_CONFIG_ENVIRONMENT_PLUGIN =
|
|
27
|
-
'ModernJsBuildConfigEnvironmentLeasePlugin';
|
|
28
|
-
const ENVIRONMENT_LEASE_REGISTRY_KEY = Symbol.for(
|
|
29
|
-
'@modern-js/app-tools/build-config-environment-lease-registry/v1',
|
|
30
|
-
);
|
|
31
|
-
const ENVIRONMENT_LEASE_REGISTRY_BRAND = Symbol.for(
|
|
32
|
-
'@modern-js/app-tools/build-config-environment-lease-registry-brand/v1',
|
|
33
|
-
);
|
|
34
|
-
const LIFECYCLE_HOOK_NAMES = [
|
|
35
|
-
'run',
|
|
36
|
-
'watchRun',
|
|
37
|
-
'afterDone',
|
|
38
|
-
'failed',
|
|
39
|
-
'shutdown',
|
|
40
|
-
'watchClose',
|
|
41
|
-
] as const;
|
|
42
25
|
|
|
43
26
|
type PackageJson = {
|
|
44
27
|
bin?: Record<string, string> | string;
|
|
45
28
|
};
|
|
46
29
|
|
|
47
|
-
type EnvironmentLease = {
|
|
48
|
-
originalValue: string | undefined;
|
|
49
|
-
owners: Set<symbol>;
|
|
50
|
-
value: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
type EnvironmentLeaseRegistry = Readonly<{
|
|
54
|
-
acquire: (name: string, value: string) => () => void;
|
|
55
|
-
brand: symbol;
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
type LifecycleHookName = (typeof LIFECYCLE_HOOK_NAMES)[number];
|
|
59
|
-
|
|
60
|
-
type LifecycleHook = {
|
|
61
|
-
tap: (options: { name: string; stage: number }, handler: () => void) => void;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function restoreEnvironment(name: string, value: string | undefined): void {
|
|
65
|
-
if (value === undefined) {
|
|
66
|
-
delete process.env[name];
|
|
67
|
-
} else {
|
|
68
|
-
process.env[name] = value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function createEnvironmentLeaseRegistry(): EnvironmentLeaseRegistry {
|
|
73
|
-
const environmentLeases = new Map<string, EnvironmentLease>();
|
|
74
|
-
|
|
75
|
-
return Object.freeze({
|
|
76
|
-
acquire(name: string, value: string): () => void {
|
|
77
|
-
let lease = environmentLeases.get(name);
|
|
78
|
-
|
|
79
|
-
if (lease) {
|
|
80
|
-
if (lease.value !== value) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
`Build config environment "${name}" already has an active lease for a different value.`,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
if (process.env[name] !== lease.value) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Build config environment lease for "${name}" lost ownership before another lease was acquired.`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
lease = {
|
|
92
|
-
originalValue: process.env[name],
|
|
93
|
-
owners: new Set(),
|
|
94
|
-
value,
|
|
95
|
-
};
|
|
96
|
-
process.env[name] = value;
|
|
97
|
-
environmentLeases.set(name, lease);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const owner = Symbol(name);
|
|
101
|
-
lease.owners.add(owner);
|
|
102
|
-
let released = false;
|
|
103
|
-
|
|
104
|
-
return () => {
|
|
105
|
-
if (released) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (environmentLeases.get(name) !== lease || !lease.owners.has(owner)) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
`Build config environment lease for "${name}" cannot be restored because its ownership record was lost.`,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
released = true;
|
|
116
|
-
const lostOwnership = process.env[name] !== lease.value;
|
|
117
|
-
lease.owners.delete(owner);
|
|
118
|
-
|
|
119
|
-
if (lease.owners.size === 0) {
|
|
120
|
-
environmentLeases.delete(name);
|
|
121
|
-
restoreEnvironment(name, lease.originalValue);
|
|
122
|
-
} else if (lostOwnership) {
|
|
123
|
-
process.env[name] = lease.value;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (lostOwnership) {
|
|
127
|
-
throw new Error(
|
|
128
|
-
`Build config environment lease for "${name}" lost ownership before restoration.`,
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
brand: ENVIRONMENT_LEASE_REGISTRY_BRAND,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function getEnvironmentLeaseRegistry(): EnvironmentLeaseRegistry {
|
|
138
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
139
|
-
process,
|
|
140
|
-
ENVIRONMENT_LEASE_REGISTRY_KEY,
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
if (descriptor) {
|
|
144
|
-
const registry = descriptor.value as
|
|
145
|
-
| Partial<EnvironmentLeaseRegistry>
|
|
146
|
-
| undefined;
|
|
147
|
-
if (
|
|
148
|
-
descriptor.configurable ||
|
|
149
|
-
descriptor.enumerable ||
|
|
150
|
-
descriptor.writable ||
|
|
151
|
-
registry?.brand !== ENVIRONMENT_LEASE_REGISTRY_BRAND ||
|
|
152
|
-
typeof registry.acquire !== 'function'
|
|
153
|
-
) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
'The process-global build config environment lease registry is occupied by an incompatible value.',
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
return registry as EnvironmentLeaseRegistry;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const registry = createEnvironmentLeaseRegistry();
|
|
162
|
-
Object.defineProperty(process, ENVIRONMENT_LEASE_REGISTRY_KEY, {
|
|
163
|
-
configurable: false,
|
|
164
|
-
enumerable: false,
|
|
165
|
-
value: registry,
|
|
166
|
-
writable: false,
|
|
167
|
-
});
|
|
168
|
-
return registry;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function acquireEnvironmentLease(name: string, value: string): () => void {
|
|
172
|
-
return getEnvironmentLeaseRegistry().acquire(name, value);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function releaseAfterFailure(
|
|
176
|
-
release: () => void,
|
|
177
|
-
originalError: unknown,
|
|
178
|
-
): never {
|
|
179
|
-
try {
|
|
180
|
-
release();
|
|
181
|
-
} catch (restorationError) {
|
|
182
|
-
throw new AggregateError(
|
|
183
|
-
[originalError, restorationError],
|
|
184
|
-
'Build config environment setup and restoration both failed.',
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
throw originalError;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
class BuildConfigEnvironmentLeasePlugin {
|
|
192
|
-
constructor(private readonly release: () => void) {}
|
|
193
|
-
|
|
194
|
-
apply(compiler: Rspack.Compiler): void {
|
|
195
|
-
const hooks = compiler.hooks as unknown as Record<
|
|
196
|
-
string,
|
|
197
|
-
LifecycleHook | undefined
|
|
198
|
-
>;
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
const lifecycleHooks = {} as Record<LifecycleHookName, LifecycleHook>;
|
|
202
|
-
for (const hookName of LIFECYCLE_HOOK_NAMES) {
|
|
203
|
-
const hook = hooks[hookName];
|
|
204
|
-
if (!hook || typeof hook.tap !== 'function') {
|
|
205
|
-
throw new Error(
|
|
206
|
-
`Rspack does not expose the "${hookName}" lifecycle hook required to restore build config environment leases.`,
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
lifecycleHooks[hookName] = hook;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
let mode: 'pending' | 'run' | 'watch' = 'pending';
|
|
213
|
-
const modeTap = {
|
|
214
|
-
name: BUILD_CONFIG_ENVIRONMENT_PLUGIN,
|
|
215
|
-
stage: Number.MIN_SAFE_INTEGER,
|
|
216
|
-
};
|
|
217
|
-
const releaseTap = {
|
|
218
|
-
name: BUILD_CONFIG_ENVIRONMENT_PLUGIN,
|
|
219
|
-
stage: Number.MAX_SAFE_INTEGER,
|
|
220
|
-
};
|
|
221
|
-
const releaseAfterOneShot = () => {
|
|
222
|
-
if (mode !== 'watch' && compiler.watchMode !== true) {
|
|
223
|
-
this.release();
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
lifecycleHooks.run.tap(modeTap, () => {
|
|
228
|
-
mode = 'run';
|
|
229
|
-
});
|
|
230
|
-
lifecycleHooks.watchRun.tap(modeTap, () => {
|
|
231
|
-
mode = 'watch';
|
|
232
|
-
});
|
|
233
|
-
lifecycleHooks.afterDone.tap(releaseTap, releaseAfterOneShot);
|
|
234
|
-
lifecycleHooks.failed.tap(releaseTap, releaseAfterOneShot);
|
|
235
|
-
lifecycleHooks.shutdown.tap(releaseTap, this.release);
|
|
236
|
-
lifecycleHooks.watchClose.tap(releaseTap, this.release);
|
|
237
|
-
} catch (error) {
|
|
238
|
-
releaseAfterFailure(this.release, error);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
30
|
function resolveEffectTsgoCli(from: string | URL): string {
|
|
244
31
|
const projectRequire = createRequire(from);
|
|
245
32
|
const packageJsonPath = projectRequire.resolve(
|
|
@@ -333,37 +120,6 @@ export function getBuildConfigEnvironment(name: string): string | undefined {
|
|
|
333
120
|
return process.env[name];
|
|
334
121
|
}
|
|
335
122
|
|
|
336
|
-
/**
|
|
337
|
-
* Runs a Rspack config setup under a leased environment value. The lease is
|
|
338
|
-
* restored when that compiler reaches any supported terminal hook.
|
|
339
|
-
*/
|
|
340
|
-
export function withBuildConfigEnvironment<
|
|
341
|
-
Config extends { plugins?: Rspack.Plugin[] },
|
|
342
|
-
SetupArguments extends unknown[],
|
|
343
|
-
>(
|
|
344
|
-
name: string,
|
|
345
|
-
value: string,
|
|
346
|
-
setup: (
|
|
347
|
-
config: Config,
|
|
348
|
-
...args: SetupArguments
|
|
349
|
-
) => Config | void | Promise<Config | void>,
|
|
350
|
-
): (config: Config, ...args: SetupArguments) => Promise<Config> {
|
|
351
|
-
return async (config, ...args) => {
|
|
352
|
-
const release = acquireEnvironmentLease(name, value);
|
|
353
|
-
|
|
354
|
-
try {
|
|
355
|
-
const configured = (await setup(config, ...args)) ?? config;
|
|
356
|
-
configured.plugins = [
|
|
357
|
-
...(configured.plugins ?? []),
|
|
358
|
-
new BuildConfigEnvironmentLeasePlugin(release),
|
|
359
|
-
];
|
|
360
|
-
return configured;
|
|
361
|
-
} catch (error) {
|
|
362
|
-
releaseAfterFailure(release, error);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
123
|
export type ResolveEffectTsgoCompilerOptions = {
|
|
368
124
|
/** Module URL or absolute filename used to resolve the consumer's compiler. */
|
|
369
125
|
from: string | URL;
|
package/src/cloudflare/index.ts
CHANGED
|
@@ -850,21 +850,6 @@ const createCloudflareBundlerChain = (
|
|
|
850
850
|
workerEntryNames: Iterable<string>,
|
|
851
851
|
): ModifyBundlerChainFn => {
|
|
852
852
|
const resolvePaths = [appContext.appDirectory, process.cwd()];
|
|
853
|
-
const tanstackRouterSsrServerFile = resolvePackageFile(
|
|
854
|
-
'@tanstack/router-core',
|
|
855
|
-
'dist/esm/ssr/ssr-server.js',
|
|
856
|
-
resolvePaths,
|
|
857
|
-
);
|
|
858
|
-
const runtimeRscWorkerFile = resolvePackageFile(
|
|
859
|
-
'@modern-js/runtime',
|
|
860
|
-
'dist/esm/rsc/server.worker.mjs',
|
|
861
|
-
resolvePaths,
|
|
862
|
-
);
|
|
863
|
-
const renderRscWorkerFile = resolvePackageFile(
|
|
864
|
-
'@modern-js/render',
|
|
865
|
-
'dist/esm/rscWorker.mjs',
|
|
866
|
-
resolvePaths,
|
|
867
|
-
);
|
|
868
853
|
const reactFile = resolvePackageFile('react', 'index.js', resolvePaths);
|
|
869
854
|
const reactJsxRuntimeFile = resolvePackageFile(
|
|
870
855
|
'react',
|
|
@@ -891,13 +876,6 @@ const createCloudflareBundlerChain = (
|
|
|
891
876
|
'dist/esm/loadable.esm.mjs',
|
|
892
877
|
[...resolvePaths, getTemplatePath('')],
|
|
893
878
|
);
|
|
894
|
-
const loadableServerWorkerFile = getTemplatePath(
|
|
895
|
-
'cloudflare-worker-loadable-server.mjs',
|
|
896
|
-
);
|
|
897
|
-
const fsPromisesWorkerFile = getTemplatePath(
|
|
898
|
-
'cloudflare-worker-fs-promises.mjs',
|
|
899
|
-
);
|
|
900
|
-
const pathWorkerFile = getTemplatePath('cloudflare-worker-path.mjs');
|
|
901
879
|
const entryNames = [...workerEntryNames];
|
|
902
880
|
|
|
903
881
|
return chain => {
|
|
@@ -935,34 +913,6 @@ const createCloudflareBundlerChain = (
|
|
|
935
913
|
.use(AbsentOptionalDependencyPlugin);
|
|
936
914
|
|
|
937
915
|
applyCloudflareWorkerMfRuntimeBoundary(chain);
|
|
938
|
-
if (tanstackRouterSsrServerFile) {
|
|
939
|
-
chain.resolve.alias.set(
|
|
940
|
-
'@tanstack/router-core/ssr/server$',
|
|
941
|
-
tanstackRouterSsrServerFile,
|
|
942
|
-
);
|
|
943
|
-
chain.resolve.alias.set(
|
|
944
|
-
'@tanstack/router-core/ssr/server',
|
|
945
|
-
tanstackRouterSsrServerFile,
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
|
-
if (runtimeRscWorkerFile) {
|
|
949
|
-
chain.resolve.alias.set(
|
|
950
|
-
'@modern-js/runtime/rsc/server$',
|
|
951
|
-
runtimeRscWorkerFile,
|
|
952
|
-
);
|
|
953
|
-
chain.resolve.alias.set(
|
|
954
|
-
'@modern-js/runtime/rsc/server',
|
|
955
|
-
runtimeRscWorkerFile,
|
|
956
|
-
);
|
|
957
|
-
}
|
|
958
|
-
if (renderRscWorkerFile) {
|
|
959
|
-
chain.resolve.alias.set('@modern-js/render/rsc$', renderRscWorkerFile);
|
|
960
|
-
chain.resolve.alias.set('@modern-js/render/rsc', renderRscWorkerFile);
|
|
961
|
-
chain.resolve.alias.set(
|
|
962
|
-
'@modern-js/render/rsc-worker$',
|
|
963
|
-
renderRscWorkerFile,
|
|
964
|
-
);
|
|
965
|
-
}
|
|
966
916
|
setAliasIfPresent(chain.resolve.alias, 'react$', reactFile);
|
|
967
917
|
setAliasIfPresent(
|
|
968
918
|
chain.resolve.alias,
|
|
@@ -985,41 +935,6 @@ const createCloudflareBundlerChain = (
|
|
|
985
935
|
'@loadable/component$',
|
|
986
936
|
loadableComponentFile,
|
|
987
937
|
);
|
|
988
|
-
setAliasIfPresent(
|
|
989
|
-
chain.resolve.alias,
|
|
990
|
-
'@loadable/server$',
|
|
991
|
-
loadableServerWorkerFile,
|
|
992
|
-
);
|
|
993
|
-
setAliasIfPresent(
|
|
994
|
-
chain.resolve.alias,
|
|
995
|
-
'fs/promises$',
|
|
996
|
-
fsPromisesWorkerFile,
|
|
997
|
-
);
|
|
998
|
-
setAliasIfPresent(
|
|
999
|
-
chain.resolve.alias,
|
|
1000
|
-
'node:fs/promises$',
|
|
1001
|
-
fsPromisesWorkerFile,
|
|
1002
|
-
);
|
|
1003
|
-
setAliasIfPresent(chain.resolve.alias, 'path$', pathWorkerFile);
|
|
1004
|
-
setAliasIfPresent(chain.resolve.alias, 'node:path$', pathWorkerFile);
|
|
1005
|
-
chain.resolve.alias.set(
|
|
1006
|
-
'react-server-dom-rspack/server.node$',
|
|
1007
|
-
'react-server-dom-rspack/server.edge',
|
|
1008
|
-
);
|
|
1009
|
-
chain.resolve.alias.set(
|
|
1010
|
-
'react-server-dom-rspack/server.node',
|
|
1011
|
-
'react-server-dom-rspack/server.edge',
|
|
1012
|
-
);
|
|
1013
|
-
chain.resolve.alias.set(
|
|
1014
|
-
'react-server-dom-rspack/client.node$',
|
|
1015
|
-
'react-server-dom-rspack/client.edge',
|
|
1016
|
-
);
|
|
1017
|
-
chain.resolve.alias.set(
|
|
1018
|
-
'react-server-dom-rspack/client.node',
|
|
1019
|
-
'react-server-dom-rspack/client.edge',
|
|
1020
|
-
);
|
|
1021
|
-
chain.resolve.fallback.set('fs', false);
|
|
1022
|
-
chain.resolve.fallback.set('node:fs', false);
|
|
1023
938
|
};
|
|
1024
939
|
};
|
|
1025
940
|
|
package/src/config.ts
CHANGED
|
@@ -2,7 +2,6 @@ export type { ResolveEffectTsgoCompilerOptions } from './build-config/public';
|
|
|
2
2
|
export {
|
|
3
3
|
getBuildConfigEnvironment,
|
|
4
4
|
resolveEffectTsgoCompiler,
|
|
5
|
-
withBuildConfigEnvironment,
|
|
6
5
|
} from './build-config/public';
|
|
7
6
|
export { createRemoteManifestUrl } from './build-config/remote-address';
|
|
8
7
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { type NodeFileTraceResult, nodeFileTrace } from '@vercel/nft';
|
|
4
|
+
|
|
5
|
+
// Directories owned by the build host rather than the app. nft statically
|
|
6
|
+
// evaluates `os.homedir()`, `os.tmpdir()` and literal system paths, so code
|
|
7
|
+
// like `fs.readFileSync(path.join(os.homedir(), name))` becomes a glob of the
|
|
8
|
+
// whole home directory. With `base: '/'` that glob walks the machine.
|
|
9
|
+
const SYSTEM_ROOTS =
|
|
10
|
+
process.platform === 'win32'
|
|
11
|
+
? []
|
|
12
|
+
: ['/dev', '/etc', '/proc', '/run', '/sys', '/var/run'];
|
|
13
|
+
|
|
14
|
+
const GLOB_SEGMENT = /[*?[{]/;
|
|
15
|
+
|
|
16
|
+
const isInside = (parent: string, child: string) =>
|
|
17
|
+
child === parent || child.startsWith(`${parent}${path.sep}`);
|
|
18
|
+
|
|
19
|
+
const globRoot = (absolutePattern: string) => {
|
|
20
|
+
const { root } = path.parse(absolutePattern);
|
|
21
|
+
const segments = absolutePattern.slice(root.length).split(path.sep);
|
|
22
|
+
const index = segments.findIndex(segment => GLOB_SEGMENT.test(segment));
|
|
23
|
+
return index === -1
|
|
24
|
+
? undefined
|
|
25
|
+
: path.join(root, ...segments.slice(0, index));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Builds the nft `ignore` predicate for a trace rooted at `base`: skip every
|
|
30
|
+
* path under a system root, and skip globs that would enumerate the file
|
|
31
|
+
* system root, the home directory or the temp directory as a whole. Files
|
|
32
|
+
* inside home or temp are still traced, since package stores can live there.
|
|
33
|
+
*/
|
|
34
|
+
export const createBuildHostIgnore = (base: string) => {
|
|
35
|
+
const wholeDirectories = new Set([
|
|
36
|
+
path.parse(path.resolve(base)).root,
|
|
37
|
+
path.resolve(os.homedir()),
|
|
38
|
+
path.resolve(os.tmpdir()),
|
|
39
|
+
]);
|
|
40
|
+
return (relativePath: string) => {
|
|
41
|
+
const absolutePath = path.resolve(base, relativePath);
|
|
42
|
+
if (SYSTEM_ROOTS.some(root => isInside(root, absolutePath))) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const root = globRoot(absolutePath);
|
|
46
|
+
return root !== undefined && wholeDirectories.has(root);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* `traceFiles` implementation for ndepe's `nodeDepEmit`, tracing with the
|
|
52
|
+
* `@vercel/nft` release app-tools-extensions depends on instead of the one ndepe pins.
|
|
53
|
+
*/
|
|
54
|
+
export const traceDeployFiles = ({
|
|
55
|
+
entryFiles,
|
|
56
|
+
sourceDir,
|
|
57
|
+
base = '/',
|
|
58
|
+
}: {
|
|
59
|
+
entryFiles: string[];
|
|
60
|
+
sourceDir: string;
|
|
61
|
+
base?: string;
|
|
62
|
+
}): Promise<NodeFileTraceResult> =>
|
|
63
|
+
nodeFileTrace(entryFiles, {
|
|
64
|
+
base,
|
|
65
|
+
processCwd: sourceDir,
|
|
66
|
+
ignore: createBuildHostIgnore(base),
|
|
67
|
+
});
|
package/src/release-identity.ts
CHANGED
|
@@ -10,6 +10,15 @@ export type UltramodernReleaseIdentity = {
|
|
|
10
10
|
sourceRevision: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// Inherited GIT_* variables (git hooks export GIT_DIR and GIT_INDEX_FILE)
|
|
14
|
+
// would make git describe some other repository than `workspaceRoot`.
|
|
15
|
+
const workspaceGitEnv = (): NodeJS.ProcessEnv =>
|
|
16
|
+
Object.fromEntries(
|
|
17
|
+
Object.entries(process.env).filter(
|
|
18
|
+
([name]) => !name.toUpperCase().startsWith('GIT_'),
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
13
22
|
const gitOutput = (
|
|
14
23
|
workspaceRoot: string,
|
|
15
24
|
args: string[],
|
|
@@ -18,6 +27,7 @@ const gitOutput = (
|
|
|
18
27
|
return execFileSync('git', args, {
|
|
19
28
|
cwd: workspaceRoot,
|
|
20
29
|
encoding: 'utf8',
|
|
30
|
+
env: workspaceGitEnv(),
|
|
21
31
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
22
32
|
}).trim();
|
|
23
33
|
} catch {
|
|
@@ -1138,7 +1138,7 @@ async function withRouteCssLinks(
|
|
|
1138
1138
|
seenCssHrefs.add(entry.preloadHref);
|
|
1139
1139
|
return true;
|
|
1140
1140
|
});
|
|
1141
|
-
for (const {
|
|
1141
|
+
for (const { preloadHref } of uniqueCssEntries) {
|
|
1142
1142
|
const preloadUrl = new URL(preloadHref);
|
|
1143
1143
|
const preloadReference =
|
|
1144
1144
|
preloadUrl.origin === requestOrigin
|