@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.5 → 3.9.0-ultramodern.7
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/config.js +1 -16
- package/dist/cjs/backend-federation-build/emit.js +1 -1
- package/dist/cjs/cloudflare/delivery-unit.js +0 -9
- package/dist/esm/backend-federation-build/config.mjs +3 -15
- package/dist/esm/backend-federation-build/emit.mjs +2 -2
- package/dist/esm/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm-node/backend-federation-build/config.mjs +3 -15
- package/dist/esm-node/backend-federation-build/emit.mjs +2 -2
- package/dist/esm-node/cloudflare/delivery-unit.mjs +1 -10
- package/dist/types/backend-federation-build/config.d.ts +0 -1
- package/dist/types/cloudflare/delivery-unit.d.ts +1 -1
- package/package.json +10 -10
- package/src/backend-federation-build/config.ts +2 -22
- package/src/backend-federation-build/emit.ts +1 -4
- package/src/cloudflare/delivery-unit.ts +1 -18
|
@@ -39,7 +39,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
40
|
COMPACT_CONFIG_PATH: ()=>COMPACT_CONFIG_PATH,
|
|
41
41
|
buildArtifactPathFor: ()=>buildArtifactPathFor,
|
|
42
|
-
buildModulePathFor: ()=>buildModulePathFor,
|
|
43
42
|
createAppFromCompactMetadata: ()=>createAppFromCompactMetadata,
|
|
44
43
|
createStampedDeliveryUnit: ()=>createStampedDeliveryUnit,
|
|
45
44
|
findBackendFederationApp: ()=>findBackendFederationApp,
|
|
@@ -60,7 +59,6 @@ const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/
|
|
|
60
59
|
const isRecord = (value)=>'object' == typeof value && null !== value;
|
|
61
60
|
const readJsonFile = async (filePath)=>JSON.parse(await promises_default().readFile(filePath, 'utf8'));
|
|
62
61
|
const buildArtifactPathFor = (appDirectory)=>external_node_path_default().join(appDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
63
|
-
const buildModulePathFor = (appDirectory)=>external_node_path_default().join(appDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_MODULE_PATH);
|
|
64
62
|
const readBuildIdentity = async (appDirectory)=>{
|
|
65
63
|
const buildArtifactPath = buildArtifactPathFor(appDirectory);
|
|
66
64
|
if ((0, external_node_fs_namespaceObject.existsSync)(buildArtifactPath)) {
|
|
@@ -79,18 +77,7 @@ const readBuildIdentity = async (appDirectory)=>{
|
|
|
79
77
|
sourceRevision: deliveryUnit.sourceRevision
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
|
-
|
|
83
|
-
if (!(0, external_node_fs_namespaceObject.existsSync)(buildModulePath)) return {};
|
|
84
|
-
console.warn(`[backend-federation-build] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ${backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE}.`);
|
|
85
|
-
const source = await promises_default().readFile(buildModulePath, 'utf8');
|
|
86
|
-
return {
|
|
87
|
-
appId: source.match(/\bappId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
88
|
-
buildVersion: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
89
|
-
packageName: source.match(/\bpackageName:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
90
|
-
version: source.match(/\bversion:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
91
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
92
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
93
|
-
};
|
|
80
|
+
throw new Error(`[backend-federation-build] Missing delivery-unit build artifact at ${buildArtifactPath}.`);
|
|
94
81
|
};
|
|
95
82
|
const toPascalCase = (value)=>value.split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
|
|
96
83
|
const stringValue = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
|
|
@@ -179,7 +166,6 @@ const findBackendFederationApp = async (workspaceRoot, appDirectory)=>{
|
|
|
179
166
|
};
|
|
180
167
|
exports.COMPACT_CONFIG_PATH = __webpack_exports__.COMPACT_CONFIG_PATH;
|
|
181
168
|
exports.buildArtifactPathFor = __webpack_exports__.buildArtifactPathFor;
|
|
182
|
-
exports.buildModulePathFor = __webpack_exports__.buildModulePathFor;
|
|
183
169
|
exports.createAppFromCompactMetadata = __webpack_exports__.createAppFromCompactMetadata;
|
|
184
170
|
exports.createStampedDeliveryUnit = __webpack_exports__.createStampedDeliveryUnit;
|
|
185
171
|
exports.findBackendFederationApp = __webpack_exports__.findBackendFederationApp;
|
|
@@ -190,7 +176,6 @@ exports.resolveWorkspaceSourceRevision = __webpack_exports__.resolveWorkspaceSou
|
|
|
190
176
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
191
177
|
"COMPACT_CONFIG_PATH",
|
|
192
178
|
"buildArtifactPathFor",
|
|
193
|
-
"buildModulePathFor",
|
|
194
179
|
"createAppFromCompactMetadata",
|
|
195
180
|
"createStampedDeliveryUnit",
|
|
196
181
|
"findBackendFederationApp",
|
|
@@ -64,7 +64,7 @@ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
|
64
64
|
const hasBuildIdentity = void 0 !== buildIdentity.unitId || void 0 !== buildIdentity.buildVersion || void 0 !== buildIdentity.packageName || void 0 !== buildIdentity.version;
|
|
65
65
|
if (hasBuildIdentity) {
|
|
66
66
|
const compactConfigPath = external_node_path_default().join(workspaceRoot, external_config_js_namespaceObject.COMPACT_CONFIG_PATH);
|
|
67
|
-
const buildIdentityPath = (0,
|
|
67
|
+
const buildIdentityPath = (0, external_config_js_namespaceObject.buildArtifactPathFor)(appDirectory);
|
|
68
68
|
const mismatches = [];
|
|
69
69
|
const compare = (label, a, b, leftLabel = 'deliveryUnit')=>{
|
|
70
70
|
if (void 0 !== a && void 0 !== b && a !== b) mismatches.push(`${label}: ${leftLabel}=${a} vs ultramodern-build=${b}`);
|
|
@@ -130,20 +130,11 @@ const resolveTopologyDeliveryUnit = async (appDirectory)=>{
|
|
|
130
130
|
};
|
|
131
131
|
const resolveWorkerDeliveryUnitStamp = async (appDirectory)=>{
|
|
132
132
|
const buildArtifactPath = external_node_path_default().join(appDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
133
|
-
const buildModulePath = external_node_path_default().join(appDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_MODULE_PATH);
|
|
134
133
|
let identity;
|
|
135
134
|
if (await utils_namespaceObject.fs.pathExists(buildArtifactPath)) {
|
|
136
135
|
const artifact = await utils_namespaceObject.fs.readJSON(buildArtifactPath);
|
|
137
136
|
if (!(0, backend_federation_contracts_namespaceObject.isUltramodernBuildArtifact)(artifact)) return;
|
|
138
137
|
identity = (0, backend_federation_contracts_namespaceObject.toDeliveryUnitIdentity)(artifact.deliveryUnit);
|
|
139
|
-
} else if (await utils_namespaceObject.fs.pathExists(buildModulePath)) {
|
|
140
|
-
console.warn(`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`);
|
|
141
|
-
const source = await utils_namespaceObject.fs.readFile(buildModulePath, 'utf8');
|
|
142
|
-
identity = (0, backend_federation_contracts_namespaceObject.toDeliveryUnitIdentity)({
|
|
143
|
-
buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
144
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
145
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
146
|
-
});
|
|
147
138
|
}
|
|
148
139
|
if (!identity) return;
|
|
149
140
|
const resolved = await resolveCompactApp(appDirectory);
|
|
@@ -2,13 +2,12 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import promises from "node:fs/promises";
|
|
3
3
|
import node_path from "node:path";
|
|
4
4
|
import { resolveUltramodernSourceRevision } from "@modern-js/app-tools-extensions/release-identity";
|
|
5
|
-
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION,
|
|
5
|
+
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_PATH, deliveryUnitContractBlock, isUltramodernBuildArtifact, validateDeliveryUnitRecord, validateUltramodernBuildArtifact } from "@modern-js/backend-federation-contracts";
|
|
6
6
|
const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
|
|
7
7
|
const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
|
|
8
8
|
const isRecord = (value)=>'object' == typeof value && null !== value;
|
|
9
9
|
const readJsonFile = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf8'));
|
|
10
10
|
const buildArtifactPathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
11
|
-
const buildModulePathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
12
11
|
const readBuildIdentity = async (appDirectory)=>{
|
|
13
12
|
const buildArtifactPath = buildArtifactPathFor(appDirectory);
|
|
14
13
|
if (existsSync(buildArtifactPath)) {
|
|
@@ -27,18 +26,7 @@ const readBuildIdentity = async (appDirectory)=>{
|
|
|
27
26
|
sourceRevision: deliveryUnit.sourceRevision
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
if (!existsSync(buildModulePath)) return {};
|
|
32
|
-
console.warn(`[backend-federation-build] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ${ULTRAMODERN_BUILD_ARTIFACT_FILE}.`);
|
|
33
|
-
const source = await promises.readFile(buildModulePath, 'utf8');
|
|
34
|
-
return {
|
|
35
|
-
appId: source.match(/\bappId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
36
|
-
buildVersion: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
37
|
-
packageName: source.match(/\bpackageName:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
38
|
-
version: source.match(/\bversion:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
39
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
40
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
41
|
-
};
|
|
29
|
+
throw new Error(`[backend-federation-build] Missing delivery-unit build artifact at ${buildArtifactPath}.`);
|
|
42
30
|
};
|
|
43
31
|
const toPascalCase = (value)=>value.split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
|
|
44
32
|
const stringValue = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
|
|
@@ -125,4 +113,4 @@ const findBackendFederationApp = async (workspaceRoot, appDirectory)=>{
|
|
|
125
113
|
if (resolved) return resolved;
|
|
126
114
|
}
|
|
127
115
|
};
|
|
128
|
-
export { COMPACT_CONFIG_PATH, buildArtifactPathFor,
|
|
116
|
+
export { COMPACT_CONFIG_PATH, buildArtifactPathFor, createAppFromCompactMetadata, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, normalizeRelativePath, readBuildIdentity, resolveWorkspaceSourceRevision };
|
|
@@ -5,7 +5,7 @@ import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensio
|
|
|
5
5
|
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, stampUltramodernBuildArtifactIdentity } from "@modern-js/backend-federation-contracts";
|
|
6
6
|
import { createBackendFederationEntryIntegrity } from "@modern-js/server-runtime-extensions/backend-federation-security/node";
|
|
7
7
|
import { createBackendManifest, createBackendRemoteEntrySource } from "./codegen.mjs";
|
|
8
|
-
import { COMPACT_CONFIG_PATH, buildArtifactPathFor,
|
|
8
|
+
import { COMPACT_CONFIG_PATH, buildArtifactPathFor, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, readBuildIdentity, resolveWorkspaceSourceRevision } from "./config.mjs";
|
|
9
9
|
const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
10
10
|
const workspaceRoot = findWorkspaceRoot(appDirectory);
|
|
11
11
|
if (!workspaceRoot) return;
|
|
@@ -20,7 +20,7 @@ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
|
20
20
|
const hasBuildIdentity = void 0 !== buildIdentity.unitId || void 0 !== buildIdentity.buildVersion || void 0 !== buildIdentity.packageName || void 0 !== buildIdentity.version;
|
|
21
21
|
if (hasBuildIdentity) {
|
|
22
22
|
const compactConfigPath = node_path.join(workspaceRoot, COMPACT_CONFIG_PATH);
|
|
23
|
-
const buildIdentityPath =
|
|
23
|
+
const buildIdentityPath = buildArtifactPathFor(appDirectory);
|
|
24
24
|
const mismatches = [];
|
|
25
25
|
const compare = (label, a, b, leftLabel = 'deliveryUnit')=>{
|
|
26
26
|
if (void 0 !== a && void 0 !== b && a !== b) mismatches.push(`${label}: ${leftLabel}=${a} vs ultramodern-build=${b}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
|
-
import { ULTRAMODERN_BUILD_ARTIFACT_PATH,
|
|
2
|
+
import { ULTRAMODERN_BUILD_ARTIFACT_PATH, isUltramodernBuildArtifact, nonEmptyString, toDeliveryUnitIdentity } from "@modern-js/backend-federation-contracts";
|
|
3
3
|
import { fs } from "@modern-js/utils";
|
|
4
4
|
import { resolveUltramodernReleaseIdentity } from "../release-identity.mjs";
|
|
5
5
|
import { isRecord } from "./utils.mjs";
|
|
@@ -87,20 +87,11 @@ const resolveTopologyDeliveryUnit = async (appDirectory)=>{
|
|
|
87
87
|
};
|
|
88
88
|
const resolveWorkerDeliveryUnitStamp = async (appDirectory)=>{
|
|
89
89
|
const buildArtifactPath = node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
90
|
-
const buildModulePath = node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
91
90
|
let identity;
|
|
92
91
|
if (await fs.pathExists(buildArtifactPath)) {
|
|
93
92
|
const artifact = await fs.readJSON(buildArtifactPath);
|
|
94
93
|
if (!isUltramodernBuildArtifact(artifact)) return;
|
|
95
94
|
identity = toDeliveryUnitIdentity(artifact.deliveryUnit);
|
|
96
|
-
} else if (await fs.pathExists(buildModulePath)) {
|
|
97
|
-
console.warn(`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`);
|
|
98
|
-
const source = await fs.readFile(buildModulePath, 'utf8');
|
|
99
|
-
identity = toDeliveryUnitIdentity({
|
|
100
|
-
buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
101
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
102
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
103
|
-
});
|
|
104
95
|
}
|
|
105
96
|
if (!identity) return;
|
|
106
97
|
const resolved = await resolveCompactApp(appDirectory);
|
|
@@ -3,13 +3,12 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import promises from "node:fs/promises";
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
import { resolveUltramodernSourceRevision } from "@modern-js/app-tools-extensions/release-identity";
|
|
6
|
-
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION,
|
|
6
|
+
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_PATH, deliveryUnitContractBlock, isUltramodernBuildArtifact, validateDeliveryUnitRecord, validateUltramodernBuildArtifact } from "@modern-js/backend-federation-contracts";
|
|
7
7
|
const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
|
|
8
8
|
const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
|
|
9
9
|
const isRecord = (value)=>'object' == typeof value && null !== value;
|
|
10
10
|
const readJsonFile = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf8'));
|
|
11
11
|
const buildArtifactPathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
12
|
-
const buildModulePathFor = (appDirectory)=>node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
13
12
|
const readBuildIdentity = async (appDirectory)=>{
|
|
14
13
|
const buildArtifactPath = buildArtifactPathFor(appDirectory);
|
|
15
14
|
if (existsSync(buildArtifactPath)) {
|
|
@@ -28,18 +27,7 @@ const readBuildIdentity = async (appDirectory)=>{
|
|
|
28
27
|
sourceRevision: deliveryUnit.sourceRevision
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
if (!existsSync(buildModulePath)) return {};
|
|
33
|
-
console.warn(`[backend-federation-build] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ${ULTRAMODERN_BUILD_ARTIFACT_FILE}.`);
|
|
34
|
-
const source = await promises.readFile(buildModulePath, 'utf8');
|
|
35
|
-
return {
|
|
36
|
-
appId: source.match(/\bappId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
37
|
-
buildVersion: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
38
|
-
packageName: source.match(/\bpackageName:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
39
|
-
version: source.match(/\bversion:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
40
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
41
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
42
|
-
};
|
|
30
|
+
throw new Error(`[backend-federation-build] Missing delivery-unit build artifact at ${buildArtifactPath}.`);
|
|
43
31
|
};
|
|
44
32
|
const toPascalCase = (value)=>value.split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
|
|
45
33
|
const stringValue = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
|
|
@@ -126,4 +114,4 @@ const findBackendFederationApp = async (workspaceRoot, appDirectory)=>{
|
|
|
126
114
|
if (resolved) return resolved;
|
|
127
115
|
}
|
|
128
116
|
};
|
|
129
|
-
export { COMPACT_CONFIG_PATH, buildArtifactPathFor,
|
|
117
|
+
export { COMPACT_CONFIG_PATH, buildArtifactPathFor, createAppFromCompactMetadata, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, normalizeRelativePath, readBuildIdentity, resolveWorkspaceSourceRevision };
|
|
@@ -6,7 +6,7 @@ import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensio
|
|
|
6
6
|
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, stampUltramodernBuildArtifactIdentity } from "@modern-js/backend-federation-contracts";
|
|
7
7
|
import { createBackendFederationEntryIntegrity } from "@modern-js/server-runtime-extensions/backend-federation-security/node";
|
|
8
8
|
import { createBackendManifest, createBackendRemoteEntrySource } from "./codegen.mjs";
|
|
9
|
-
import { COMPACT_CONFIG_PATH, buildArtifactPathFor,
|
|
9
|
+
import { COMPACT_CONFIG_PATH, buildArtifactPathFor, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, readBuildIdentity, resolveWorkspaceSourceRevision } from "./config.mjs";
|
|
10
10
|
const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
11
11
|
const workspaceRoot = findWorkspaceRoot(appDirectory);
|
|
12
12
|
if (!workspaceRoot) return;
|
|
@@ -21,7 +21,7 @@ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
|
21
21
|
const hasBuildIdentity = void 0 !== buildIdentity.unitId || void 0 !== buildIdentity.buildVersion || void 0 !== buildIdentity.packageName || void 0 !== buildIdentity.version;
|
|
22
22
|
if (hasBuildIdentity) {
|
|
23
23
|
const compactConfigPath = node_path.join(workspaceRoot, COMPACT_CONFIG_PATH);
|
|
24
|
-
const buildIdentityPath =
|
|
24
|
+
const buildIdentityPath = buildArtifactPathFor(appDirectory);
|
|
25
25
|
const mismatches = [];
|
|
26
26
|
const compare = (label, a, b, leftLabel = 'deliveryUnit')=>{
|
|
27
27
|
if (void 0 !== a && void 0 !== b && a !== b) mismatches.push(`${label}: ${leftLabel}=${a} vs ultramodern-build=${b}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import node_path from "node:path";
|
|
3
|
-
import { ULTRAMODERN_BUILD_ARTIFACT_PATH,
|
|
3
|
+
import { ULTRAMODERN_BUILD_ARTIFACT_PATH, isUltramodernBuildArtifact, nonEmptyString, toDeliveryUnitIdentity } from "@modern-js/backend-federation-contracts";
|
|
4
4
|
import { fs } from "@modern-js/utils";
|
|
5
5
|
import { resolveUltramodernReleaseIdentity } from "../release-identity.mjs";
|
|
6
6
|
import { isRecord } from "./utils.mjs";
|
|
@@ -88,20 +88,11 @@ const resolveTopologyDeliveryUnit = async (appDirectory)=>{
|
|
|
88
88
|
};
|
|
89
89
|
const resolveWorkerDeliveryUnitStamp = async (appDirectory)=>{
|
|
90
90
|
const buildArtifactPath = node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
91
|
-
const buildModulePath = node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
92
91
|
let identity;
|
|
93
92
|
if (await fs.pathExists(buildArtifactPath)) {
|
|
94
93
|
const artifact = await fs.readJSON(buildArtifactPath);
|
|
95
94
|
if (!isUltramodernBuildArtifact(artifact)) return;
|
|
96
95
|
identity = toDeliveryUnitIdentity(artifact.deliveryUnit);
|
|
97
|
-
} else if (await fs.pathExists(buildModulePath)) {
|
|
98
|
-
console.warn(`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`);
|
|
99
|
-
const source = await fs.readFile(buildModulePath, 'utf8');
|
|
100
|
-
identity = toDeliveryUnitIdentity({
|
|
101
|
-
buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
102
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
103
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
104
|
-
});
|
|
105
96
|
}
|
|
106
97
|
if (!identity) return;
|
|
107
98
|
const resolved = await resolveCompactApp(appDirectory);
|
|
@@ -87,7 +87,6 @@ export type BackendFederationBuildIdentity = {
|
|
|
87
87
|
};
|
|
88
88
|
export declare const normalizeRelativePath: (value: string) => string;
|
|
89
89
|
export declare const buildArtifactPathFor: (appDirectory: string) => string;
|
|
90
|
-
export declare const buildModulePathFor: (appDirectory: string) => string;
|
|
91
90
|
export declare const readBuildIdentity: (appDirectory: string) => Promise<BackendFederationBuildIdentity>;
|
|
92
91
|
export declare const findWorkspaceRoot: (appDirectory: string) => string | undefined;
|
|
93
92
|
export declare const resolveWorkspaceSourceRevision: (workspaceRoot: string) => Promise<string>;
|
|
@@ -17,7 +17,7 @@ export type DeliveryUnitStamp = DeliveryUnitIdentity & {
|
|
|
17
17
|
export declare const resolveTopologyDeliveryUnit: (appDirectory: string) => Promise<DeliveryUnitStamp | undefined>;
|
|
18
18
|
/**
|
|
19
19
|
* Resolve the delivery-unit identity actually bundled into the worker by
|
|
20
|
-
*
|
|
20
|
+
* reading the generated `shared/ultramodern-build.json` artifact. This is the
|
|
21
21
|
* worker snapshot / declared surface source that gets stamped into the manifest.
|
|
22
22
|
*/
|
|
23
23
|
export declare const resolveWorkerDeliveryUnitStamp: (appDirectory: string) => Promise<DeliveryUnitStamp | undefined>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/solutions/app-tools-extensions"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"version": "3.9.0-ultramodern.
|
|
14
|
+
"version": "3.9.0-ultramodern.7",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"src"
|
|
@@ -135,13 +135,13 @@
|
|
|
135
135
|
"@babel/parser": "^8.0.4",
|
|
136
136
|
"@babel/traverse": "^8.0.4",
|
|
137
137
|
"@loadable/component": "5.16.7",
|
|
138
|
-
"@modern-js/backend-federation-contracts": "npm:@bleedingdev/modern-js-backend-federation-contracts@3.9.0-ultramodern.
|
|
139
|
-
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.
|
|
140
|
-
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.
|
|
141
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.
|
|
142
|
-
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.
|
|
143
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
144
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
138
|
+
"@modern-js/backend-federation-contracts": "npm:@bleedingdev/modern-js-backend-federation-contracts@3.9.0-ultramodern.7",
|
|
139
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.7",
|
|
140
|
+
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.7",
|
|
141
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.7",
|
|
142
|
+
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.7",
|
|
143
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.7",
|
|
144
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.7",
|
|
145
145
|
"@swc/helpers": "^0.5.23",
|
|
146
146
|
"compression-webpack-plugin": "^12.0.0",
|
|
147
147
|
"esbuild": "^0.28.2",
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"@rsbuild/core": "2.2.3"
|
|
152
152
|
},
|
|
153
153
|
"devDependencies": {
|
|
154
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.
|
|
155
|
-
"@modern-js/plugin-bff-extensions": "npm:@bleedingdev/modern-js-plugin-bff-extensions@3.9.0-ultramodern.
|
|
154
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.7",
|
|
155
|
+
"@modern-js/plugin-bff-extensions": "npm:@bleedingdev/modern-js-plugin-bff-extensions@3.9.0-ultramodern.7",
|
|
156
156
|
"@module-federation/runtime-tools": "2.9.0",
|
|
157
157
|
"@rsbuild/core": "2.2.3",
|
|
158
158
|
"@rslib/core": "1.0.0",
|
|
@@ -12,9 +12,7 @@ import {
|
|
|
12
12
|
type DeliveryUnitRecord,
|
|
13
13
|
deliveryUnitContractBlock,
|
|
14
14
|
isUltramodernBuildArtifact,
|
|
15
|
-
ULTRAMODERN_BUILD_ARTIFACT_FILE,
|
|
16
15
|
ULTRAMODERN_BUILD_ARTIFACT_PATH,
|
|
17
|
-
ULTRAMODERN_BUILD_MODULE_PATH,
|
|
18
16
|
type UltramodernBuildArtifact,
|
|
19
17
|
validateDeliveryUnitRecord,
|
|
20
18
|
validateUltramodernBuildArtifact,
|
|
@@ -123,9 +121,6 @@ const readJsonFile = async <T>(filePath: string): Promise<T> =>
|
|
|
123
121
|
export const buildArtifactPathFor = (appDirectory: string) =>
|
|
124
122
|
path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
125
123
|
|
|
126
|
-
export const buildModulePathFor = (appDirectory: string) =>
|
|
127
|
-
path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
128
|
-
|
|
129
124
|
export const readBuildIdentity = async (
|
|
130
125
|
appDirectory: string,
|
|
131
126
|
): Promise<BackendFederationBuildIdentity> => {
|
|
@@ -159,24 +154,9 @@ export const readBuildIdentity = async (
|
|
|
159
154
|
};
|
|
160
155
|
}
|
|
161
156
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
console.warn(
|
|
168
|
-
`[backend-federation-build] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ${ULTRAMODERN_BUILD_ARTIFACT_FILE}.`,
|
|
157
|
+
throw new Error(
|
|
158
|
+
`[backend-federation-build] Missing delivery-unit build artifact at ${buildArtifactPath}.`,
|
|
169
159
|
);
|
|
170
|
-
|
|
171
|
-
const source = await fs.readFile(buildModulePath, 'utf8');
|
|
172
|
-
return {
|
|
173
|
-
appId: source.match(/\bappId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
174
|
-
buildVersion: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
175
|
-
packageName: source.match(/\bpackageName:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
176
|
-
version: source.match(/\bversion:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
177
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
178
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
179
|
-
};
|
|
180
160
|
};
|
|
181
161
|
|
|
182
162
|
const toPascalCase = (value: string) =>
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
type BackendFederationApp,
|
|
18
18
|
buildArtifactPathFor,
|
|
19
|
-
buildModulePathFor,
|
|
20
19
|
COMPACT_CONFIG_PATH,
|
|
21
20
|
createStampedDeliveryUnit,
|
|
22
21
|
findBackendFederationApp,
|
|
@@ -74,9 +73,7 @@ export const emitBackendFederationArtifacts = async (
|
|
|
74
73
|
|
|
75
74
|
if (hasBuildIdentity) {
|
|
76
75
|
const compactConfigPath = path.join(workspaceRoot, COMPACT_CONFIG_PATH);
|
|
77
|
-
const buildIdentityPath =
|
|
78
|
-
? buildArtifactPathFor(appDirectory)
|
|
79
|
-
: buildModulePathFor(appDirectory);
|
|
76
|
+
const buildIdentityPath = buildArtifactPathFor(appDirectory);
|
|
80
77
|
const mismatches: string[] = [];
|
|
81
78
|
const compare = (
|
|
82
79
|
label: string,
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
nonEmptyString,
|
|
6
6
|
toDeliveryUnitIdentity,
|
|
7
7
|
ULTRAMODERN_BUILD_ARTIFACT_PATH,
|
|
8
|
-
ULTRAMODERN_BUILD_MODULE_PATH,
|
|
9
8
|
} from '@modern-js/backend-federation-contracts';
|
|
10
9
|
import { fs as fse } from '@modern-js/utils';
|
|
11
10
|
import { resolveUltramodernReleaseIdentity } from '../release-identity';
|
|
@@ -148,7 +147,7 @@ export const resolveTopologyDeliveryUnit = async (
|
|
|
148
147
|
|
|
149
148
|
/**
|
|
150
149
|
* Resolve the delivery-unit identity actually bundled into the worker by
|
|
151
|
-
*
|
|
150
|
+
* reading the generated `shared/ultramodern-build.json` artifact. This is the
|
|
152
151
|
* worker snapshot / declared surface source that gets stamped into the manifest.
|
|
153
152
|
*/
|
|
154
153
|
export const resolveWorkerDeliveryUnitStamp = async (
|
|
@@ -158,10 +157,6 @@ export const resolveWorkerDeliveryUnitStamp = async (
|
|
|
158
157
|
appDirectory,
|
|
159
158
|
ULTRAMODERN_BUILD_ARTIFACT_PATH,
|
|
160
159
|
);
|
|
161
|
-
const buildModulePath = path.join(
|
|
162
|
-
appDirectory,
|
|
163
|
-
ULTRAMODERN_BUILD_MODULE_PATH,
|
|
164
|
-
);
|
|
165
160
|
let identity: DeliveryUnitIdentity | undefined;
|
|
166
161
|
|
|
167
162
|
if (await fse.pathExists(buildArtifactPath)) {
|
|
@@ -170,18 +165,6 @@ export const resolveWorkerDeliveryUnitStamp = async (
|
|
|
170
165
|
return undefined;
|
|
171
166
|
}
|
|
172
167
|
identity = toDeliveryUnitIdentity(artifact.deliveryUnit);
|
|
173
|
-
} else if (await fse.pathExists(buildModulePath)) {
|
|
174
|
-
console.warn(
|
|
175
|
-
`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`,
|
|
176
|
-
);
|
|
177
|
-
const source = await fse.readFile(buildModulePath, 'utf8');
|
|
178
|
-
identity = toDeliveryUnitIdentity({
|
|
179
|
-
buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
180
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
181
|
-
sourceRevision: source.match(
|
|
182
|
-
/\bsourceRevision:\s*['"]([^'"]+)['"]/u,
|
|
183
|
-
)?.[1],
|
|
184
|
-
});
|
|
185
168
|
}
|
|
186
169
|
|
|
187
170
|
if (!identity) {
|