@bleedingdev/modern-js-app-tools 3.9.0-ultramodern.4 → 3.9.0-ultramodern.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/builder/generator/index.js +0 -1
  2. package/dist/cjs/builder/shared/builderPlugins/index.js +4 -11
  3. package/dist/cjs/config/index.js +4 -11
  4. package/dist/cjs/index.js +80 -111
  5. package/dist/cjs/plugins/deploy/platforms/node.js +0 -13
  6. package/dist/cjs/plugins/serverBuild.js +2 -1
  7. package/dist/esm/builder/generator/index.mjs +1 -2
  8. package/dist/esm/builder/shared/builderPlugins/index.mjs +0 -1
  9. package/dist/esm/config/index.mjs +0 -1
  10. package/dist/esm/index.mjs +1 -6
  11. package/dist/esm/plugins/deploy/platforms/node.mjs +0 -13
  12. package/dist/esm/plugins/serverBuild.mjs +2 -1
  13. package/dist/esm-node/builder/generator/index.mjs +1 -2
  14. package/dist/esm-node/builder/shared/builderPlugins/index.mjs +0 -1
  15. package/dist/esm-node/config/index.mjs +0 -1
  16. package/dist/esm-node/index.mjs +1 -6
  17. package/dist/esm-node/plugins/deploy/platforms/node.mjs +0 -13
  18. package/dist/esm-node/plugins/serverBuild.mjs +2 -1
  19. package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -1
  20. package/dist/types/config/index.d.ts +0 -1
  21. package/dist/types/index.d.ts +0 -1
  22. package/dist/types/plugins/deploy/utils/generator.d.ts +1 -1
  23. package/dist/types/types/config/output.d.ts +0 -9
  24. package/dist/types/types/index.d.ts +1 -1
  25. package/dist/types/types/plugin.d.ts +56 -2
  26. package/dist/types/utils/initAppContext.d.ts +3 -2
  27. package/docs/configure/app/bff/effect.md +27 -21
  28. package/docs/guides/advanced-features/bff/data-platform.md +2 -2
  29. package/docs/guides/advanced-features/bff/frameworks.md +27 -20
  30. package/docs/guides/advanced-features/bff/function.md +2 -2
  31. package/docs/guides/advanced-features/bff/operators.md +17 -17
  32. package/docs/guides/get-started/quick-start.md +1 -5
  33. package/docs/guides/get-started/ultramodern.md +1 -1
  34. package/docs/llms.txt +2 -2
  35. package/package.json +14 -30
  36. package/rslib.config.mts +0 -5
  37. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +0 -125
  38. package/dist/cjs/config/build-environment.js +0 -268
  39. package/dist/cjs/config/public.js +0 -46
  40. package/dist/cjs/plugins/backend-federation/codegen.js +0 -256
  41. package/dist/cjs/plugins/backend-federation/config.js +0 -204
  42. package/dist/cjs/plugins/backend-federation/emit.js +0 -150
  43. package/dist/cjs/plugins/backendFederationBuild.js +0 -53
  44. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +0 -62
  45. package/dist/cjs/plugins/deploy/utils/npmAliases.js +0 -226
  46. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +0 -44
  47. package/dist/cjs/presetUltramodern.js +0 -175
  48. package/dist/cjs/types/config/precompress.js +0 -18
  49. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +0 -77
  50. package/dist/esm/config/build-environment.mjs +0 -224
  51. package/dist/esm/config/public.mjs +0 -1
  52. package/dist/esm/plugins/backend-federation/codegen.mjs +0 -205
  53. package/dist/esm/plugins/backend-federation/config.mjs +0 -128
  54. package/dist/esm/plugins/backend-federation/emit.mjs +0 -99
  55. package/dist/esm/plugins/backendFederationBuild.mjs +0 -1
  56. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +0 -1
  57. package/dist/esm/plugins/deploy/utils/npmAliases.mjs +0 -174
  58. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +0 -6
  59. package/dist/esm/presetUltramodern.mjs +0 -119
  60. package/dist/esm/types/config/precompress.mjs +0 -0
  61. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +0 -78
  62. package/dist/esm-node/config/build-environment.mjs +0 -225
  63. package/dist/esm-node/config/public.mjs +0 -2
  64. package/dist/esm-node/plugins/backend-federation/codegen.mjs +0 -206
  65. package/dist/esm-node/plugins/backend-federation/config.mjs +0 -129
  66. package/dist/esm-node/plugins/backend-federation/emit.mjs +0 -100
  67. package/dist/esm-node/plugins/backendFederationBuild.mjs +0 -2
  68. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +0 -2
  69. package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +0 -175
  70. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +0 -7
  71. package/dist/esm-node/presetUltramodern.mjs +0 -120
  72. package/dist/esm-node/types/config/precompress.mjs +0 -1
  73. package/dist/types/builder/shared/builderPlugins/adapterPrecompress.d.ts +0 -3
  74. package/dist/types/config/build-environment.d.ts +0 -22
  75. package/dist/types/config/public.d.ts +0 -2
  76. package/dist/types/plugins/backend-federation/codegen.d.ts +0 -86
  77. package/dist/types/plugins/backend-federation/config.d.ts +0 -103
  78. package/dist/types/plugins/backend-federation/emit.d.ts +0 -13
  79. package/dist/types/plugins/backendFederationBuild.d.ts +0 -2
  80. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +0 -1
  81. package/dist/types/plugins/deploy/utils/npmAliases.d.ts +0 -14
  82. package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +0 -3
  83. package/dist/types/precompress/LICENSE +0 -20
  84. package/dist/types/precompress/index.d.ts +0 -76
  85. package/dist/types/presetUltramodern.d.ts +0 -87
  86. package/dist/types/types/config/precompress.d.ts +0 -19
@@ -1,256 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, getters, values)=>{
14
- var define = (defs, kind)=>{
15
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
- enumerable: true,
17
- [kind]: defs[key]
18
- });
19
- };
20
- define(getters, "get");
21
- define(values, "value");
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- (()=>{
28
- __webpack_require__.r = (exports1)=>{
29
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
- value: 'Module'
31
- });
32
- Object.defineProperty(exports1, '__esModule', {
33
- value: true
34
- });
35
- };
36
- })();
37
- var __webpack_exports__ = {};
38
- __webpack_require__.r(__webpack_exports__);
39
- __webpack_require__.d(__webpack_exports__, {
40
- createBackendManifest: ()=>createBackendManifest,
41
- createBackendRemoteEntrySource: ()=>createBackendRemoteEntrySource
42
- });
43
- const external_node_path_namespaceObject = require("node:path");
44
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
45
- const universal_namespaceObject = require("@modern-js/utils/universal");
46
- const external_esbuild_namespaceObject = require("esbuild");
47
- const external_config_js_namespaceObject = require("./config.js");
48
- const createRelativeImportSpecifier = (fromDirectory, toFile)=>{
49
- const relativePath = (0, external_config_js_namespaceObject.normalizeRelativePath)(external_node_path_default().relative(fromDirectory, toFile));
50
- return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
51
- };
52
- const createPublicPath = (containerEntry, fallbackPort)=>{
53
- try {
54
- return new URL('.', containerEntry).href;
55
- } catch {
56
- const slashIndex = containerEntry.lastIndexOf('/');
57
- if (slashIndex >= 0) return containerEntry.slice(0, slashIndex + 1);
58
- return `http://localhost:${fallbackPort}/`;
59
- }
60
- };
61
- const createBackendRemoteEntrySource = async (workspaceRoot, app, effectApiPath, entryPath)=>{
62
- const effectApiSpecifier = createRelativeImportSpecifier(external_node_path_default().dirname(effectApiPath), effectApiPath);
63
- const containerMetadata = {
64
- buildVersion: app.buildVersion,
65
- expose: universal_namespaceObject.BACKEND_FEDERATION_EFFECT_EXPOSE,
66
- name: app.backendName,
67
- packageName: app.packageName,
68
- remoteType: app.remoteType,
69
- source: (0, external_config_js_namespaceObject.normalizeRelativePath)(external_node_path_default().relative(workspaceRoot, effectApiPath)),
70
- version: app.version,
71
- ...app.unitId ? {
72
- unitId: app.unitId
73
- } : {},
74
- ...app.sourceRevision ? {
75
- sourceRevision: app.sourceRevision
76
- } : {}
77
- };
78
- const compatibility = {
79
- build: app.buildVersion,
80
- contractVersion: universal_namespaceObject.BACKEND_FEDERATION_CONTRACT_VERSION,
81
- nodeAdapterVersion: universal_namespaceObject.BACKEND_FEDERATION_NODE_ADAPTER_VERSION,
82
- packageName: app.packageName,
83
- ...app.unitId ? {
84
- unitId: app.unitId
85
- } : {},
86
- ...app.sourceRevision ? {
87
- sourceRevision: app.sourceRevision
88
- } : {}
89
- };
90
- const source = `// Generated by Modern.js backend federation build.
91
- import * as exposedNamespace from ${JSON.stringify(effectApiSpecifier)};
92
-
93
- const exposedModule = {
94
- ...exposedNamespace,
95
- backendFederationContract: {
96
- ...(exposedNamespace.backendFederationContract ?? {}),
97
- compatibility: {
98
- ...(exposedNamespace.backendFederationContract?.compatibility ?? {}),
99
- ...${JSON.stringify(compatibility)},
100
- },
101
- name: ${JSON.stringify(app.backendName)},
102
- role: 'microvertical-server',
103
- runtimeFramework: 'effect',
104
- strictEffectApproach: true,
105
- },
106
- };
107
- const exposedModules = {
108
- ${JSON.stringify(universal_namespaceObject.BACKEND_FEDERATION_EFFECT_EXPOSE)}: () => Promise.resolve(exposedModule),
109
- };
110
- const __modernjsBackendFederation = ${JSON.stringify(containerMetadata)};
111
-
112
- function init() {}
113
-
114
- function get(id) {
115
- const load = exposedModules[id];
116
- if (!load) {
117
- throw new Error(\`Unexpected backend federation expose: \${id}\`);
118
- }
119
-
120
- return async () => load();
121
- }
122
-
123
- module.exports = { __modernjsBackendFederation, get, init };
124
- `;
125
- const result = await (0, external_esbuild_namespaceObject.build)({
126
- absWorkingDir: external_node_path_default().dirname(effectApiPath),
127
- bundle: true,
128
- format: 'cjs',
129
- logLevel: 'silent',
130
- platform: 'node',
131
- stdin: {
132
- contents: source,
133
- loader: 'ts',
134
- resolveDir: external_node_path_default().dirname(effectApiPath),
135
- sourcefile: external_node_path_default().basename(entryPath)
136
- },
137
- target: 'node20',
138
- write: false
139
- });
140
- const output = result.outputFiles[0];
141
- if (!output) throw new Error('[backend-federation-build] CommonJS backend federation container emitted no output.');
142
- return output.text;
143
- };
144
- const createBackendManifest = (workspaceRoot, distDirectory, app, entryIntegrity)=>{
145
- const sourceModule = `${app.directory}/api/effect-api.ts`;
146
- const publicPath = createPublicPath(app.containerEntry, app.port);
147
- const manifest = {
148
- schemaVersion: 1,
149
- id: app.backendName,
150
- name: app.backendName,
151
- version: app.version,
152
- buildVersion: app.buildVersion,
153
- metaData: {
154
- name: app.backendName,
155
- type: 'backend',
156
- buildInfo: {
157
- buildVersion: app.buildVersion,
158
- buildName: app.packageName
159
- },
160
- remoteEntry: {
161
- name: universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
162
- path: '',
163
- type: app.remoteType
164
- },
165
- globalName: app.backendName,
166
- publicPath,
167
- ssrRemoteEntry: {
168
- name: universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
169
- path: '',
170
- type: app.remoteType
171
- },
172
- ssrPublicPath: publicPath
173
- },
174
- entry: {
175
- ...entryIntegrity,
176
- file: universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
177
- path: (0, external_config_js_namespaceObject.normalizeRelativePath)(external_node_path_default().relative(workspaceRoot, external_node_path_default().join(distDirectory, universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE))),
178
- type: app.remoteType,
179
- url: app.containerEntry
180
- },
181
- exposes: [
182
- {
183
- id: `${app.backendName}:${universal_namespaceObject.BACKEND_FEDERATION_EFFECT_EXPOSE}`,
184
- name: universal_namespaceObject.BACKEND_FEDERATION_EFFECT_EXPOSE,
185
- path: '',
186
- assets: {
187
- js: {
188
- async: [],
189
- sync: [
190
- universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
191
- ]
192
- },
193
- css: {
194
- async: [],
195
- sync: []
196
- }
197
- }
198
- }
199
- ],
200
- shared: [],
201
- backendFederation: {
202
- role: 'microvertical-server',
203
- appId: app.id,
204
- name: app.backendName,
205
- runtimeFramework: 'effect',
206
- strictEffectApproach: true,
207
- contractVersion: universal_namespaceObject.BACKEND_FEDERATION_CONTRACT_VERSION,
208
- nodeAdapterVersion: universal_namespaceObject.BACKEND_FEDERATION_NODE_ADAPTER_VERSION,
209
- remoteType: app.remoteType,
210
- expose: universal_namespaceObject.BACKEND_FEDERATION_EFFECT_EXPOSE,
211
- manifestUrl: app.manifestUrl,
212
- containerEntry: app.containerEntry,
213
- source: {
214
- module: sourceModule
215
- },
216
- readinessPath: `${app.apiPrefix}/${app.apiStem}/readiness`,
217
- openapiPath: `${app.apiPrefix}/openapi.json`,
218
- ...app.deliveryUnit ? {
219
- deliveryUnit: app.deliveryUnit
220
- } : {},
221
- versionBoundary: {
222
- invariant: 'web-and-api-same-build',
223
- packageName: app.packageName,
224
- version: app.version,
225
- buildVersion: app.buildVersion,
226
- ...app.uiManifestUrl ? {
227
- uiManifestUrl: app.uiManifestUrl
228
- } : {},
229
- ...app.deliveryUnit ? {
230
- deliveryUnit: {
231
- unitId: app.deliveryUnit.unitId,
232
- buildMarker: app.deliveryUnit.buildMarker,
233
- sourceRevision: app.deliveryUnit.sourceRevision
234
- }
235
- } : {}
236
- }
237
- }
238
- };
239
- const validation = (0, universal_namespaceObject.validateBackendFederationManifest)(manifest, {
240
- path: 'backendFederationManifest',
241
- requireEffectExpose: true,
242
- requireEffectRuntime: true,
243
- requireVersionFields: true
244
- });
245
- if (!validation.ok) throw new Error(`[backend-federation-build] Invalid backend federation manifest: ${(0, universal_namespaceObject.formatBackendFederationValidationErrors)(validation.errors)}.`);
246
- return manifest;
247
- };
248
- exports.createBackendManifest = __webpack_exports__.createBackendManifest;
249
- exports.createBackendRemoteEntrySource = __webpack_exports__.createBackendRemoteEntrySource;
250
- for(var __rspack_i in __webpack_exports__)if (-1 === [
251
- "createBackendManifest",
252
- "createBackendRemoteEntrySource"
253
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
254
- Object.defineProperty(exports, '__esModule', {
255
- value: true
256
- });
@@ -1,204 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, getters, values)=>{
14
- var define = (defs, kind)=>{
15
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
- enumerable: true,
17
- [kind]: defs[key]
18
- });
19
- };
20
- define(getters, "get");
21
- define(values, "value");
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- (()=>{
28
- __webpack_require__.r = (exports1)=>{
29
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
- value: 'Module'
31
- });
32
- Object.defineProperty(exports1, '__esModule', {
33
- value: true
34
- });
35
- };
36
- })();
37
- var __webpack_exports__ = {};
38
- __webpack_require__.r(__webpack_exports__);
39
- __webpack_require__.d(__webpack_exports__, {
40
- COMPACT_CONFIG_PATH: ()=>COMPACT_CONFIG_PATH,
41
- buildArtifactPathFor: ()=>buildArtifactPathFor,
42
- buildModulePathFor: ()=>buildModulePathFor,
43
- createAppFromCompactMetadata: ()=>createAppFromCompactMetadata,
44
- createStampedDeliveryUnit: ()=>createStampedDeliveryUnit,
45
- findBackendFederationApp: ()=>findBackendFederationApp,
46
- findWorkspaceRoot: ()=>findWorkspaceRoot,
47
- normalizeRelativePath: ()=>normalizeRelativePath,
48
- readBuildIdentity: ()=>readBuildIdentity,
49
- resolveWorkspaceSourceRevision: ()=>resolveWorkspaceSourceRevision
50
- });
51
- const external_node_fs_namespaceObject = require("node:fs");
52
- const promises_namespaceObject = require("node:fs/promises");
53
- var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
54
- const external_node_path_namespaceObject = require("node:path");
55
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
56
- const release_identity_namespaceObject = require("@modern-js/app-tools-extensions/release-identity");
57
- const universal_namespaceObject = require("@modern-js/utils/universal");
58
- const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
59
- const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
60
- const isRecord = (value)=>'object' == typeof value && null !== value;
61
- const readJsonFile = async (filePath)=>JSON.parse(await promises_default().readFile(filePath, 'utf8'));
62
- const buildArtifactPathFor = (appDirectory)=>external_node_path_default().join(appDirectory, universal_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_PATH);
63
- const buildModulePathFor = (appDirectory)=>external_node_path_default().join(appDirectory, universal_namespaceObject.ULTRAMODERN_BUILD_MODULE_PATH);
64
- const readBuildIdentity = async (appDirectory)=>{
65
- const buildArtifactPath = buildArtifactPathFor(appDirectory);
66
- if ((0, external_node_fs_namespaceObject.existsSync)(buildArtifactPath)) {
67
- const artifact = await readJsonFile(buildArtifactPath);
68
- const artifactValidation = (0, universal_namespaceObject.validateUltramodernBuildArtifact)(artifact, buildArtifactPath);
69
- if (!artifactValidation.ok) throw new Error(`[backend-federation-build] Invalid delivery-unit build artifact at ${buildArtifactPath}.`);
70
- if (!(0, universal_namespaceObject.isUltramodernBuildArtifact)(artifact)) throw new Error(`[backend-federation-build] Invalid delivery-unit build artifact at ${buildArtifactPath}.`);
71
- const deliveryUnit = artifact.deliveryUnit;
72
- return {
73
- artifact,
74
- appId: deliveryUnit.appId,
75
- buildVersion: deliveryUnit.buildMarker,
76
- packageName: deliveryUnit.packageName,
77
- version: deliveryUnit.version,
78
- unitId: deliveryUnit.unitId,
79
- sourceRevision: deliveryUnit.sourceRevision
80
- };
81
- }
82
- const buildModulePath = buildModulePathFor(appDirectory);
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 ${universal_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
- };
94
- };
95
- const toPascalCase = (value)=>value.split(/[^a-zA-Z0-9]+/u).filter(Boolean).map((part)=>part.charAt(0).toUpperCase() + part.slice(1)).join('');
96
- const stringValue = (value)=>'string' == typeof value && value.length > 0 ? value : void 0;
97
- const createBackendName = (app, id)=>{
98
- const configuredName = stringValue(app.backendFederation?.name) ?? stringValue(app.backendFederation?.executionSurfaces?.node?.remoteName) ?? stringValue(app.serverExecution?.node?.remoteName);
99
- if (configuredName) return configuredName;
100
- const mfName = stringValue(app.moduleFederation?.name);
101
- return mfName ? `${mfName}Backend` : `vertical${toPascalCase(id)}Backend`;
102
- };
103
- const findWorkspaceRoot = (appDirectory)=>{
104
- let current = appDirectory;
105
- while(true){
106
- if ((0, external_node_fs_namespaceObject.existsSync)(external_node_path_default().join(current, COMPACT_CONFIG_PATH))) return current;
107
- const parent = external_node_path_default().dirname(current);
108
- if (parent === current) return;
109
- current = parent;
110
- }
111
- };
112
- const resolveWorkspaceSourceRevision = async (workspaceRoot)=>(0, release_identity_namespaceObject.resolveUltramodernSourceRevision)(workspaceRoot);
113
- const createStampedDeliveryUnit = (input)=>{
114
- if (!input.unitId || !input.buildMarker || !input.packageName || !input.version) return;
115
- const record = {
116
- schemaVersion: universal_namespaceObject.DELIVERY_UNIT_SCHEMA_VERSION,
117
- kind: universal_namespaceObject.DELIVERY_UNIT_KIND,
118
- appId: input.appId,
119
- unitId: input.unitId,
120
- packageName: input.packageName,
121
- version: input.version,
122
- buildMarker: input.buildMarker,
123
- sourceRevision: input.sourceRevision,
124
- deployProfile: universal_namespaceObject.DELIVERY_UNIT_DEPLOY_PROFILE
125
- };
126
- const validation = (0, universal_namespaceObject.validateDeliveryUnitRecord)(record);
127
- if (!validation.ok) return;
128
- return (0, universal_namespaceObject.deliveryUnitContractBlock)(record);
129
- };
130
- const createAppFromCompactMetadata = (workspaceRoot, appDirectory, compactApp)=>{
131
- const id = stringValue(compactApp.id);
132
- const appPath = stringValue(compactApp.path);
133
- if (!id || 'vertical' !== compactApp.kind || !isRecord(compactApp.api)) return;
134
- const directory = appPath ? normalizeRelativePath(appPath) : `verticals/${id}`;
135
- if (external_node_path_default().resolve(workspaceRoot, directory) !== external_node_path_default().resolve(appDirectory)) return;
136
- const port = 'number' == typeof compactApp.port ? compactApp.port : void 0;
137
- if (void 0 === port) return;
138
- const apiPrefix = stringValue(compactApp.api.prefix) ?? `/${id}-api`;
139
- const apiStem = stringValue(compactApp.api.stem) ?? id;
140
- const backendName = createBackendName(compactApp, id);
141
- const manifestUrl = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.manifestUrl) ?? stringValue(compactApp.serverExecution?.node?.manifestUrl) ?? `http://localhost:${port}/${universal_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE}`;
142
- const containerEntry = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.containerEntry) ?? stringValue(compactApp.serverExecution?.node?.containerEntry) ?? `http://localhost:${port}/${universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`;
143
- const configuredRemoteType = stringValue(compactApp.backendFederation?.executionSurfaces?.node?.remoteType) ?? stringValue(compactApp.serverExecution?.node?.remoteType);
144
- if (void 0 !== configuredRemoteType && 'commonjs-module' !== configuredRemoteType) throw new Error(`[backend-federation-build] Node backend federation remoteType must be "commonjs-module"; received "${configuredRemoteType}" for ${id}.`);
145
- if (!new URL(containerEntry).pathname.endsWith(`/${universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`)) throw new Error(`[backend-federation-build] Node backend federation containerEntry must end with "/${universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE}"; received "${containerEntry}" for ${id}.`);
146
- const remoteType = 'commonjs-module';
147
- const packageName = stringValue(compactApp.package);
148
- const uiManifestUrl = stringValue(compactApp.backendFederation?.versionBoundary?.ui?.manifestUrl) ?? stringValue(compactApp.moduleFederation?.manifestUrl);
149
- const compactDeliveryUnit = isRecord(compactApp.deliveryUnit) ? {
150
- unitId: stringValue(compactApp.deliveryUnit.unitId),
151
- buildMarker: stringValue(compactApp.deliveryUnit.buildMarker),
152
- sourceRevision: stringValue(compactApp.deliveryUnit.sourceRevision),
153
- packageName: stringValue(compactApp.deliveryUnit.packageName),
154
- version: stringValue(compactApp.deliveryUnit.version)
155
- } : void 0;
156
- return {
157
- id,
158
- directory,
159
- packageName,
160
- port,
161
- apiPrefix,
162
- apiStem,
163
- backendName,
164
- manifestUrl,
165
- containerEntry,
166
- remoteType,
167
- uiManifestUrl,
168
- compactDeliveryUnit
169
- };
170
- };
171
- const findBackendFederationApp = async (workspaceRoot, appDirectory)=>{
172
- const compactConfigPath = external_node_path_default().join(workspaceRoot, COMPACT_CONFIG_PATH);
173
- const compactConfig = await readJsonFile(compactConfigPath);
174
- const apps = Array.isArray(compactConfig.topology?.apps) ? compactConfig.topology.apps : [];
175
- for (const app of apps){
176
- const resolved = createAppFromCompactMetadata(workspaceRoot, appDirectory, app);
177
- if (resolved) return resolved;
178
- }
179
- };
180
- exports.COMPACT_CONFIG_PATH = __webpack_exports__.COMPACT_CONFIG_PATH;
181
- exports.buildArtifactPathFor = __webpack_exports__.buildArtifactPathFor;
182
- exports.buildModulePathFor = __webpack_exports__.buildModulePathFor;
183
- exports.createAppFromCompactMetadata = __webpack_exports__.createAppFromCompactMetadata;
184
- exports.createStampedDeliveryUnit = __webpack_exports__.createStampedDeliveryUnit;
185
- exports.findBackendFederationApp = __webpack_exports__.findBackendFederationApp;
186
- exports.findWorkspaceRoot = __webpack_exports__.findWorkspaceRoot;
187
- exports.normalizeRelativePath = __webpack_exports__.normalizeRelativePath;
188
- exports.readBuildIdentity = __webpack_exports__.readBuildIdentity;
189
- exports.resolveWorkspaceSourceRevision = __webpack_exports__.resolveWorkspaceSourceRevision;
190
- for(var __rspack_i in __webpack_exports__)if (-1 === [
191
- "COMPACT_CONFIG_PATH",
192
- "buildArtifactPathFor",
193
- "buildModulePathFor",
194
- "createAppFromCompactMetadata",
195
- "createStampedDeliveryUnit",
196
- "findBackendFederationApp",
197
- "findWorkspaceRoot",
198
- "normalizeRelativePath",
199
- "readBuildIdentity",
200
- "resolveWorkspaceSourceRevision"
201
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
202
- Object.defineProperty(exports, '__esModule', {
203
- value: true
204
- });
@@ -1,150 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, getters, values)=>{
14
- var define = (defs, kind)=>{
15
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
- enumerable: true,
17
- [kind]: defs[key]
18
- });
19
- };
20
- define(getters, "get");
21
- define(values, "value");
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- (()=>{
28
- __webpack_require__.r = (exports1)=>{
29
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
- value: 'Module'
31
- });
32
- Object.defineProperty(exports1, '__esModule', {
33
- value: true
34
- });
35
- };
36
- })();
37
- var __webpack_exports__ = {};
38
- __webpack_require__.r(__webpack_exports__);
39
- __webpack_require__.d(__webpack_exports__, {
40
- default: ()=>emit,
41
- emitBackendFederationArtifacts: ()=>emitBackendFederationArtifacts
42
- });
43
- const external_node_fs_namespaceObject = require("node:fs");
44
- const promises_namespaceObject = require("node:fs/promises");
45
- var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
46
- const external_node_path_namespaceObject = require("node:path");
47
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
48
- const release_identity_namespaceObject = require("@modern-js/app-tools-extensions/release-identity");
49
- const node_namespaceObject = require("@modern-js/server-runtime-extensions/backend-federation-security/node");
50
- const universal_namespaceObject = require("@modern-js/utils/universal");
51
- const external_codegen_js_namespaceObject = require("./codegen.js");
52
- const external_config_js_namespaceObject = require("./config.js");
53
- const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
54
- const workspaceRoot = (0, external_config_js_namespaceObject.findWorkspaceRoot)(appDirectory);
55
- if (!workspaceRoot) return;
56
- const effectApiPath = external_node_path_default().join(appDirectory, 'api/effect-api.ts');
57
- const backendFederationConfigPath = external_node_path_default().join(appDirectory, 'backend-federation.config.ts');
58
- if (!(0, external_node_fs_namespaceObject.existsSync)(effectApiPath) || !(0, external_node_fs_namespaceObject.existsSync)(backendFederationConfigPath)) return;
59
- const app = await (0, external_config_js_namespaceObject.findBackendFederationApp)(workspaceRoot, appDirectory);
60
- if (!app) return;
61
- const buildIdentity = await (0, external_config_js_namespaceObject.readBuildIdentity)(appDirectory);
62
- const compactDeliveryUnit = app.compactDeliveryUnit;
63
- const hasCompactDeliveryUnit = void 0 !== compactDeliveryUnit && (void 0 !== compactDeliveryUnit.unitId || void 0 !== compactDeliveryUnit.buildMarker || void 0 !== compactDeliveryUnit.packageName || void 0 !== compactDeliveryUnit.version);
64
- const hasBuildIdentity = void 0 !== buildIdentity.unitId || void 0 !== buildIdentity.buildVersion || void 0 !== buildIdentity.packageName || void 0 !== buildIdentity.version;
65
- if (hasBuildIdentity) {
66
- const compactConfigPath = external_node_path_default().join(workspaceRoot, external_config_js_namespaceObject.COMPACT_CONFIG_PATH);
67
- const buildIdentityPath = (0, external_node_fs_namespaceObject.existsSync)((0, external_config_js_namespaceObject.buildArtifactPathFor)(appDirectory)) ? (0, external_config_js_namespaceObject.buildArtifactPathFor)(appDirectory) : (0, external_config_js_namespaceObject.buildModulePathFor)(appDirectory);
68
- const mismatches = [];
69
- const compare = (label, a, b, leftLabel = 'deliveryUnit')=>{
70
- if (void 0 !== a && void 0 !== b && a !== b) mismatches.push(`${label}: ${leftLabel}=${a} vs ultramodern-build=${b}`);
71
- };
72
- compare('appId', app.id, buildIdentity.appId, 'topology');
73
- if (hasCompactDeliveryUnit) {
74
- compare('unitId', compactDeliveryUnit?.unitId, buildIdentity.unitId);
75
- compare('buildMarker/build', compactDeliveryUnit?.buildMarker, buildIdentity.buildVersion);
76
- compare('packageName', compactDeliveryUnit?.packageName, buildIdentity.packageName);
77
- compare('version', compactDeliveryUnit?.version, buildIdentity.version);
78
- }
79
- if (mismatches.length > 0) throw new Error(`[backend-federation-build] Delivery-unit identity drift between ${compactConfigPath} (topology) and ${buildIdentityPath}: ${mismatches.join('; ')}`);
80
- }
81
- const unitId = compactDeliveryUnit?.unitId ?? buildIdentity.unitId;
82
- const generationBuildMarker = compactDeliveryUnit?.buildMarker ?? buildIdentity.buildVersion;
83
- const sourceRevision = await (0, external_config_js_namespaceObject.resolveWorkspaceSourceRevision)(workspaceRoot);
84
- const buildVersion = generationBuildMarker && unitId ? (0, release_identity_namespaceObject.resolveUltramodernReleaseIdentity)({
85
- generationBuildMarker,
86
- unitId,
87
- workspaceRoot
88
- }).buildMarker : void 0;
89
- const packageName = compactDeliveryUnit?.packageName ?? buildIdentity.packageName ?? app.packageName;
90
- const version = compactDeliveryUnit?.version ?? buildIdentity.version;
91
- const deliveryUnit = (0, external_config_js_namespaceObject.createStampedDeliveryUnit)({
92
- appId: app.id,
93
- unitId,
94
- buildMarker: buildVersion,
95
- packageName,
96
- version,
97
- sourceRevision
98
- });
99
- const stampedBuildArtifact = buildIdentity.artifact ? (0, universal_namespaceObject.stampUltramodernBuildArtifactIdentity)(buildIdentity.artifact, {
100
- buildMarker: buildVersion ?? buildIdentity.artifact.deliveryUnit.buildMarker,
101
- sourceRevision
102
- }) : void 0;
103
- const resolvedApp = {
104
- ...app,
105
- packageName,
106
- version,
107
- buildVersion,
108
- unitId,
109
- sourceRevision,
110
- deliveryUnit
111
- };
112
- const manifestPath = external_node_path_default().join(distDirectory, universal_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE);
113
- const entryPath = external_node_path_default().join(distDirectory, universal_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
114
- const deliveryUnitArtifactPath = stampedBuildArtifact ? external_node_path_default().join(distDirectory, universal_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE) : void 0;
115
- const entrySource = await (0, external_codegen_js_namespaceObject.createBackendRemoteEntrySource)(workspaceRoot, resolvedApp, effectApiPath, entryPath);
116
- await promises_default().mkdir(distDirectory, {
117
- recursive: true
118
- });
119
- await promises_default().writeFile(entryPath, entrySource);
120
- await promises_default().writeFile(manifestPath, `${JSON.stringify((0, external_codegen_js_namespaceObject.createBackendManifest)(workspaceRoot, distDirectory, resolvedApp, (0, node_namespaceObject.createBackendFederationEntryIntegrity)(entrySource)), null, 2)}\n`);
121
- if (stampedBuildArtifact && deliveryUnitArtifactPath) await promises_default().writeFile(deliveryUnitArtifactPath, `${JSON.stringify(stampedBuildArtifact, null, 2)}\n`);
122
- return {
123
- appId: resolvedApp.id,
124
- manifestPath,
125
- containerPath: entryPath,
126
- ...deliveryUnitArtifactPath ? {
127
- deliveryUnitArtifactPath
128
- } : {},
129
- remoteName: resolvedApp.backendName,
130
- remoteType: resolvedApp.remoteType
131
- };
132
- };
133
- const emit = ()=>({
134
- name: '@modern-js/backend-federation-build',
135
- setup (api) {
136
- api.onAfterBuild(async ()=>{
137
- const { appDirectory, distDirectory } = api.getAppContext();
138
- await emitBackendFederationArtifacts(appDirectory, distDirectory);
139
- });
140
- }
141
- });
142
- exports["default"] = __webpack_exports__["default"];
143
- exports.emitBackendFederationArtifacts = __webpack_exports__.emitBackendFederationArtifacts;
144
- for(var __rspack_i in __webpack_exports__)if (-1 === [
145
- "default",
146
- "emitBackendFederationArtifacts"
147
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
148
- Object.defineProperty(exports, '__esModule', {
149
- value: true
150
- });
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, getters, values)=>{
14
- var define = (defs, kind)=>{
15
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
- enumerable: true,
17
- [kind]: defs[key]
18
- });
19
- };
20
- define(getters, "get");
21
- define(values, "value");
22
- };
23
- })();
24
- (()=>{
25
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
- })();
27
- (()=>{
28
- __webpack_require__.r = (exports1)=>{
29
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
- value: 'Module'
31
- });
32
- Object.defineProperty(exports1, '__esModule', {
33
- value: true
34
- });
35
- };
36
- })();
37
- var __webpack_exports__ = {};
38
- __webpack_require__.r(__webpack_exports__);
39
- __webpack_require__.d(__webpack_exports__, {
40
- default: ()=>emit_js_default(),
41
- emitBackendFederationArtifacts: ()=>emit_js_namespaceObject.emitBackendFederationArtifacts
42
- });
43
- const emit_js_namespaceObject = require("./backend-federation/emit.js");
44
- var emit_js_default = /*#__PURE__*/ __webpack_require__.n(emit_js_namespaceObject);
45
- exports["default"] = __webpack_exports__["default"];
46
- exports.emitBackendFederationArtifacts = __webpack_exports__.emitBackendFederationArtifacts;
47
- for(var __rspack_i in __webpack_exports__)if (-1 === [
48
- "default",
49
- "emitBackendFederationArtifacts"
50
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
51
- Object.defineProperty(exports, '__esModule', {
52
- value: true
53
- });