@bleedingdev/modern-js-ultramodern-app-tools 3.9.3-ultramodern.2 → 3.9.3-ultramodern.4
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/native-composition/config-metadata.js +1 -1
- package/dist/cjs/native-composition/native-infrastructure.js +11 -1
- package/dist/cjs/native-composition/preset.js +29 -19
- package/dist/cjs/native-composition/renderer-build-resolution.js +1 -0
- package/dist/cjs/native-composition/renderer-release-identity.js +95 -0
- package/dist/cjs/renderers/react/build-metadata.js +2 -43
- package/dist/cjs/renderers/react/ssr-integration-plugin.js +11 -3
- package/dist/esm/native-composition/config-metadata.mjs +1 -1
- package/dist/esm/native-composition/native-infrastructure.mjs +11 -1
- package/dist/esm/native-composition/preset.mjs +25 -18
- package/dist/esm/native-composition/renderer-build-resolution.mjs +1 -0
- package/dist/esm/native-composition/renderer-release-identity.mjs +54 -0
- package/dist/esm/renderers/react/build-metadata.mjs +2 -43
- package/dist/esm/renderers/react/ssr-integration-plugin.mjs +11 -3
- package/dist/esm-node/native-composition/config-metadata.mjs +1 -1
- package/dist/esm-node/native-composition/native-infrastructure.mjs +11 -1
- package/dist/esm-node/native-composition/preset.mjs +25 -18
- package/dist/esm-node/native-composition/renderer-build-resolution.mjs +1 -0
- package/dist/esm-node/native-composition/renderer-release-identity.mjs +55 -0
- package/dist/esm-node/renderers/react/build-metadata.mjs +2 -43
- package/dist/esm-node/renderers/react/ssr-integration-plugin.mjs +11 -3
- package/dist/types/native-composition/preset.d.ts +10 -1
- package/dist/types/native-composition/renderer-release-identity.d.ts +11 -0
- package/dist/types-esm/native-composition/preset.d.mts +10 -1
- package/dist/types-esm/native-composition/renderer-release-identity.d.mts +11 -0
- package/lib/build-target.d.ts +17 -0
- package/lib/react-types.d.ts +1 -0
- package/package.json +30 -30
- package/src/native-composition/config-metadata.ts +4 -1
- package/src/native-composition/native-infrastructure.ts +12 -1
- package/src/native-composition/preset.ts +44 -27
- package/src/native-composition/renderer-build-resolution.ts +1 -0
- package/src/native-composition/renderer-release-identity.ts +78 -0
- package/src/renderers/react/build-metadata.ts +3 -49
- package/src/renderers/react/ssr-integration-plugin.ts +14 -4
|
@@ -140,7 +140,7 @@ function workerFile() {
|
|
|
140
140
|
if (parent === directory) throw new Error('Cannot find the UltraModern app tools package root');
|
|
141
141
|
directory = parent;
|
|
142
142
|
}
|
|
143
|
-
return external_node_path_default().join(directory, 'dist/
|
|
143
|
+
return external_node_path_default().join(directory, 'dist/esm-node/native-composition/config-metadata-worker.mjs');
|
|
144
144
|
}
|
|
145
145
|
function loadUltramodernConfigMetadata(options) {
|
|
146
146
|
const appDirectory = external_node_path_default().resolve(options.appDirectory);
|
|
@@ -61,6 +61,7 @@ const external_native_i18n_js_namespaceObject = require("./native-i18n.js");
|
|
|
61
61
|
const external_native_worker_js_namespaceObject = require("./native-worker.js");
|
|
62
62
|
const external_renderer_profile_js_namespaceObject = require("./renderer-profile.js");
|
|
63
63
|
const external_renderer_registration_js_namespaceObject = require("./renderer-registration.js");
|
|
64
|
+
const external_renderer_release_identity_js_namespaceObject = require("./renderer-release-identity.js");
|
|
64
65
|
const external_server_plugin_resolution_js_namespaceObject = require("./server-plugin-resolution.js");
|
|
65
66
|
async function findSource(directory, name, extensions) {
|
|
66
67
|
for (const extension of extensions){
|
|
@@ -148,7 +149,15 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
148
149
|
}
|
|
149
150
|
if (options.resolveBuildIdentities && !metadataRead) api.modifyResolvedConfig((config)=>{
|
|
150
151
|
const { command, apiOnly } = api.getAppContext();
|
|
151
|
-
if (
|
|
152
|
+
if (apiOnly) return config;
|
|
153
|
+
const identity = (0, external_renderer_release_identity_js_namespaceObject.rendererReleaseIdentityBuilderPlugin)(()=>buildIdentities);
|
|
154
|
+
if ('dev' !== command) return {
|
|
155
|
+
...config,
|
|
156
|
+
builderPlugins: [
|
|
157
|
+
...config.builderPlugins ?? [],
|
|
158
|
+
identity
|
|
159
|
+
]
|
|
160
|
+
};
|
|
152
161
|
development ??= new external_native_development_js_namespaceObject.NativeDevelopment({
|
|
153
162
|
renderer,
|
|
154
163
|
profile,
|
|
@@ -165,6 +174,7 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
165
174
|
...config,
|
|
166
175
|
builderPlugins: [
|
|
167
176
|
...config.builderPlugins ?? [],
|
|
177
|
+
identity,
|
|
168
178
|
development.plugin
|
|
169
179
|
]
|
|
170
180
|
};
|
|
@@ -41,7 +41,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
41
41
|
createPresetUltramodernConfig: ()=>createPresetUltramodernConfig,
|
|
42
42
|
isUltramodernReleaseIdentityBannerPlugin: ()=>isUltramodernReleaseIdentityBannerPlugin,
|
|
43
43
|
presetUltramodern: ()=>presetUltramodern,
|
|
44
|
-
releaseIdentityBanner: ()=>releaseIdentityBanner
|
|
44
|
+
releaseIdentityBanner: ()=>releaseIdentityBanner,
|
|
45
|
+
ultramodernReleaseIdentityBannerPlugin: ()=>ultramodernReleaseIdentityBannerPlugin
|
|
45
46
|
});
|
|
46
47
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
47
48
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -68,6 +69,20 @@ class UltramodernReleaseIdentityBannerPlugin extends core_namespaceObject.rspack
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
const releaseIdentityBanner = (values)=>values.map((value)=>`${JSON.stringify(value)};`).join('');
|
|
72
|
+
const ultramodernReleaseIdentityBannerPlugin = (values)=>({
|
|
73
|
+
name: 'ultramodern:release-identity-banner',
|
|
74
|
+
setup (api) {
|
|
75
|
+
api.modifyRspackConfig((config)=>{
|
|
76
|
+
config.plugins ??= [];
|
|
77
|
+
config.plugins.push(new UltramodernReleaseIdentityBannerPlugin({
|
|
78
|
+
banner: releaseIdentityBanner(values),
|
|
79
|
+
raw: true,
|
|
80
|
+
stage: core_namespaceObject.rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
81
|
+
test: /\.(?:c|m)?js$/u
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
71
86
|
function isUltramodernReleaseIdentityBannerPlugin(plugin) {
|
|
72
87
|
return 'object' == typeof plugin && null !== plugin && Object.getOwnPropertyDescriptor(plugin, RELEASE_IDENTITY_BANNER)?.value === true;
|
|
73
88
|
}
|
|
@@ -138,6 +153,15 @@ const createRendererPreset = (options = {}, renderer = 'react')=>{
|
|
|
138
153
|
(0, module_federation_shared_plugin_js_namespaceObject.ultramodernModuleFederationSharedPlugin)()
|
|
139
154
|
]
|
|
140
155
|
} : {},
|
|
156
|
+
...bundledReleaseIdentity ? {
|
|
157
|
+
builderPlugins: [
|
|
158
|
+
ultramodernReleaseIdentityBannerPlugin([
|
|
159
|
+
bundledReleaseIdentity.buildMarker,
|
|
160
|
+
bundledReleaseIdentity.sourceRevision,
|
|
161
|
+
bundledReleaseIdentity.releaseVersion
|
|
162
|
+
])
|
|
163
|
+
]
|
|
164
|
+
} : {},
|
|
141
165
|
server,
|
|
142
166
|
source: {
|
|
143
167
|
...'react' === renderer ? {
|
|
@@ -156,23 +180,7 @@ const createRendererPreset = (options = {}, renderer = 'react')=>{
|
|
|
156
180
|
bundlerChain: (chain, utils)=>{
|
|
157
181
|
if ('react' === renderer) setReactRouterBridgeSafeAliases(chain, utils);
|
|
158
182
|
},
|
|
159
|
-
lightningcssLoader: true
|
|
160
|
-
...bundledReleaseIdentity ? {
|
|
161
|
-
rspack: (config)=>{
|
|
162
|
-
config.plugins ??= [];
|
|
163
|
-
config.plugins.push(new UltramodernReleaseIdentityBannerPlugin({
|
|
164
|
-
banner: releaseIdentityBanner([
|
|
165
|
-
bundledReleaseIdentity.buildMarker,
|
|
166
|
-
bundledReleaseIdentity.sourceRevision,
|
|
167
|
-
bundledReleaseIdentity.releaseVersion
|
|
168
|
-
]),
|
|
169
|
-
raw: true,
|
|
170
|
-
stage: core_namespaceObject.rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
171
|
-
test: /\.(?:c|m)?js$/u
|
|
172
|
-
}));
|
|
173
|
-
return config;
|
|
174
|
-
}
|
|
175
|
-
} : {}
|
|
183
|
+
lightningcssLoader: true
|
|
176
184
|
}
|
|
177
185
|
};
|
|
178
186
|
if (enableBffRequestId) presetConfig.bff = {
|
|
@@ -198,12 +206,14 @@ exports.createPresetUltramodernConfig = __webpack_exports__.createPresetUltramod
|
|
|
198
206
|
exports.isUltramodernReleaseIdentityBannerPlugin = __webpack_exports__.isUltramodernReleaseIdentityBannerPlugin;
|
|
199
207
|
exports.presetUltramodern = __webpack_exports__.presetUltramodern;
|
|
200
208
|
exports.releaseIdentityBanner = __webpack_exports__.releaseIdentityBanner;
|
|
209
|
+
exports.ultramodernReleaseIdentityBannerPlugin = __webpack_exports__.ultramodernReleaseIdentityBannerPlugin;
|
|
201
210
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
202
211
|
"UltramodernReleaseIdentityBannerPlugin",
|
|
203
212
|
"createPresetUltramodernConfig",
|
|
204
213
|
"isUltramodernReleaseIdentityBannerPlugin",
|
|
205
214
|
"presetUltramodern",
|
|
206
|
-
"releaseIdentityBanner"
|
|
215
|
+
"releaseIdentityBanner",
|
|
216
|
+
"ultramodernReleaseIdentityBannerPlugin"
|
|
207
217
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
208
218
|
Object.defineProperty(exports, '__esModule', {
|
|
209
219
|
value: true
|
|
@@ -50,6 +50,7 @@ function createRendererBuildIdentityResolver(renderer) {
|
|
|
50
50
|
mode: context.mode ?? ('production' === process.env.NODE_ENV ? 'production' : 'development'),
|
|
51
51
|
...delivery ? {
|
|
52
52
|
appId: delivery.appId,
|
|
53
|
+
unitId: delivery.unitId,
|
|
53
54
|
sourceRevision: delivery.sourceRevision
|
|
54
55
|
} : {
|
|
55
56
|
appId: context.packageName || void 0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
applyRendererReleaseIdentity: ()=>applyRendererReleaseIdentity,
|
|
32
|
+
rendererReleaseIdentityBuilderPlugin: ()=>rendererReleaseIdentityBuilderPlugin
|
|
33
|
+
});
|
|
34
|
+
const core_namespaceObject = require("@rsbuild/core");
|
|
35
|
+
const external_preset_js_namespaceObject = require("./preset.js");
|
|
36
|
+
function applyRendererReleaseIdentity(api, getIdentities) {
|
|
37
|
+
api.modifyBundlerChain({
|
|
38
|
+
order: 'post',
|
|
39
|
+
handler: (chain)=>{
|
|
40
|
+
const identities = getIdentities();
|
|
41
|
+
if (!identities) return;
|
|
42
|
+
if (chain.plugins.has('globalVars')) chain.plugin('globalVars').tap((args)=>{
|
|
43
|
+
const definitions = {
|
|
44
|
+
...args[0]
|
|
45
|
+
};
|
|
46
|
+
delete definitions.ULTRAMODERN_BUILD_MARKER;
|
|
47
|
+
delete definitions.ULTRAMODERN_SOURCE_REVISION;
|
|
48
|
+
return [
|
|
49
|
+
definitions,
|
|
50
|
+
...args.slice(1)
|
|
51
|
+
];
|
|
52
|
+
});
|
|
53
|
+
chain.plugin('ultramodern-renderer-runtime-identity').use(core_namespaceObject.rspack.DefinePlugin, [
|
|
54
|
+
{
|
|
55
|
+
ULTRAMODERN_BUILD_MARKER: JSON.stringify(identities.buildId),
|
|
56
|
+
ULTRAMODERN_SOURCE_REVISION: JSON.stringify(identities.sourceRevision)
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
api.modifyRspackConfig({
|
|
62
|
+
order: 'post',
|
|
63
|
+
handler: (config)=>{
|
|
64
|
+
const identities = getIdentities();
|
|
65
|
+
if (!identities) return config;
|
|
66
|
+
const { buildId, sourceRevision } = identities;
|
|
67
|
+
config.plugins = (config.plugins ?? []).filter((plugin)=>!(0, external_preset_js_namespaceObject.isUltramodernReleaseIdentityBannerPlugin)(plugin));
|
|
68
|
+
config.plugins.push(new core_namespaceObject.rspack.BannerPlugin({
|
|
69
|
+
banner: (0, external_preset_js_namespaceObject.releaseIdentityBanner)([
|
|
70
|
+
buildId,
|
|
71
|
+
sourceRevision
|
|
72
|
+
]),
|
|
73
|
+
raw: true,
|
|
74
|
+
stage: core_namespaceObject.rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
75
|
+
test: /\.(?:c|m)?js$/u
|
|
76
|
+
}));
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const rendererReleaseIdentityBuilderPlugin = (getIdentities)=>({
|
|
82
|
+
name: 'ultramodern:renderer-release-identity',
|
|
83
|
+
setup (api) {
|
|
84
|
+
applyRendererReleaseIdentity(api, getIdentities);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
exports.applyRendererReleaseIdentity = __webpack_exports__.applyRendererReleaseIdentity;
|
|
88
|
+
exports.rendererReleaseIdentityBuilderPlugin = __webpack_exports__.rendererReleaseIdentityBuilderPlugin;
|
|
89
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
90
|
+
"applyRendererReleaseIdentity",
|
|
91
|
+
"rendererReleaseIdentityBuilderPlugin"
|
|
92
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
93
|
+
Object.defineProperty(exports, '__esModule', {
|
|
94
|
+
value: true
|
|
95
|
+
});
|
|
@@ -54,11 +54,10 @@ const renderer_build_identity_namespaceObject = require("@modern-js/app-tools-ex
|
|
|
54
54
|
const runtime_package_resolution_namespaceObject = require("@modern-js/app-tools-extensions/runtime-package-resolution");
|
|
55
55
|
const data_namespaceObject = require("@modern-js/renderer-core/data");
|
|
56
56
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
57
|
-
const core_namespaceObject = require("@rsbuild/core");
|
|
58
57
|
const config_read_context_js_namespaceObject = require("../../native-composition/config-read-context.js");
|
|
59
58
|
const native_build_manifest_js_namespaceObject = require("../../native-composition/native-build-manifest.js");
|
|
60
|
-
const preset_js_namespaceObject = require("../../native-composition/preset.js");
|
|
61
59
|
const renderer_profile_js_namespaceObject = require("../../native-composition/renderer-profile.js");
|
|
60
|
+
const renderer_release_identity_js_namespaceObject = require("../../native-composition/renderer-release-identity.js");
|
|
62
61
|
const external_adapter_js_namespaceObject = require("./adapter.js");
|
|
63
62
|
const REACT_RENDERER_IDENTITY_ELEMENT_ID = 'ultramodern-renderer-identity';
|
|
64
63
|
async function resolveReactMetadataServerPlugin(registrarUrl = __rslib_import_meta_url__) {
|
|
@@ -120,47 +119,7 @@ function reactRendererBuildMetadataPlugin(options) {
|
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
121
|
});
|
|
123
|
-
|
|
124
|
-
order: 'post',
|
|
125
|
-
handler: (chain)=>{
|
|
126
|
-
if (!identities) return;
|
|
127
|
-
if (chain.plugins.has('globalVars')) chain.plugin('globalVars').tap((args)=>{
|
|
128
|
-
const definitions = {
|
|
129
|
-
...args[0]
|
|
130
|
-
};
|
|
131
|
-
delete definitions.ULTRAMODERN_BUILD_MARKER;
|
|
132
|
-
delete definitions.ULTRAMODERN_SOURCE_REVISION;
|
|
133
|
-
return [
|
|
134
|
-
definitions,
|
|
135
|
-
...args.slice(1)
|
|
136
|
-
];
|
|
137
|
-
});
|
|
138
|
-
chain.plugin('ultramodern-react-runtime-identity').use(core_namespaceObject.rspack.DefinePlugin, [
|
|
139
|
-
{
|
|
140
|
-
ULTRAMODERN_BUILD_MARKER: JSON.stringify(identities.buildId),
|
|
141
|
-
ULTRAMODERN_SOURCE_REVISION: JSON.stringify(identities.sourceRevision)
|
|
142
|
-
}
|
|
143
|
-
]);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
api.modifyRspackConfig({
|
|
147
|
-
order: 'post',
|
|
148
|
-
handler: (config)=>{
|
|
149
|
-
if (!identities) return config;
|
|
150
|
-
const { buildId, sourceRevision } = identities;
|
|
151
|
-
config.plugins = (config.plugins ?? []).filter((plugin)=>!(0, preset_js_namespaceObject.isUltramodernReleaseIdentityBannerPlugin)(plugin));
|
|
152
|
-
config.plugins.push(new core_namespaceObject.rspack.BannerPlugin({
|
|
153
|
-
banner: (0, preset_js_namespaceObject.releaseIdentityBanner)([
|
|
154
|
-
buildId,
|
|
155
|
-
sourceRevision
|
|
156
|
-
]),
|
|
157
|
-
raw: true,
|
|
158
|
-
stage: core_namespaceObject.rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
159
|
-
test: /\.(?:c|m)?js$/u
|
|
160
|
-
}));
|
|
161
|
-
return config;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
122
|
+
(0, renderer_release_identity_js_namespaceObject.applyRendererReleaseIdentity)(api, ()=>identities);
|
|
164
123
|
api.modifyHTMLTags((tags, { filename, environment })=>{
|
|
165
124
|
if ('client' !== environment.name) return tags;
|
|
166
125
|
const entries = Object.entries(environment.htmlPaths).filter(([, output])=>output === filename);
|
|
@@ -38,6 +38,8 @@ const normalizeSsrCapabilities = (config)=>{
|
|
|
38
38
|
worker: config.deploy?.target === 'cloudflare'
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
const MODERN_TARGET_DEFINE = 'process.env.MODERN_TARGET';
|
|
42
|
+
const IMPORT_META_MODERN_TARGET_DEFINE = 'import.meta.env.MODERN_TARGET';
|
|
41
43
|
const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
42
44
|
name: '@modern-js/ultramodern-builder-plugin-ssr',
|
|
43
45
|
pre: [
|
|
@@ -45,10 +47,15 @@ const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
|
45
47
|
],
|
|
46
48
|
setup (api) {
|
|
47
49
|
const capabilities = normalizeSsrCapabilities(modernAPI.getNormalizedConfig());
|
|
48
|
-
api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>
|
|
50
|
+
api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>{
|
|
51
|
+
const buildTarget = config.source.define?.[MODERN_TARGET_DEFINE];
|
|
52
|
+
return mergeEnvironmentConfig(config, {
|
|
49
53
|
source: {
|
|
50
54
|
define: {
|
|
51
|
-
'process.env.MODERN_MF_APP_SSR': JSON.stringify(String(capabilities.federation))
|
|
55
|
+
'process.env.MODERN_MF_APP_SSR': JSON.stringify(String(capabilities.federation)),
|
|
56
|
+
...void 0 === buildTarget ? {} : {
|
|
57
|
+
[IMPORT_META_MODERN_TARGET_DEFINE]: buildTarget
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
},
|
|
54
61
|
...'workerSSR' === name && capabilities.worker ? {
|
|
@@ -56,7 +63,8 @@ const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
|
56
63
|
module: true
|
|
57
64
|
}
|
|
58
65
|
} : {}
|
|
59
|
-
})
|
|
66
|
+
});
|
|
67
|
+
});
|
|
60
68
|
}
|
|
61
69
|
});
|
|
62
70
|
const ultramodernSSRIntegrationPlugin = ()=>({
|
|
@@ -96,7 +96,7 @@ function workerFile() {
|
|
|
96
96
|
if (parent === directory) throw new Error('Cannot find the UltraModern app tools package root');
|
|
97
97
|
directory = parent;
|
|
98
98
|
}
|
|
99
|
-
return node_path.join(directory, 'dist/
|
|
99
|
+
return node_path.join(directory, 'dist/esm-node/native-composition/config-metadata-worker.mjs');
|
|
100
100
|
}
|
|
101
101
|
function loadUltramodernConfigMetadata(options) {
|
|
102
102
|
const appDirectory = node_path.resolve(options.appDirectory);
|
|
@@ -14,6 +14,7 @@ import { resolveNativeI18nEntry } from "./native-i18n.mjs";
|
|
|
14
14
|
import { isNativeWorkerBuild, nativeWorkerEntrySource, nativeWorkerEnvironment, writeNativeWorkerResources } from "./native-worker.mjs";
|
|
15
15
|
import { resolveCandidateRendererProfile, resolveRendererProfile } from "./renderer-profile.mjs";
|
|
16
16
|
import { nativeInfrastructurePluginName, resolveNativeRendererAdapter } from "./renderer-registration.mjs";
|
|
17
|
+
import { rendererReleaseIdentityBuilderPlugin } from "./renderer-release-identity.mjs";
|
|
17
18
|
import { resolveSdkServerPlugin } from "./server-plugin-resolution.mjs";
|
|
18
19
|
async function findSource(directory, name, extensions) {
|
|
19
20
|
for (const extension of extensions){
|
|
@@ -101,7 +102,15 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
101
102
|
}
|
|
102
103
|
if (options.resolveBuildIdentities && !metadataRead) api.modifyResolvedConfig((config)=>{
|
|
103
104
|
const { command, apiOnly } = api.getAppContext();
|
|
104
|
-
if (
|
|
105
|
+
if (apiOnly) return config;
|
|
106
|
+
const identity = rendererReleaseIdentityBuilderPlugin(()=>buildIdentities);
|
|
107
|
+
if ('dev' !== command) return {
|
|
108
|
+
...config,
|
|
109
|
+
builderPlugins: [
|
|
110
|
+
...config.builderPlugins ?? [],
|
|
111
|
+
identity
|
|
112
|
+
]
|
|
113
|
+
};
|
|
105
114
|
development ??= new NativeDevelopment({
|
|
106
115
|
renderer,
|
|
107
116
|
profile,
|
|
@@ -118,6 +127,7 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
118
127
|
...config,
|
|
119
128
|
builderPlugins: [
|
|
120
129
|
...config.builderPlugins ?? [],
|
|
130
|
+
identity,
|
|
121
131
|
development.plugin
|
|
122
132
|
]
|
|
123
133
|
};
|
|
@@ -21,6 +21,20 @@ class UltramodernReleaseIdentityBannerPlugin extends rspack.BannerPlugin {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const releaseIdentityBanner = (values)=>values.map((value)=>`${JSON.stringify(value)};`).join('');
|
|
24
|
+
const ultramodernReleaseIdentityBannerPlugin = (values)=>({
|
|
25
|
+
name: 'ultramodern:release-identity-banner',
|
|
26
|
+
setup (api) {
|
|
27
|
+
api.modifyRspackConfig((config)=>{
|
|
28
|
+
config.plugins ??= [];
|
|
29
|
+
config.plugins.push(new UltramodernReleaseIdentityBannerPlugin({
|
|
30
|
+
banner: releaseIdentityBanner(values),
|
|
31
|
+
raw: true,
|
|
32
|
+
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
33
|
+
test: /\.(?:c|m)?js$/u
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
24
38
|
function isUltramodernReleaseIdentityBannerPlugin(plugin) {
|
|
25
39
|
return 'object' == typeof plugin && null !== plugin && Object.getOwnPropertyDescriptor(plugin, RELEASE_IDENTITY_BANNER)?.value === true;
|
|
26
40
|
}
|
|
@@ -91,6 +105,15 @@ const createRendererPreset = (options = {}, renderer = 'react')=>{
|
|
|
91
105
|
ultramodernModuleFederationSharedPlugin()
|
|
92
106
|
]
|
|
93
107
|
} : {},
|
|
108
|
+
...bundledReleaseIdentity ? {
|
|
109
|
+
builderPlugins: [
|
|
110
|
+
ultramodernReleaseIdentityBannerPlugin([
|
|
111
|
+
bundledReleaseIdentity.buildMarker,
|
|
112
|
+
bundledReleaseIdentity.sourceRevision,
|
|
113
|
+
bundledReleaseIdentity.releaseVersion
|
|
114
|
+
])
|
|
115
|
+
]
|
|
116
|
+
} : {},
|
|
94
117
|
server,
|
|
95
118
|
source: {
|
|
96
119
|
...'react' === renderer ? {
|
|
@@ -109,23 +132,7 @@ const createRendererPreset = (options = {}, renderer = 'react')=>{
|
|
|
109
132
|
bundlerChain: (chain, utils)=>{
|
|
110
133
|
if ('react' === renderer) setReactRouterBridgeSafeAliases(chain, utils);
|
|
111
134
|
},
|
|
112
|
-
lightningcssLoader: true
|
|
113
|
-
...bundledReleaseIdentity ? {
|
|
114
|
-
rspack: (config)=>{
|
|
115
|
-
config.plugins ??= [];
|
|
116
|
-
config.plugins.push(new UltramodernReleaseIdentityBannerPlugin({
|
|
117
|
-
banner: releaseIdentityBanner([
|
|
118
|
-
bundledReleaseIdentity.buildMarker,
|
|
119
|
-
bundledReleaseIdentity.sourceRevision,
|
|
120
|
-
bundledReleaseIdentity.releaseVersion
|
|
121
|
-
]),
|
|
122
|
-
raw: true,
|
|
123
|
-
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
124
|
-
test: /\.(?:c|m)?js$/u
|
|
125
|
-
}));
|
|
126
|
-
return config;
|
|
127
|
-
}
|
|
128
|
-
} : {}
|
|
135
|
+
lightningcssLoader: true
|
|
129
136
|
}
|
|
130
137
|
};
|
|
131
138
|
if (enableBffRequestId) presetConfig.bff = {
|
|
@@ -146,4 +153,4 @@ const presetUltramodern = (config, options = {})=>{
|
|
|
146
153
|
];
|
|
147
154
|
return merged;
|
|
148
155
|
};
|
|
149
|
-
export { UltramodernReleaseIdentityBannerPlugin, createPresetUltramodernConfig, isUltramodernReleaseIdentityBannerPlugin, presetUltramodern, releaseIdentityBanner };
|
|
156
|
+
export { UltramodernReleaseIdentityBannerPlugin, createPresetUltramodernConfig, isUltramodernReleaseIdentityBannerPlugin, presetUltramodern, releaseIdentityBanner, ultramodernReleaseIdentityBannerPlugin };
|
|
@@ -18,6 +18,7 @@ function createRendererBuildIdentityResolver(renderer) {
|
|
|
18
18
|
mode: context.mode ?? ('production' === process.env.NODE_ENV ? 'production' : 'development'),
|
|
19
19
|
...delivery ? {
|
|
20
20
|
appId: delivery.appId,
|
|
21
|
+
unitId: delivery.unitId,
|
|
21
22
|
sourceRevision: delivery.sourceRevision
|
|
22
23
|
} : {
|
|
23
24
|
appId: context.packageName || void 0
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { rspack } from "@rsbuild/core";
|
|
2
|
+
import { isUltramodernReleaseIdentityBannerPlugin, releaseIdentityBanner } from "./preset.mjs";
|
|
3
|
+
function applyRendererReleaseIdentity(api, getIdentities) {
|
|
4
|
+
api.modifyBundlerChain({
|
|
5
|
+
order: 'post',
|
|
6
|
+
handler: (chain)=>{
|
|
7
|
+
const identities = getIdentities();
|
|
8
|
+
if (!identities) return;
|
|
9
|
+
if (chain.plugins.has('globalVars')) chain.plugin('globalVars').tap((args)=>{
|
|
10
|
+
const definitions = {
|
|
11
|
+
...args[0]
|
|
12
|
+
};
|
|
13
|
+
delete definitions.ULTRAMODERN_BUILD_MARKER;
|
|
14
|
+
delete definitions.ULTRAMODERN_SOURCE_REVISION;
|
|
15
|
+
return [
|
|
16
|
+
definitions,
|
|
17
|
+
...args.slice(1)
|
|
18
|
+
];
|
|
19
|
+
});
|
|
20
|
+
chain.plugin('ultramodern-renderer-runtime-identity').use(rspack.DefinePlugin, [
|
|
21
|
+
{
|
|
22
|
+
ULTRAMODERN_BUILD_MARKER: JSON.stringify(identities.buildId),
|
|
23
|
+
ULTRAMODERN_SOURCE_REVISION: JSON.stringify(identities.sourceRevision)
|
|
24
|
+
}
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
api.modifyRspackConfig({
|
|
29
|
+
order: 'post',
|
|
30
|
+
handler: (config)=>{
|
|
31
|
+
const identities = getIdentities();
|
|
32
|
+
if (!identities) return config;
|
|
33
|
+
const { buildId, sourceRevision } = identities;
|
|
34
|
+
config.plugins = (config.plugins ?? []).filter((plugin)=>!isUltramodernReleaseIdentityBannerPlugin(plugin));
|
|
35
|
+
config.plugins.push(new rspack.BannerPlugin({
|
|
36
|
+
banner: releaseIdentityBanner([
|
|
37
|
+
buildId,
|
|
38
|
+
sourceRevision
|
|
39
|
+
]),
|
|
40
|
+
raw: true,
|
|
41
|
+
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
42
|
+
test: /\.(?:c|m)?js$/u
|
|
43
|
+
}));
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const rendererReleaseIdentityBuilderPlugin = (getIdentities)=>({
|
|
49
|
+
name: 'ultramodern:renderer-release-identity',
|
|
50
|
+
setup (api) {
|
|
51
|
+
applyRendererReleaseIdentity(api, getIdentities);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export { applyRendererReleaseIdentity, rendererReleaseIdentityBuilderPlugin };
|
|
@@ -6,11 +6,10 @@ import { rendererProfileKey } from "@modern-js/app-tools-extensions/renderer-bui
|
|
|
6
6
|
import { findHostingModuleDirectory } from "@modern-js/app-tools-extensions/runtime-package-resolution";
|
|
7
7
|
import { escapeInlineDataJSON } from "@modern-js/renderer-core/data";
|
|
8
8
|
import { getArgv } from "@modern-js/utils";
|
|
9
|
-
import { rspack } from "@rsbuild/core";
|
|
10
9
|
import { isEntryMetadataRead } from "../../native-composition/config-read-context.mjs";
|
|
11
10
|
import { createRendererBuildManifest, readRendererBuildManifest, rendererBuildCachePerformance, writeRendererBuildManifest } from "../../native-composition/native-build-manifest.mjs";
|
|
12
|
-
import { isUltramodernReleaseIdentityBannerPlugin, releaseIdentityBanner } from "../../native-composition/preset.mjs";
|
|
13
11
|
import { resolveRendererProfile, resolveRendererRouterFrameworks } from "../../native-composition/renderer-profile.mjs";
|
|
12
|
+
import { applyRendererReleaseIdentity } from "../../native-composition/renderer-release-identity.mjs";
|
|
14
13
|
import { reactRendererAdapter } from "./adapter.mjs";
|
|
15
14
|
const REACT_RENDERER_IDENTITY_ELEMENT_ID = 'ultramodern-renderer-identity';
|
|
16
15
|
async function resolveReactMetadataServerPlugin(registrarUrl = import.meta.url) {
|
|
@@ -72,47 +71,7 @@ function reactRendererBuildMetadataPlugin(options) {
|
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
|
-
api
|
|
76
|
-
order: 'post',
|
|
77
|
-
handler: (chain)=>{
|
|
78
|
-
if (!identities) return;
|
|
79
|
-
if (chain.plugins.has('globalVars')) chain.plugin('globalVars').tap((args)=>{
|
|
80
|
-
const definitions = {
|
|
81
|
-
...args[0]
|
|
82
|
-
};
|
|
83
|
-
delete definitions.ULTRAMODERN_BUILD_MARKER;
|
|
84
|
-
delete definitions.ULTRAMODERN_SOURCE_REVISION;
|
|
85
|
-
return [
|
|
86
|
-
definitions,
|
|
87
|
-
...args.slice(1)
|
|
88
|
-
];
|
|
89
|
-
});
|
|
90
|
-
chain.plugin('ultramodern-react-runtime-identity').use(rspack.DefinePlugin, [
|
|
91
|
-
{
|
|
92
|
-
ULTRAMODERN_BUILD_MARKER: JSON.stringify(identities.buildId),
|
|
93
|
-
ULTRAMODERN_SOURCE_REVISION: JSON.stringify(identities.sourceRevision)
|
|
94
|
-
}
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
api.modifyRspackConfig({
|
|
99
|
-
order: 'post',
|
|
100
|
-
handler: (config)=>{
|
|
101
|
-
if (!identities) return config;
|
|
102
|
-
const { buildId, sourceRevision } = identities;
|
|
103
|
-
config.plugins = (config.plugins ?? []).filter((plugin)=>!isUltramodernReleaseIdentityBannerPlugin(plugin));
|
|
104
|
-
config.plugins.push(new rspack.BannerPlugin({
|
|
105
|
-
banner: releaseIdentityBanner([
|
|
106
|
-
buildId,
|
|
107
|
-
sourceRevision
|
|
108
|
-
]),
|
|
109
|
-
raw: true,
|
|
110
|
-
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
111
|
-
test: /\.(?:c|m)?js$/u
|
|
112
|
-
}));
|
|
113
|
-
return config;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
74
|
+
applyRendererReleaseIdentity(api, ()=>identities);
|
|
116
75
|
api.modifyHTMLTags((tags, { filename, environment })=>{
|
|
117
76
|
if ('client' !== environment.name) return tags;
|
|
118
77
|
const entries = Object.entries(environment.htmlPaths).filter(([, output])=>output === filename);
|
|
@@ -9,6 +9,8 @@ const normalizeSsrCapabilities = (config)=>{
|
|
|
9
9
|
worker: config.deploy?.target === 'cloudflare'
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
const MODERN_TARGET_DEFINE = 'process.env.MODERN_TARGET';
|
|
13
|
+
const IMPORT_META_MODERN_TARGET_DEFINE = 'import.meta.env.MODERN_TARGET';
|
|
12
14
|
const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
13
15
|
name: '@modern-js/ultramodern-builder-plugin-ssr',
|
|
14
16
|
pre: [
|
|
@@ -16,10 +18,15 @@ const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
|
16
18
|
],
|
|
17
19
|
setup (api) {
|
|
18
20
|
const capabilities = normalizeSsrCapabilities(modernAPI.getNormalizedConfig());
|
|
19
|
-
api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>
|
|
21
|
+
api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>{
|
|
22
|
+
const buildTarget = config.source.define?.[MODERN_TARGET_DEFINE];
|
|
23
|
+
return mergeEnvironmentConfig(config, {
|
|
20
24
|
source: {
|
|
21
25
|
define: {
|
|
22
|
-
'process.env.MODERN_MF_APP_SSR': JSON.stringify(String(capabilities.federation))
|
|
26
|
+
'process.env.MODERN_MF_APP_SSR': JSON.stringify(String(capabilities.federation)),
|
|
27
|
+
...void 0 === buildTarget ? {} : {
|
|
28
|
+
[IMPORT_META_MODERN_TARGET_DEFINE]: buildTarget
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
},
|
|
25
32
|
...'workerSSR' === name && capabilities.worker ? {
|
|
@@ -27,7 +34,8 @@ const ssrIntegrationBuilderPlugin = (modernAPI)=>({
|
|
|
27
34
|
module: true
|
|
28
35
|
}
|
|
29
36
|
} : {}
|
|
30
|
-
})
|
|
37
|
+
});
|
|
38
|
+
});
|
|
31
39
|
}
|
|
32
40
|
});
|
|
33
41
|
const ultramodernSSRIntegrationPlugin = ()=>({
|
|
@@ -97,7 +97,7 @@ function workerFile() {
|
|
|
97
97
|
if (parent === directory) throw new Error('Cannot find the UltraModern app tools package root');
|
|
98
98
|
directory = parent;
|
|
99
99
|
}
|
|
100
|
-
return node_path.join(directory, 'dist/
|
|
100
|
+
return node_path.join(directory, 'dist/esm-node/native-composition/config-metadata-worker.mjs');
|
|
101
101
|
}
|
|
102
102
|
function loadUltramodernConfigMetadata(options) {
|
|
103
103
|
const appDirectory = node_path.resolve(options.appDirectory);
|
|
@@ -15,6 +15,7 @@ import { resolveNativeI18nEntry } from "./native-i18n.mjs";
|
|
|
15
15
|
import { isNativeWorkerBuild, nativeWorkerEntrySource, nativeWorkerEnvironment, writeNativeWorkerResources } from "./native-worker.mjs";
|
|
16
16
|
import { resolveCandidateRendererProfile, resolveRendererProfile } from "./renderer-profile.mjs";
|
|
17
17
|
import { nativeInfrastructurePluginName, resolveNativeRendererAdapter } from "./renderer-registration.mjs";
|
|
18
|
+
import { rendererReleaseIdentityBuilderPlugin } from "./renderer-release-identity.mjs";
|
|
18
19
|
import { resolveSdkServerPlugin } from "./server-plugin-resolution.mjs";
|
|
19
20
|
async function findSource(directory, name, extensions) {
|
|
20
21
|
for (const extension of extensions){
|
|
@@ -102,7 +103,15 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
102
103
|
}
|
|
103
104
|
if (options.resolveBuildIdentities && !metadataRead) api.modifyResolvedConfig((config)=>{
|
|
104
105
|
const { command, apiOnly } = api.getAppContext();
|
|
105
|
-
if (
|
|
106
|
+
if (apiOnly) return config;
|
|
107
|
+
const identity = rendererReleaseIdentityBuilderPlugin(()=>buildIdentities);
|
|
108
|
+
if ('dev' !== command) return {
|
|
109
|
+
...config,
|
|
110
|
+
builderPlugins: [
|
|
111
|
+
...config.builderPlugins ?? [],
|
|
112
|
+
identity
|
|
113
|
+
]
|
|
114
|
+
};
|
|
106
115
|
development ??= new NativeDevelopment({
|
|
107
116
|
renderer,
|
|
108
117
|
profile,
|
|
@@ -119,6 +128,7 @@ function nativeRendererInfrastructurePlugin(renderer, generator, options = {}) {
|
|
|
119
128
|
...config,
|
|
120
129
|
builderPlugins: [
|
|
121
130
|
...config.builderPlugins ?? [],
|
|
131
|
+
identity,
|
|
122
132
|
development.plugin
|
|
123
133
|
]
|
|
124
134
|
};
|