@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.1 → 3.9.0-ultramodern.11
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 +256 -0
- package/dist/cjs/backend-federation-build/config.js +189 -0
- package/dist/cjs/backend-federation-build/emit.js +150 -0
- package/dist/cjs/backend-federation-build/index.js +53 -0
- package/dist/cjs/build-config/build-environment.js +268 -0
- package/dist/cjs/build-config/precompress/plugin.js +124 -0
- package/dist/cjs/build-config/precompress/types.js +18 -0
- package/dist/cjs/build-config/public.js +46 -0
- package/dist/cjs/cloudflare/constants.js +1 -1
- package/dist/cjs/cloudflare/delivery-unit.js +7 -16
- package/dist/cjs/cloudflare-output-contract.js +37 -1
- package/dist/cjs/cloudflare-output-verifier/identity.js +6 -6
- package/dist/cjs/cloudflare-output-verifier/worker-bundles.js +4 -1
- package/dist/cjs/config.js +29 -1
- package/dist/cjs/deploy-output/npmAliases.js +226 -0
- package/dist/cjs/deploy-output/plugin.js +76 -0
- package/dist/cjs/deploy-output/target.js +48 -0
- package/dist/cjs/native-type-checker.js +193 -0
- package/dist/cjs/policy-defaults.js +101 -0
- package/dist/cjs/release-envelope/framework-output.js +77 -32
- package/dist/cjs/release-envelope/plugin.js +5 -3
- package/dist/cjs/release-identity.js +3 -6
- package/dist/cjs/runtime-package-resolution.js +118 -0
- package/dist/esm/backend-federation-build/codegen.mjs +205 -0
- package/dist/esm/backend-federation-build/config.mjs +116 -0
- package/dist/esm/backend-federation-build/emit.mjs +99 -0
- package/dist/esm/backend-federation-build/index.mjs +1 -0
- package/dist/esm/build-config/build-environment.mjs +224 -0
- package/dist/esm/build-config/precompress/plugin.mjs +76 -0
- package/dist/esm/build-config/precompress/types.mjs +0 -0
- package/dist/esm/build-config/public.mjs +1 -0
- package/dist/esm/cloudflare/constants.mjs +1 -1
- package/dist/esm/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm/cloudflare-output-contract.mjs +35 -2
- package/dist/esm/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm/cloudflare-output-verifier/worker-bundles.mjs +5 -2
- package/dist/esm/config.mjs +1 -0
- package/dist/esm/deploy-output/npmAliases.mjs +174 -0
- package/dist/esm/deploy-output/plugin.mjs +28 -0
- package/dist/esm/deploy-output/target.mjs +10 -0
- package/dist/esm/native-type-checker.mjs +142 -0
- package/dist/esm/policy-defaults.mjs +45 -0
- package/dist/esm/release-envelope/framework-output.mjs +51 -6
- package/dist/esm/release-envelope/plugin.mjs +5 -3
- package/dist/esm/release-identity.mjs +3 -6
- package/dist/esm/runtime-package-resolution.mjs +60 -0
- package/dist/esm-node/backend-federation-build/codegen.mjs +206 -0
- package/dist/esm-node/backend-federation-build/config.mjs +117 -0
- package/dist/esm-node/backend-federation-build/emit.mjs +100 -0
- package/dist/esm-node/backend-federation-build/index.mjs +2 -0
- package/dist/esm-node/build-config/build-environment.mjs +225 -0
- package/dist/esm-node/build-config/precompress/plugin.mjs +77 -0
- package/dist/esm-node/build-config/precompress/types.mjs +1 -0
- package/dist/esm-node/build-config/public.mjs +2 -0
- package/dist/esm-node/cloudflare/constants.mjs +1 -1
- package/dist/esm-node/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm-node/cloudflare-output-contract.mjs +35 -2
- package/dist/esm-node/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm-node/cloudflare-output-verifier/worker-bundles.mjs +5 -2
- package/dist/esm-node/config.mjs +1 -0
- package/dist/esm-node/deploy-output/npmAliases.mjs +175 -0
- package/dist/esm-node/deploy-output/plugin.mjs +31 -0
- package/dist/esm-node/deploy-output/target.mjs +11 -0
- package/dist/esm-node/native-type-checker.mjs +143 -0
- package/dist/esm-node/policy-defaults.mjs +46 -0
- package/dist/esm-node/release-envelope/framework-output.mjs +51 -6
- package/dist/esm-node/release-envelope/plugin.mjs +5 -3
- package/dist/esm-node/release-identity.mjs +3 -6
- package/dist/esm-node/runtime-package-resolution.mjs +61 -0
- package/dist/types/backend-federation-build/codegen.d.ts +86 -0
- package/dist/types/backend-federation-build/config.d.ts +102 -0
- package/dist/types/backend-federation-build/emit.d.ts +21 -0
- package/dist/types/backend-federation-build/index.d.ts +2 -0
- package/dist/types/build-config/build-environment.d.ts +22 -0
- package/dist/types/build-config/precompress/plugin.d.ts +4 -0
- package/dist/types/build-config/precompress/types.d.ts +19 -0
- package/dist/types/build-config/public.d.ts +2 -0
- package/dist/types/cloudflare/constants.d.ts +1 -1
- package/dist/types/cloudflare/delivery-unit.d.ts +2 -2
- package/dist/types/cloudflare/worker-manifest.d.ts +2 -2
- package/dist/types/cloudflare-output-contract.d.ts +2 -1
- package/dist/types/cloudflare-output-verifier/identity.d.ts +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/deploy-output/npmAliases.d.ts +14 -0
- package/dist/types/deploy-output/plugin.d.ts +15 -0
- package/dist/types/deploy-output/target.d.ts +6 -0
- package/dist/types/native-type-checker.d.ts +15 -0
- package/dist/types/policy-defaults.d.ts +46 -0
- package/dist/types/precompress/LICENSE +20 -0
- package/dist/types/precompress/index.d.ts +76 -0
- package/dist/types/release-envelope/framework-output.d.ts +2 -1
- package/dist/types/runtime-package-resolution.d.ts +28 -0
- package/package.json +71 -13
- package/src/backend-federation-build/codegen.ts +245 -0
- package/src/backend-federation-build/config.ts +356 -0
- package/src/backend-federation-build/emit.ts +202 -0
- package/src/backend-federation-build/index.ts +2 -0
- package/src/build-config/build-environment.ts +404 -0
- package/src/build-config/precompress/plugin.ts +140 -0
- package/src/build-config/precompress/types.ts +26 -0
- package/src/build-config/public.ts +6 -0
- package/src/cloudflare/constants.ts +1 -1
- package/src/cloudflare/delivery-unit.ts +3 -20
- package/src/cloudflare/worker-manifest.ts +1 -0
- package/src/cloudflare-builder.ts +1 -0
- package/src/cloudflare-output-contract.ts +37 -0
- package/src/cloudflare-output-verifier/identity.ts +1 -1
- package/src/cloudflare-output-verifier/worker-bundles.ts +5 -3
- package/src/config.ts +7 -0
- package/src/deploy-output/npmAliases.ts +333 -0
- package/src/deploy-output/plugin.ts +49 -0
- package/src/deploy-output/target.ts +23 -0
- package/src/native-type-checker.ts +183 -0
- package/src/policy-defaults.ts +127 -0
- package/src/release-envelope/framework-output.ts +135 -4
- package/src/release-envelope/plugin.ts +15 -3
- package/src/release-identity.ts +3 -2
- package/src/runtime-package-resolution.ts +115 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
5
|
+
var __webpack_require__ = {};
|
|
6
|
+
(()=>{
|
|
7
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
8
|
+
var define = (defs, kind)=>{
|
|
9
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
[kind]: defs[key]
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
define(getters, "get");
|
|
15
|
+
define(values, "value");
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
20
|
+
})();
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.r = (exports1)=>{
|
|
23
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
24
|
+
value: 'Module'
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
27
|
+
value: true
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
var __webpack_exports__ = {};
|
|
32
|
+
__webpack_require__.r(__webpack_exports__);
|
|
33
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
+
POLICY_DEFAULTS_PLUGIN_NAME: ()=>POLICY_DEFAULTS_PLUGIN_NAME,
|
|
35
|
+
RENDERER_EXTENSIONS_PACKAGE: ()=>RENDERER_EXTENSIONS_PACKAGE,
|
|
36
|
+
RENDERER_EXTENSIONS_PLUGIN_NAME: ()=>RENDERER_EXTENSIONS_PLUGIN_NAME,
|
|
37
|
+
SERVER_EXTENSIONS_PLUGIN_NAME: ()=>SERVER_EXTENSIONS_PLUGIN_NAME,
|
|
38
|
+
applyPolicyDefaults: ()=>applyPolicyDefaults,
|
|
39
|
+
createPolicyDefaultsPlugin: ()=>createPolicyDefaultsPlugin
|
|
40
|
+
});
|
|
41
|
+
const external_runtime_package_resolution_js_namespaceObject = require("./runtime-package-resolution.js");
|
|
42
|
+
const RENDERER_EXTENSIONS_PACKAGE = '@modern-js/runtime-renderer-extensions';
|
|
43
|
+
const RENDERER_EXTENSIONS_PLUGIN_NAME = 'rendererHead';
|
|
44
|
+
const SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/app-tools/server-plugin';
|
|
45
|
+
const POLICY_DEFAULTS_PLUGIN_NAME = '@modern-js/ultramodern-policy-defaults';
|
|
46
|
+
const applyPolicyDefaults = (api, options = {})=>{
|
|
47
|
+
if (false !== options.rendererExtensions) {
|
|
48
|
+
api._internalRuntimePlugins(({ entrypoint, plugins })=>{
|
|
49
|
+
if (!plugins.some((plugin)=>plugin.path === RENDERER_EXTENSIONS_PACKAGE)) plugins.push({
|
|
50
|
+
name: RENDERER_EXTENSIONS_PLUGIN_NAME,
|
|
51
|
+
path: RENDERER_EXTENSIONS_PACKAGE,
|
|
52
|
+
config: {}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
entrypoint,
|
|
56
|
+
plugins
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const moduleDirectories = (0, external_runtime_package_resolution_js_namespaceObject.collectRuntimePackageModuleDirectories)([
|
|
60
|
+
RENDERER_EXTENSIONS_PACKAGE
|
|
61
|
+
], __rslib_import_meta_url__);
|
|
62
|
+
if (moduleDirectories.length > 0) api.modifyResolvedConfig((config)=>({
|
|
63
|
+
...config,
|
|
64
|
+
builderPlugins: [
|
|
65
|
+
...config.builderPlugins ?? [],
|
|
66
|
+
(0, external_runtime_package_resolution_js_namespaceObject.createRuntimePackageResolutionPlugin)(moduleDirectories)
|
|
67
|
+
]
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
if (false !== options.serverExtensions) api._internalServerPlugins(({ plugins })=>{
|
|
71
|
+
if (!plugins.some((plugin)=>plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME)) plugins.push({
|
|
72
|
+
name: SERVER_EXTENSIONS_PLUGIN_NAME
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
plugins
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const createPolicyDefaultsPlugin = (options = {})=>({
|
|
80
|
+
name: POLICY_DEFAULTS_PLUGIN_NAME,
|
|
81
|
+
setup (api) {
|
|
82
|
+
applyPolicyDefaults(api, options);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
exports.POLICY_DEFAULTS_PLUGIN_NAME = __webpack_exports__.POLICY_DEFAULTS_PLUGIN_NAME;
|
|
86
|
+
exports.RENDERER_EXTENSIONS_PACKAGE = __webpack_exports__.RENDERER_EXTENSIONS_PACKAGE;
|
|
87
|
+
exports.RENDERER_EXTENSIONS_PLUGIN_NAME = __webpack_exports__.RENDERER_EXTENSIONS_PLUGIN_NAME;
|
|
88
|
+
exports.SERVER_EXTENSIONS_PLUGIN_NAME = __webpack_exports__.SERVER_EXTENSIONS_PLUGIN_NAME;
|
|
89
|
+
exports.applyPolicyDefaults = __webpack_exports__.applyPolicyDefaults;
|
|
90
|
+
exports.createPolicyDefaultsPlugin = __webpack_exports__.createPolicyDefaultsPlugin;
|
|
91
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
92
|
+
"POLICY_DEFAULTS_PLUGIN_NAME",
|
|
93
|
+
"RENDERER_EXTENSIONS_PACKAGE",
|
|
94
|
+
"RENDERER_EXTENSIONS_PLUGIN_NAME",
|
|
95
|
+
"SERVER_EXTENSIONS_PLUGIN_NAME",
|
|
96
|
+
"applyPolicyDefaults",
|
|
97
|
+
"createPolicyDefaultsPlugin"
|
|
98
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
99
|
+
Object.defineProperty(exports, '__esModule', {
|
|
100
|
+
value: true
|
|
101
|
+
});
|
|
@@ -53,7 +53,7 @@ const promises_namespaceObject = require("node:fs/promises");
|
|
|
53
53
|
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
54
54
|
const external_node_path_namespaceObject = require("node:path");
|
|
55
55
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
56
|
-
const
|
|
56
|
+
const backend_federation_contracts_namespaceObject = require("@modern-js/backend-federation-contracts");
|
|
57
57
|
const external_index_js_namespaceObject = require("./index.js");
|
|
58
58
|
const MICROVERTICAL_RELEASE_ENVELOPE_PATH = 'release/microvertical-release-envelope.json';
|
|
59
59
|
const MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH = 'release/microvertical-release-identity-carriers.json';
|
|
@@ -73,6 +73,46 @@ const collectNestedStrings = (value, key)=>{
|
|
|
73
73
|
...collectNestedStrings(entryValue, key)
|
|
74
74
|
]);
|
|
75
75
|
};
|
|
76
|
+
const emptyProducerRouteModules = async (distDirectory, files, manifest, manifestLogicalPath)=>{
|
|
77
|
+
if (!isRecord(manifest) || !Array.isArray(manifest.exposes) || 0 !== manifest.exposes.length || !Array.isArray(manifest.remotes) || 0 !== manifest.remotes.length || !isRecord(manifest.metaData) || !isRecord(manifest.metaData.remoteEntry) || '' !== manifest.metaData.remoteEntry.name || '' !== manifest.metaData.remoteEntry.path || 'global' !== manifest.metaData.remoteEntry.type) return [];
|
|
78
|
+
const publicPath = manifest.metaData.publicPath;
|
|
79
|
+
const safeReference = (value)=>'string' == typeof value && value.length > 0 && !/[\\\\%?#\s]/u.test(value) && !value.split('/').some((segment)=>'.' === segment || '..' === segment);
|
|
80
|
+
if (!safeReference(publicPath)) return [];
|
|
81
|
+
const absoluteBase = /^https?:\/\//u.test(publicPath);
|
|
82
|
+
if ('auto' !== publicPath && (!publicPath.endsWith('/') || !absoluteBase && (!publicPath.startsWith('/') || publicPath.startsWith('//')))) return [];
|
|
83
|
+
if (absoluteBase) {
|
|
84
|
+
const base = new URL(publicPath);
|
|
85
|
+
if (base.username || base.password || base.href !== publicPath) return [];
|
|
86
|
+
}
|
|
87
|
+
const directory = external_node_path_default().posix.dirname(manifestLogicalPath);
|
|
88
|
+
const routesManifest = await readJson(external_node_path_default().join(distDirectory, directory, 'routes-manifest.json'));
|
|
89
|
+
if (!isRecord(routesManifest) || !isRecord(routesManifest.routeAssets)) return [];
|
|
90
|
+
const modules = new Set();
|
|
91
|
+
for (const route of Object.values(routesManifest.routeAssets)){
|
|
92
|
+
if (!isRecord(route) || !Array.isArray(route.assets)) return [];
|
|
93
|
+
for (const reference of route.assets){
|
|
94
|
+
if (!safeReference(reference) || reference.startsWith('//')) return [];
|
|
95
|
+
let relative = reference;
|
|
96
|
+
if (/^https?:\/\//u.test(reference)) {
|
|
97
|
+
if (!absoluteBase || !reference.startsWith(publicPath)) return [];
|
|
98
|
+
relative = reference.slice(publicPath.length);
|
|
99
|
+
} else if (reference.startsWith('/')) {
|
|
100
|
+
const prefix = 'auto' === publicPath ? '/' : absoluteBase ? new URL(publicPath).pathname : publicPath;
|
|
101
|
+
if (!reference.startsWith(prefix)) return [];
|
|
102
|
+
relative = reference.slice(prefix.length);
|
|
103
|
+
}
|
|
104
|
+
if (!/^(?:static|html|public)\/[^:]+$/u.test(relative) || relative.includes('//')) return [];
|
|
105
|
+
const logicalPath = external_node_path_default().posix.join(directory, relative);
|
|
106
|
+
if (!files.includes(logicalPath)) return [];
|
|
107
|
+
const assetStat = await promises_default().lstat(external_node_path_default().join(distDirectory, logicalPath));
|
|
108
|
+
if (!assetStat.isFile()) return [];
|
|
109
|
+
if (COMPILED_MODULE_PATTERN.test(logicalPath)) modules.add(logicalPath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [
|
|
113
|
+
...modules
|
|
114
|
+
];
|
|
115
|
+
};
|
|
76
116
|
const manifestReferencedClientModules = async (distDirectory, files, manifestLogicalPath = 'mf-manifest.json')=>{
|
|
77
117
|
const manifest = await readJson(external_node_path_default().join(distDirectory, manifestLogicalPath));
|
|
78
118
|
const references = [
|
|
@@ -82,9 +122,10 @@ const manifestReferencedClientModules = async (distDirectory, files, manifestLog
|
|
|
82
122
|
...collectNestedStrings(manifest, 'async')
|
|
83
123
|
];
|
|
84
124
|
const normalizedReferences = new Set(references.filter((value)=>'string' == typeof value).map((value)=>value.replace(/^https?:\/\/[^/]+/u, '')).map((value)=>value.replace(/^\/+/u, '')));
|
|
85
|
-
|
|
125
|
+
const modules = files.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath) && [
|
|
86
126
|
...normalizedReferences
|
|
87
127
|
].some((reference)=>reference === logicalPath || reference.endsWith(`/${logicalPath}`) || logicalPath.endsWith(`/${reference}`)));
|
|
128
|
+
return modules.length > 0 ? modules : emptyProducerRouteModules(distDirectory, files, manifest, manifestLogicalPath);
|
|
88
129
|
};
|
|
89
130
|
const routeReferencedSsrModules = async (distDirectory, files, target, routeSpecLogicalPath = 'route.json')=>{
|
|
90
131
|
const routeSpec = await readJson(external_node_path_default().join(distDirectory, routeSpecLogicalPath));
|
|
@@ -134,11 +175,14 @@ const writeReleaseEnvelope = async (artifactRoot, envelope)=>{
|
|
|
134
175
|
if (!envelopePath) throw new Error('[ultramodern-release-envelope] could not resolve release envelope path.');
|
|
135
176
|
await promises_default().writeFile(envelopePath, `${(0, external_index_js_namespaceObject.canonicalSerializeMicroVerticalReleaseEnvelope)(envelope)}\n`);
|
|
136
177
|
};
|
|
137
|
-
const readBuildArtifact = async (distDirectory)=>{
|
|
138
|
-
const artifactPath = external_node_path_default().join(distDirectory,
|
|
178
|
+
const readBuildArtifact = async (distDirectory, requirePromotable = true)=>{
|
|
179
|
+
const artifactPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE);
|
|
139
180
|
const artifact = await readJson(artifactPath);
|
|
140
|
-
if (!(0,
|
|
141
|
-
if ('workspace' === artifact.deliveryUnit.sourceRevision)
|
|
181
|
+
if (!(0, backend_federation_contracts_namespaceObject.isUltramodernBuildArtifact)(artifact)) throw new Error(`[ultramodern-release-envelope] ${backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE} is missing or invalid.`);
|
|
182
|
+
if ('workspace' === artifact.deliveryUnit.sourceRevision) {
|
|
183
|
+
if (!requirePromotable) return;
|
|
184
|
+
throw new Error('[ultramodern-release-envelope] sourceRevision "workspace" cannot produce a promotable full-stack envelope.');
|
|
185
|
+
}
|
|
142
186
|
return artifact;
|
|
143
187
|
};
|
|
144
188
|
const assertIdentityBlock = (value, identity, location, includeReleaseVersion)=>{
|
|
@@ -154,7 +198,7 @@ const assertIdentityBlock = (value, identity, location, includeReleaseVersion)=>
|
|
|
154
198
|
for (const [field, expectedValue] of Object.entries(expected))if (value[field] !== expectedValue) throw new Error(`[ultramodern-release-envelope] ${location}.${field} must match ${expectedValue}; received ${String(value[field])}.`);
|
|
155
199
|
};
|
|
156
200
|
const readBackendManifest = async (distDirectory, identity)=>{
|
|
157
|
-
const manifest = await readJson(external_node_path_default().join(distDirectory,
|
|
201
|
+
const manifest = await readJson(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE));
|
|
158
202
|
if (!isRecord(manifest) || !isRecord(manifest.backendFederation)) throw new Error('[ultramodern-release-envelope] backend federation manifest is missing backendFederation metadata.');
|
|
159
203
|
assertIdentityBlock(manifest.backendFederation.deliveryUnit, identity, 'backendFederation.deliveryUnit', true);
|
|
160
204
|
const versionBoundary = manifest.backendFederation.versionBoundary;
|
|
@@ -283,10 +327,10 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
283
327
|
add(ssrPaths, 'node' === target ? 'nodejs' : 'workerd');
|
|
284
328
|
add(apiBackendPaths, 'node' === target ? 'nodejs' : 'workerd-effect');
|
|
285
329
|
add([
|
|
286
|
-
|
|
330
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE
|
|
287
331
|
], 'module-federation-manifest');
|
|
288
332
|
add([
|
|
289
|
-
|
|
333
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
290
334
|
], 'node' === target ? 'nodejs' : 'commonjs-module');
|
|
291
335
|
const surfaces = {
|
|
292
336
|
uiClient: [
|
|
@@ -299,8 +343,8 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
299
343
|
...apiBackendPaths
|
|
300
344
|
].sort((left, right)=>left.localeCompare(right)),
|
|
301
345
|
backendFederation: {
|
|
302
|
-
manifest:
|
|
303
|
-
container:
|
|
346
|
+
manifest: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
347
|
+
container: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
304
348
|
}
|
|
305
349
|
};
|
|
306
350
|
const artifacts = [
|
|
@@ -309,8 +353,8 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
309
353
|
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(distDirectory, identity, {
|
|
310
354
|
apiBackend: apiBackendPaths,
|
|
311
355
|
backendFederation: [
|
|
312
|
-
|
|
313
|
-
|
|
356
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
357
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
314
358
|
],
|
|
315
359
|
ssr: [
|
|
316
360
|
...new Set([
|
|
@@ -336,17 +380,18 @@ const pathExists = async (filePath)=>{
|
|
|
336
380
|
return false;
|
|
337
381
|
}
|
|
338
382
|
};
|
|
339
|
-
const emitFrameworkMicroVerticalReleaseEnvelope = async ({ apiOnly, distDirectory, target })=>{
|
|
383
|
+
const emitFrameworkMicroVerticalReleaseEnvelope = async ({ apiOnly, distDirectory, requirePromotable = true, target })=>{
|
|
340
384
|
if (apiOnly) return;
|
|
341
|
-
const backendManifestPath = external_node_path_default().join(distDirectory,
|
|
342
|
-
const backendContainerPath = external_node_path_default().join(distDirectory,
|
|
385
|
+
const backendManifestPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE);
|
|
386
|
+
const backendContainerPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
|
|
343
387
|
const [hasBackendManifest, hasBackendContainer] = await Promise.all([
|
|
344
388
|
pathExists(backendManifestPath),
|
|
345
389
|
pathExists(backendContainerPath)
|
|
346
390
|
]);
|
|
347
391
|
if (!hasBackendManifest && !hasBackendContainer) return;
|
|
348
392
|
if (!hasBackendManifest || !hasBackendContainer) throw new Error('[ultramodern-release-envelope] full-stack MicroVertical backend federation manifest and container must be emitted together.');
|
|
349
|
-
const buildArtifact = await readBuildArtifact(distDirectory);
|
|
393
|
+
const buildArtifact = await readBuildArtifact(distDirectory, requirePromotable);
|
|
394
|
+
if (!buildArtifact) return;
|
|
350
395
|
const identity = {
|
|
351
396
|
unitId: buildArtifact.deliveryUnit.unitId,
|
|
352
397
|
buildMarker: buildArtifact.deliveryUnit.buildMarker,
|
|
@@ -387,9 +432,9 @@ const readFrameworkMicroVerticalReleaseEnvelope = async ({ artifactRoot, expecte
|
|
|
387
432
|
const verifyBuildOutputReleaseEnvelope = async (distDirectory, expectedTarget)=>{
|
|
388
433
|
const [hasEnvelope, hasBuildArtifact, hasBackendManifest, hasBackendEntry] = await Promise.all([
|
|
389
434
|
pathExists(external_node_path_default().join(distDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH)),
|
|
390
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
391
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
392
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
435
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE)),
|
|
436
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE)),
|
|
437
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE))
|
|
393
438
|
]);
|
|
394
439
|
const isFullStackMicroVertical = hasBuildArtifact && (hasBackendManifest || hasBackendEntry);
|
|
395
440
|
return readFrameworkMicroVerticalReleaseEnvelope({
|
|
@@ -410,12 +455,12 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
410
455
|
for (const requiredPath of [
|
|
411
456
|
'index.js',
|
|
412
457
|
'package.json',
|
|
413
|
-
|
|
414
|
-
|
|
458
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
459
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
415
460
|
])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Node staging is missing ${requiredPath}.`);
|
|
416
461
|
const backendFederationPaths = new Set([
|
|
417
|
-
|
|
418
|
-
|
|
462
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
463
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
419
464
|
]);
|
|
420
465
|
const uiClientPaths = files.filter((logicalPath)=>{
|
|
421
466
|
const topLevel = logicalPath.split('/')[0];
|
|
@@ -454,13 +499,13 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
454
499
|
for (const logicalPath of uiClientPaths)runtimeByPath.set(logicalPath, 'browser');
|
|
455
500
|
for (const logicalPath of ssrPaths)runtimeByPath.set(logicalPath, 'nodejs');
|
|
456
501
|
for (const logicalPath of apiBackendPaths)runtimeByPath.set(logicalPath, 'nodejs');
|
|
457
|
-
runtimeByPath.set(
|
|
458
|
-
runtimeByPath.set(
|
|
502
|
+
runtimeByPath.set(backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE, 'module-federation-manifest');
|
|
503
|
+
runtimeByPath.set(backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE, 'nodejs');
|
|
459
504
|
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(outputDirectory, identity, {
|
|
460
505
|
apiBackend: apiBackendPaths,
|
|
461
506
|
backendFederation: [
|
|
462
|
-
|
|
463
|
-
|
|
507
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
508
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
464
509
|
],
|
|
465
510
|
ssr: [
|
|
466
511
|
...new Set([
|
|
@@ -488,8 +533,8 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
488
533
|
...apiBackendPaths
|
|
489
534
|
].sort((left, right)=>left.localeCompare(right)),
|
|
490
535
|
backendFederation: {
|
|
491
|
-
manifest:
|
|
492
|
-
container:
|
|
536
|
+
manifest: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
537
|
+
container: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
493
538
|
}
|
|
494
539
|
}
|
|
495
540
|
};
|
|
@@ -525,8 +570,8 @@ const createCloudflareStagedReleaseArtifactInputs = async (outputDirectory, iden
|
|
|
525
570
|
'worker/package.json'
|
|
526
571
|
])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging is missing ${requiredPath}.`);
|
|
527
572
|
if (files.some((logicalPath)=>'public/release' === logicalPath || logicalPath.startsWith('public/release/'))) throw new Error('[ultramodern-release-envelope] final Cloudflare envelope must remain private and cannot be staged under public/release.');
|
|
528
|
-
const backendManifestPath = `public/${
|
|
529
|
-
const backendContainerPath = `public/${
|
|
573
|
+
const backendManifestPath = `public/${backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE}`;
|
|
574
|
+
const backendContainerPath = `public/${backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`;
|
|
530
575
|
const apiBackendPaths = files.filter((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
|
|
531
576
|
const ssrPaths = files.filter((logicalPath)=>(logicalPath.startsWith('server/') || logicalPath.startsWith('worker/')) && COMPILED_MODULE_PATTERN.test(logicalPath) && !EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
|
|
532
577
|
const uiClientPaths = files.filter((logicalPath)=>logicalPath.startsWith('public/') && logicalPath !== backendManifestPath && logicalPath !== backendContainerPath);
|
|
@@ -52,24 +52,26 @@ const createUltramodernReleaseEnvelopePlugin = ({ resolveDeployTarget })=>({
|
|
|
52
52
|
name: '@modern-js/ultramodern-release-envelope',
|
|
53
53
|
pre: [
|
|
54
54
|
'@modern-js/backend-federation-build',
|
|
55
|
-
'@modern-js/plugin-bff'
|
|
55
|
+
'@modern-js/plugin-bff',
|
|
56
|
+
'@modern-js/deploy-output-aliases'
|
|
56
57
|
],
|
|
57
58
|
post: [
|
|
58
59
|
'@modern-js/plugin-deploy'
|
|
59
60
|
],
|
|
60
61
|
setup (api) {
|
|
61
|
-
const emitBuildEnvelope = async (target)=>{
|
|
62
|
+
const emitBuildEnvelope = async (target, requirePromotable = true)=>{
|
|
62
63
|
const { apiOnly, distDirectory } = api.getAppContext();
|
|
63
64
|
await (0, external_framework_output_js_namespaceObject.emitFrameworkMicroVerticalReleaseEnvelope)({
|
|
64
65
|
apiOnly,
|
|
65
66
|
distDirectory,
|
|
67
|
+
requirePromotable,
|
|
66
68
|
target
|
|
67
69
|
});
|
|
68
70
|
};
|
|
69
71
|
api.onAfterBuild(async ()=>{
|
|
70
72
|
const configuredTarget = resolveDeployTarget(api.getNormalizedConfig());
|
|
71
73
|
if ('node' !== configuredTarget && 'cloudflare' !== configuredTarget) return;
|
|
72
|
-
await emitBuildEnvelope(configuredTarget);
|
|
74
|
+
await emitBuildEnvelope(configuredTarget, false);
|
|
73
75
|
});
|
|
74
76
|
api.onBeforeDeploy(async ()=>{
|
|
75
77
|
const configuredTarget = resolveActiveDeployTarget(api, resolveDeployTarget);
|
|
@@ -38,11 +38,8 @@ const BUILD_MARKER_NAMESPACE = 'ultramodern-delivery-unit-release-build-marker:v
|
|
|
38
38
|
const PROMOTABLE_SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
|
|
39
39
|
const gitOutput = (workspaceRoot, args)=>{
|
|
40
40
|
try {
|
|
41
|
-
return (0, external_node_child_process_namespaceObject.execFileSync)('git',
|
|
42
|
-
|
|
43
|
-
workspaceRoot,
|
|
44
|
-
...args
|
|
45
|
-
], {
|
|
41
|
+
return (0, external_node_child_process_namespaceObject.execFileSync)('git', args, {
|
|
42
|
+
cwd: workspaceRoot,
|
|
46
43
|
encoding: 'utf8',
|
|
47
44
|
stdio: [
|
|
48
45
|
'ignore',
|
|
@@ -77,7 +74,7 @@ const resolveUltramodernSourceRevision = (workspaceRoot = process.cwd(), configu
|
|
|
77
74
|
]);
|
|
78
75
|
const status = gitOutput(gitRoot, [
|
|
79
76
|
'status',
|
|
80
|
-
'--porcelain
|
|
77
|
+
'--porcelain',
|
|
81
78
|
'--untracked-files=all'
|
|
82
79
|
]);
|
|
83
80
|
if (!revision || void 0 === status || status.length > 0) return 'workspace';
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
canResolveRuntimePackage: ()=>canResolveRuntimePackage,
|
|
41
|
+
collectRuntimePackageModuleDirectories: ()=>collectRuntimePackageModuleDirectories,
|
|
42
|
+
createRuntimePackageResolutionPlugin: ()=>createRuntimePackageResolutionPlugin,
|
|
43
|
+
findHostingModuleDirectory: ()=>findHostingModuleDirectory
|
|
44
|
+
});
|
|
45
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
46
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
47
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
48
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
49
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
50
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
51
|
+
const findHostingModuleDirectory = (packageName, fromDirectory)=>{
|
|
52
|
+
let directory = external_node_path_default().resolve(fromDirectory);
|
|
53
|
+
for(;;){
|
|
54
|
+
const candidate = external_node_path_default().join(directory, 'node_modules');
|
|
55
|
+
if (external_node_fs_default().existsSync(external_node_path_default().join(candidate, packageName))) return candidate;
|
|
56
|
+
const parent = external_node_path_default().dirname(directory);
|
|
57
|
+
if (parent === directory) return;
|
|
58
|
+
directory = parent;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const collectRuntimePackageModuleDirectories = (packageNames, registrarUrl)=>{
|
|
62
|
+
const registrarDirectory = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(registrarUrl));
|
|
63
|
+
const directories = [];
|
|
64
|
+
for (const packageName of packageNames){
|
|
65
|
+
const directory = findHostingModuleDirectory(packageName, registrarDirectory);
|
|
66
|
+
if (directory && !directories.includes(directory)) directories.push(directory);
|
|
67
|
+
}
|
|
68
|
+
return directories;
|
|
69
|
+
};
|
|
70
|
+
const appendModuleDirectories = (config, directories)=>{
|
|
71
|
+
if (0 === directories.length) return;
|
|
72
|
+
config.resolve ??= {};
|
|
73
|
+
const existing = config.resolve.modules ?? [
|
|
74
|
+
'node_modules'
|
|
75
|
+
];
|
|
76
|
+
config.resolve.modules = [
|
|
77
|
+
...existing,
|
|
78
|
+
...directories.filter((directory)=>!existing.includes(directory))
|
|
79
|
+
];
|
|
80
|
+
};
|
|
81
|
+
const createRuntimePackageResolutionPlugin = (directories)=>({
|
|
82
|
+
name: 'ultramodern:runtime-package-resolution',
|
|
83
|
+
setup (api) {
|
|
84
|
+
api.modifyRspackConfig({
|
|
85
|
+
order: 'post',
|
|
86
|
+
handler (config) {
|
|
87
|
+
appendModuleDirectories(config, directories);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
api.onBeforeCreateCompiler({
|
|
91
|
+
order: 'post',
|
|
92
|
+
handler ({ bundlerConfigs }) {
|
|
93
|
+
for (const config of bundlerConfigs)appendModuleDirectories(config, directories);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const canResolveRuntimePackage = (packageName, registrarUrl)=>{
|
|
99
|
+
try {
|
|
100
|
+
(0, external_node_module_namespaceObject.createRequire)(registrarUrl).resolve(packageName);
|
|
101
|
+
return true;
|
|
102
|
+
} catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
exports.canResolveRuntimePackage = __webpack_exports__.canResolveRuntimePackage;
|
|
107
|
+
exports.collectRuntimePackageModuleDirectories = __webpack_exports__.collectRuntimePackageModuleDirectories;
|
|
108
|
+
exports.createRuntimePackageResolutionPlugin = __webpack_exports__.createRuntimePackageResolutionPlugin;
|
|
109
|
+
exports.findHostingModuleDirectory = __webpack_exports__.findHostingModuleDirectory;
|
|
110
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
111
|
+
"canResolveRuntimePackage",
|
|
112
|
+
"collectRuntimePackageModuleDirectories",
|
|
113
|
+
"createRuntimePackageResolutionPlugin",
|
|
114
|
+
"findHostingModuleDirectory"
|
|
115
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
116
|
+
Object.defineProperty(exports, '__esModule', {
|
|
117
|
+
value: true
|
|
118
|
+
});
|