@bleedingdev/modern-js-ultramodern-app-tools 3.9.3-ultramodern.13 → 3.9.3-ultramodern.15
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/README.md +41 -0
- package/dist/cjs/native-composition/config.js +3 -0
- package/dist/cjs/native-composition/module-federation-renderer-plugin.js +4 -3
- package/dist/cjs/native-composition/native-development.js +56 -1
- package/dist/cjs/native-composition/redact-config.js +51 -0
- package/dist/cjs/native-composition/renderer-registration.js +3 -1
- package/dist/cjs/native-composition/renderer-selection.js +1 -0
- package/dist/cjs/renderers/react/composition.js +2 -0
- package/dist/cjs/renderers/react/module-federation.js +56 -12
- package/dist/cjs/renderers/react/redact-integration-plugin.js +302 -0
- package/dist/esm/native-composition/config.mjs +3 -0
- package/dist/esm/native-composition/module-federation-renderer-plugin.mjs +5 -4
- package/dist/esm/native-composition/native-development.mjs +57 -2
- package/dist/esm/native-composition/redact-config.mjs +10 -0
- package/dist/esm/native-composition/renderer-registration.mjs +3 -1
- package/dist/esm/native-composition/renderer-selection.mjs +1 -0
- package/dist/esm/renderers/react/composition.mjs +2 -0
- package/dist/esm/renderers/react/module-federation.mjs +52 -11
- package/dist/esm/renderers/react/redact-integration-plugin.mjs +221 -0
- package/dist/esm-node/native-composition/config.mjs +3 -0
- package/dist/esm-node/native-composition/module-federation-renderer-plugin.mjs +5 -4
- package/dist/esm-node/native-composition/native-development.mjs +57 -2
- package/dist/esm-node/native-composition/redact-config.mjs +11 -0
- package/dist/esm-node/native-composition/renderer-registration.mjs +3 -1
- package/dist/esm-node/native-composition/renderer-selection.mjs +1 -0
- package/dist/esm-node/renderers/react/composition.mjs +2 -0
- package/dist/esm-node/renderers/react/module-federation.mjs +52 -11
- package/dist/esm-node/renderers/react/redact-integration-plugin.mjs +222 -0
- package/dist/types/native-composition/module-federation-renderer-plugin.d.ts +2 -1
- package/dist/types/native-composition/native-development.d.ts +8 -0
- package/dist/types/native-composition/redact-config.d.ts +11 -0
- package/dist/types/native-composition/renderer-selection.d.ts +1 -1
- package/dist/types/native-composition/types.d.ts +7 -0
- package/dist/types/renderers/react/module-federation.d.ts +10 -1
- package/dist/types/renderers/react/redact-integration-plugin.d.ts +50 -0
- package/dist/types-esm/native-composition/module-federation-renderer-plugin.d.mts +2 -1
- package/dist/types-esm/native-composition/native-development.d.mts +8 -0
- package/dist/types-esm/native-composition/redact-config.d.mts +11 -0
- package/dist/types-esm/native-composition/renderer-selection.d.mts +1 -1
- package/dist/types-esm/native-composition/types.d.mts +7 -0
- package/dist/types-esm/renderers/react/module-federation.d.mts +10 -1
- package/dist/types-esm/renderers/react/redact-integration-plugin.d.mts +50 -0
- package/package.json +35 -32
- package/src/native-composition/config.ts +3 -0
- package/src/native-composition/module-federation-renderer-plugin.ts +17 -3
- package/src/native-composition/native-development.ts +81 -2
- package/src/native-composition/redact-config.ts +33 -0
- package/src/native-composition/renderer-registration.ts +2 -0
- package/src/native-composition/renderer-selection.ts +1 -0
- package/src/native-composition/types.ts +5 -0
- package/src/renderers/react/composition.ts +2 -0
- package/src/renderers/react/module-federation.ts +107 -9
- package/src/renderers/react/redact-integration-plugin.ts +347 -0
package/README.md
CHANGED
|
@@ -25,6 +25,47 @@ The selector belongs to this config import. Do not add another `appTools()` or
|
|
|
25
25
|
native application source and dependencies, then a dev-server restart and a
|
|
26
26
|
document reload. The generated entries own mounting and hydration.
|
|
27
27
|
|
|
28
|
+
## Default React runtime
|
|
29
|
+
|
|
30
|
+
React applications use the framework's exact `@tanstack/redact@0.2.1` runtime
|
|
31
|
+
by default, on the client, Node SSR and Cloudflare workerd SSR. Keep authoring
|
|
32
|
+
normal React 19 imports; no application dependency or template edits enable it.
|
|
33
|
+
The framework owns Redact, `rsbuild-redact-plugin@0.1.0`, and a React 19 copy for
|
|
34
|
+
the public plugin's version check under pnpm's strict dependency isolation.
|
|
35
|
+
CSR uses that public plugin; SSR uses a fork-owned integration with the same
|
|
36
|
+
exact aliases, including canonical Redact imports, in every environment.
|
|
37
|
+
Custom Document compilers inherit these aliases instead of forcing real React
|
|
38
|
+
externals; the native compiler respects explicit runtime aliases.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
// Omit for Redact with view transitions disabled.
|
|
43
|
+
redact: { viewTransitions: true },
|
|
44
|
+
server: { ssr: true },
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Set `redact: false` to use real React throughout the application. Invalid values
|
|
49
|
+
fail configuration validation. **RSC applications always use real React**, on
|
|
50
|
+
both server and client: Flight requires React internals Redact does not provide.
|
|
51
|
+
The CLI logs this limitation once rather than mixing runtimes.
|
|
52
|
+
|
|
53
|
+
Enabled builds require the reviewed pnpm patch whose first line in Redact's
|
|
54
|
+
`dist/server/stream.js` is `// ultramodern-redact-patch: v1`. Missing patches
|
|
55
|
+
fail the build with installation guidance and the `redact: false` escape hatch;
|
|
56
|
+
there is no configuration bypass. The patch fixes streamed Suspense IDs,
|
|
57
|
+
post-hydration IDs, namespace-sensitive segments and deferred reveal ordering.
|
|
58
|
+
|
|
59
|
+
Federated hosts and remotes must choose the same runtime. Their existing
|
|
60
|
+
renderer manifest contract publishes the effective runtime and hydration
|
|
61
|
+
identity (Redact `0.2.1`, or actual React for opt-out/RSC), and rejects mismatches
|
|
62
|
+
before remote initialization. Redact publishes under React's own share keys
|
|
63
|
+
(`react`, `react-dom`, JSX runtimes), once each, so hosts that govern those
|
|
64
|
+
singletons keep working. Each key carries Redact's real version with strict
|
|
65
|
+
matching, not a React 19 version, and direct Redact imports consume the same
|
|
66
|
+
singletons. The React authoring
|
|
67
|
+
profile continues to describe React's API/compiler, not the runtime override.
|
|
68
|
+
|
|
28
69
|
## Native application imports
|
|
29
70
|
|
|
30
71
|
| Renderer | Component authoring | Application router |
|
|
@@ -50,6 +50,7 @@ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_no
|
|
|
50
50
|
const cli_namespaceObject = require("@modern-js/plugin/cli");
|
|
51
51
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
52
52
|
const external_config_read_context_js_namespaceObject = require("./config-read-context.js");
|
|
53
|
+
const external_redact_config_js_namespaceObject = require("./redact-config.js");
|
|
53
54
|
const external_renderer_registration_js_namespaceObject = require("./renderer-registration.js");
|
|
54
55
|
const external_renderer_router_resolution_js_namespaceObject = require("./renderer-router-resolution.js");
|
|
55
56
|
const external_renderer_selection_js_namespaceObject = require("./renderer-selection.js");
|
|
@@ -59,6 +60,7 @@ function isConfigPromise(value) {
|
|
|
59
60
|
}
|
|
60
61
|
function selectConfig(config, factory) {
|
|
61
62
|
if (!config || 'object' != typeof config || Array.isArray(config)) throw new Error('UltraModern configuration must be an object');
|
|
63
|
+
(0, external_redact_config_js_namespaceObject.validateRedactConfig)(config.redact);
|
|
62
64
|
const renderer = (0, external_renderer_registration_js_namespaceObject.resolveRendererAdapter)(config.renderer).name;
|
|
63
65
|
const plugins = config.plugins ?? [];
|
|
64
66
|
(0, external_renderer_selection_js_namespaceObject.assertNoAdditionalBasePlugins)(plugins);
|
|
@@ -88,6 +90,7 @@ function createDefineConfig(factory) {
|
|
|
88
90
|
}
|
|
89
91
|
async function resolveUltramodernConfig(config, context) {
|
|
90
92
|
const resolved = 'function' == typeof config ? await config(context) : config;
|
|
93
|
+
(0, external_redact_config_js_namespaceObject.validateRedactConfig)(resolved.redact);
|
|
91
94
|
const renderer = (0, external_renderer_registration_js_namespaceObject.resolveRendererAdapter)(resolved.renderer).name;
|
|
92
95
|
return void 0 === resolved.renderer ? {
|
|
93
96
|
...resolved,
|
|
@@ -72,9 +72,9 @@ function nativeManifestAssetNames(manifest) {
|
|
|
72
72
|
function resolveRendererFederationRuntimePlugin(registrarUrl = __rslib_import_meta_url__) {
|
|
73
73
|
return (0, external_node_module_namespaceObject.createRequire)(registrarUrl).resolve('@modern-js/federation-runtime/renderer-runtime-plugin');
|
|
74
74
|
}
|
|
75
|
-
function resolveRendererFederationCompatibility(renderer) {
|
|
75
|
+
function resolveRendererFederationCompatibility(renderer, config = {}) {
|
|
76
76
|
const adapter = (0, external_renderer_registration_js_namespaceObject.resolveRendererAdapter)(renderer);
|
|
77
|
-
if ('native' !== adapter.kind) return (0, module_federation_js_namespaceObject.resolveReactFederationCompatibility)();
|
|
77
|
+
if ('native' !== adapter.kind) return (0, module_federation_js_namespaceObject.resolveReactFederationCompatibility)(config);
|
|
78
78
|
const owners = adapter.runtime;
|
|
79
79
|
const metadata = (0, external_renderer_profile_js_namespaceObject.resolveRendererProfileMetadata)(renderer);
|
|
80
80
|
const bootstrap = metadata.frameworkPackages.find((owner)=>owner.specifier === owners.bootstrap);
|
|
@@ -121,7 +121,7 @@ function createRendererModuleFederationIntegration(renderer, options = {}) {
|
|
|
121
121
|
api.modifyBundlerChain((chain)=>{
|
|
122
122
|
const nativeKeys = NATIVE_PLUGINS.filter((key)=>chain.plugins.has(key));
|
|
123
123
|
if (!nativeKeys.length) return;
|
|
124
|
-
const compatibility = (0, renderer_contract_namespaceObject.readRendererFederationCompatibility)(options.resolveCompatibility?.() ?? resolveRendererFederationCompatibility(renderer));
|
|
124
|
+
const compatibility = (0, renderer_contract_namespaceObject.readRendererFederationCompatibility)(options.resolveCompatibility?.() ?? resolveRendererFederationCompatibility(renderer, api.getNormalizedConfig()));
|
|
125
125
|
const runtimePlugin = (options.resolveRuntimePlugin ?? resolveRendererFederationRuntimePlugin)();
|
|
126
126
|
const stamped = new WeakSet();
|
|
127
127
|
const publications = new Set();
|
|
@@ -132,6 +132,7 @@ function createRendererModuleFederationIntegration(renderer, options = {}) {
|
|
|
132
132
|
const config = {
|
|
133
133
|
...original
|
|
134
134
|
};
|
|
135
|
+
if ('react' === renderer) config.shared = (0, module_federation_js_namespaceObject.withReactRuntimeShared)(config.shared, compatibility);
|
|
135
136
|
if (false === config.manifest) throw (0, renderer_contract_namespaceObject.rendererFederationError)('renderer components require native manifest publication.');
|
|
136
137
|
if (void 0 !== config.manifest && true !== config.manifest && !record(config.manifest)) throw (0, renderer_contract_namespaceObject.rendererFederationError)('native manifest options must be a boolean or record.');
|
|
137
138
|
const manifest = record(config.manifest) ? config.manifest : {};
|
|
@@ -96,6 +96,47 @@ function emittedBytes(result, name) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
class NativeDevelopment {
|
|
99
|
+
async captureFederationGraph(result) {
|
|
100
|
+
try {
|
|
101
|
+
const entryNames = Object.keys(this.options.getSessionIdentities().identities);
|
|
102
|
+
const assets = await (0, external_native_federation_dev_assets_js_namespaceObject.collectNativeFederationDevAssets)(result, entryNames, (name)=>emittedBytes(result, name));
|
|
103
|
+
if (0 === assets.size) return;
|
|
104
|
+
return {
|
|
105
|
+
assets,
|
|
106
|
+
graph: (0, external_native_federation_dev_assets_js_namespaceObject.nativeFederationDevGraph)(result)
|
|
107
|
+
};
|
|
108
|
+
} catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
retainFinishedGraphs() {
|
|
113
|
+
const pending = this.finishedFederationGraphs;
|
|
114
|
+
this.finishedFederationGraphs = [];
|
|
115
|
+
for (const finished of pending){
|
|
116
|
+
if (this.closed) return;
|
|
117
|
+
const revision = (0, external_native_federation_dev_assets_js_namespaceObject.nativeFederationDevRevision)(finished.assets);
|
|
118
|
+
const graphManifest = finished.graph?.immutableManifest;
|
|
119
|
+
try {
|
|
120
|
+
this.retainedFederationAssets = (0, external_native_federation_dev_assets_js_namespaceObject.retainNativeFederationDevAssets)(this.retainedFederationAssets, new Map([
|
|
121
|
+
...finished.assets
|
|
122
|
+
].map(([url, asset])=>[
|
|
123
|
+
url,
|
|
124
|
+
{
|
|
125
|
+
...asset,
|
|
126
|
+
revision,
|
|
127
|
+
graphManifest
|
|
128
|
+
}
|
|
129
|
+
])));
|
|
130
|
+
} catch (error) {
|
|
131
|
+
utils_namespaceObject.logger.warn('Native development could not retain a finished federation graph.', error);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
this.federationAssets = new Map([
|
|
135
|
+
...this.federationAssets,
|
|
136
|
+
...this.retainedFederationAssets
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
99
140
|
notify() {
|
|
100
141
|
for (const waiter of this.waiters)waiter();
|
|
101
142
|
this.waiters.clear();
|
|
@@ -277,6 +318,7 @@ class NativeDevelopment {
|
|
|
277
318
|
this.federationAssets = new Map();
|
|
278
319
|
this.federationCompilers = new Set();
|
|
279
320
|
this.retainedFederationAssets = new Map();
|
|
321
|
+
this.finishedFederationGraphs = [];
|
|
280
322
|
this.mutableClientAssets = new Set([
|
|
281
323
|
'renderer-assets.json'
|
|
282
324
|
]);
|
|
@@ -422,11 +464,16 @@ class NativeDevelopment {
|
|
|
422
464
|
this.invalidate();
|
|
423
465
|
});
|
|
424
466
|
candidate.hooks.failed.tap('UltraModernNativeDevelopment', (error)=>this.fail(error));
|
|
467
|
+
candidate.hooks.done.tapPromise(runHook, async (result)=>{
|
|
468
|
+
if (result.hasErrors()) return;
|
|
469
|
+
const finished = await this.captureFederationGraph(result);
|
|
470
|
+
if (finished) this.finishedFederationGraphs.push(finished);
|
|
471
|
+
});
|
|
425
472
|
}
|
|
426
473
|
});
|
|
427
474
|
api.onDevCompileDone(({ stats })=>{
|
|
428
475
|
const epoch = this.epoch;
|
|
429
|
-
const
|
|
476
|
+
const publishCurrent = async ()=>{
|
|
430
477
|
if (this.closed || epoch !== this.epoch) return;
|
|
431
478
|
const results = 'stats' in stats ? stats.stats : [
|
|
432
479
|
stats
|
|
@@ -440,6 +487,7 @@ class NativeDevelopment {
|
|
|
440
487
|
const publication = await this.publish(stats);
|
|
441
488
|
if (this.closed || epoch !== this.epoch) return;
|
|
442
489
|
this.retainedFederationAssets = publication.retainedFederationAssets;
|
|
490
|
+
this.retainFinishedGraphs();
|
|
443
491
|
this.federationAssets = new Map([
|
|
444
492
|
...publication.federationAssets,
|
|
445
493
|
...this.retainedFederationAssets
|
|
@@ -455,6 +503,13 @@ class NativeDevelopment {
|
|
|
455
503
|
api.logger.error('Native development could not load the compiled application.', error);
|
|
456
504
|
}
|
|
457
505
|
};
|
|
506
|
+
const publishNext = async ()=>{
|
|
507
|
+
try {
|
|
508
|
+
await publishCurrent();
|
|
509
|
+
} finally{
|
|
510
|
+
this.retainFinishedGraphs();
|
|
511
|
+
}
|
|
512
|
+
};
|
|
458
513
|
this.publication = this.publication.then(publishNext, publishNext);
|
|
459
514
|
return this.publication;
|
|
460
515
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
function validateRedactConfig(value) {
|
|
31
|
+
if (void 0 === value || 'boolean' == typeof value) return;
|
|
32
|
+
if (null !== value && 'object' == typeof value && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || null === Object.getPrototypeOf(value)) && Object.keys(value).every((key)=>'viewTransitions' === key) && (!('viewTransitions' in value) || void 0 === value.viewTransitions || 'boolean' == typeof value.viewTransitions)) return;
|
|
33
|
+
throw new Error('[ultramodern] redact must be a boolean or { viewTransitions?: boolean }. Use redact: false to keep real React.');
|
|
34
|
+
}
|
|
35
|
+
function usesRedact(config) {
|
|
36
|
+
validateRedactConfig(config.redact);
|
|
37
|
+
return false !== config.redact && !config.server?.rsc;
|
|
38
|
+
}
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
usesRedact: ()=>usesRedact,
|
|
41
|
+
validateRedactConfig: ()=>validateRedactConfig
|
|
42
|
+
});
|
|
43
|
+
exports.usesRedact = __webpack_exports__.usesRedact;
|
|
44
|
+
exports.validateRedactConfig = __webpack_exports__.validateRedactConfig;
|
|
45
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
46
|
+
"usesRedact",
|
|
47
|
+
"validateRedactConfig"
|
|
48
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
49
|
+
Object.defineProperty(exports, '__esModule', {
|
|
50
|
+
value: true
|
|
51
|
+
});
|
|
@@ -53,7 +53,9 @@ const rendererRegistrations = {
|
|
|
53
53
|
'@modern-js/runtime',
|
|
54
54
|
'@modern-js/plugin-tanstack',
|
|
55
55
|
'@modern-js/plugin-i18n',
|
|
56
|
-
'@tanstack/react-router'
|
|
56
|
+
'@tanstack/react-router',
|
|
57
|
+
'@tanstack/redact',
|
|
58
|
+
'rsbuild-redact-plugin'
|
|
57
59
|
],
|
|
58
60
|
ownedExtensions: []
|
|
59
61
|
},
|
|
@@ -91,6 +91,7 @@ const REACT_CLI_PLUGIN_NAMES = [
|
|
|
91
91
|
'@modern-js/plugin-document',
|
|
92
92
|
'@modern-js/ultramodern-router-integration',
|
|
93
93
|
'@modern-js/ultramodern-ssr-integration',
|
|
94
|
+
'@modern-js/ultramodern-redact-integration',
|
|
94
95
|
'@modern-js/ultramodern-i18n-integration',
|
|
95
96
|
'@modern-js/i18n-integration',
|
|
96
97
|
'@modern-js/plugin-i18n',
|
|
@@ -62,6 +62,7 @@ const server_plugin_resolution_js_namespaceObject = require("../../native-compos
|
|
|
62
62
|
const type_checker_js_namespaceObject = require("../../native-composition/type-checker.js");
|
|
63
63
|
const external_build_metadata_js_namespaceObject = require("./build-metadata.js");
|
|
64
64
|
const external_module_federation_recovery_plugin_js_namespaceObject = require("./module-federation-recovery-plugin.js");
|
|
65
|
+
const external_redact_integration_plugin_js_namespaceObject = require("./redact-integration-plugin.js");
|
|
65
66
|
const external_router_integration_plugin_js_namespaceObject = require("./router-integration-plugin.js");
|
|
66
67
|
const external_rsc_disabled_plugin_js_namespaceObject = require("./rsc-disabled-plugin.js");
|
|
67
68
|
const external_rsc_worker_integration_js_namespaceObject = require("./rsc-worker-integration.js");
|
|
@@ -118,6 +119,7 @@ const composeReactRenderer = (options = {})=>{
|
|
|
118
119
|
(0, i18n_integration_namespaceObject.ultramodernI18nIntegrationPlugin)(),
|
|
119
120
|
(0, external_router_integration_plugin_js_namespaceObject.ultramodernRouterIntegrationPlugin)(),
|
|
120
121
|
(0, external_ssr_integration_plugin_js_namespaceObject.ultramodernSSRIntegrationPlugin)(),
|
|
122
|
+
(0, external_redact_integration_plugin_js_namespaceObject.ultramodernRedactIntegrationPlugin)(),
|
|
121
123
|
(0, external_module_federation_recovery_plugin_js_namespaceObject.ultramodernModuleFederationRecoveryPlugin)(),
|
|
122
124
|
federationRenderer.plugin,
|
|
123
125
|
backend_federation_build_default()({
|
|
@@ -31,20 +31,28 @@ var __webpack_require__ = {};
|
|
|
31
31
|
var __webpack_exports__ = {};
|
|
32
32
|
__webpack_require__.r(__webpack_exports__);
|
|
33
33
|
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
resolveReactFederationCompatibility: ()=>resolveReactFederationCompatibility
|
|
34
|
+
resolveReactFederationCompatibility: ()=>resolveReactFederationCompatibility,
|
|
35
|
+
withReactRuntimeShared: ()=>withReactRuntimeShared
|
|
35
36
|
});
|
|
36
37
|
const external_node_module_namespaceObject = require("node:module");
|
|
37
38
|
const renderer_contract_namespaceObject = require("@modern-js/federation-runtime/renderer-contract");
|
|
39
|
+
const redact_config_js_namespaceObject = require("../../native-composition/redact-config.js");
|
|
38
40
|
const renderer_installed_profile_js_namespaceObject = require("../../native-composition/renderer-installed-profile.js");
|
|
39
41
|
const renderer_profile_js_namespaceObject = require("../../native-composition/renderer-profile.js");
|
|
40
|
-
|
|
42
|
+
const external_redact_integration_plugin_js_namespaceObject = require("./redact-integration-plugin.js");
|
|
43
|
+
function resolveReactFederationCompatibility(config = {}, require1 = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__)) {
|
|
41
44
|
const metadata = (0, renderer_profile_js_namespaceObject.resolveRendererProfileMetadata)('react');
|
|
42
|
-
const
|
|
43
|
-
const runtimeRequire = (0, external_node_module_namespaceObject.createRequire)(
|
|
45
|
+
const redacted = (0, redact_config_js_namespaceObject.usesRedact)(config);
|
|
46
|
+
const runtimeRequire = redacted ? require1 : (0, external_node_module_namespaceObject.createRequire)(require1.resolve('@modern-js/runtime/cli'));
|
|
47
|
+
const specifier = redacted ? '@tanstack/redact' : 'react';
|
|
44
48
|
const runtime = (0, renderer_installed_profile_js_namespaceObject.readRendererFrameworkPackage)({
|
|
45
|
-
specifier
|
|
46
|
-
filename: runtimeRequire.resolve(
|
|
49
|
+
specifier,
|
|
50
|
+
filename: runtimeRequire.resolve(specifier)
|
|
47
51
|
});
|
|
52
|
+
const effectiveRuntime = {
|
|
53
|
+
name: redacted ? specifier : runtime.name,
|
|
54
|
+
version: runtime.version
|
|
55
|
+
};
|
|
48
56
|
const bootstrap = metadata.frameworkPackages.find((owner)=>'@modern-js/runtime' === owner.specifier);
|
|
49
57
|
if (!bootstrap) throw (0, renderer_contract_namespaceObject.rendererFederationError)('the installed React bootstrap owner is absent.');
|
|
50
58
|
const { renderer, protocolVersion, compiler, hydration, router } = metadata.profile;
|
|
@@ -53,22 +61,58 @@ function resolveReactFederationCompatibility() {
|
|
|
53
61
|
renderer,
|
|
54
62
|
protocolVersion,
|
|
55
63
|
compiler,
|
|
56
|
-
hydration,
|
|
64
|
+
hydration: redacted ? effectiveRuntime : hydration,
|
|
57
65
|
router
|
|
58
66
|
},
|
|
59
|
-
runtime:
|
|
60
|
-
name: runtime.name,
|
|
61
|
-
version: runtime.version
|
|
62
|
-
},
|
|
67
|
+
runtime: effectiveRuntime,
|
|
63
68
|
bootstrap: {
|
|
64
69
|
name: bootstrap.name,
|
|
65
70
|
version: bootstrap.version
|
|
66
71
|
}
|
|
67
72
|
});
|
|
68
73
|
}
|
|
74
|
+
function withReactRuntimeShared(shared, compatibility, require1 = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__)) {
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const entry of Array.isArray(shared) ? shared : [
|
|
77
|
+
shared
|
|
78
|
+
])if ('string' == typeof entry) result[entry] = {};
|
|
79
|
+
else if (entry && 'object' == typeof entry) Object.assign(result, entry);
|
|
80
|
+
const redacted = '@tanstack/redact' === compatibility.runtime.name;
|
|
81
|
+
const aliases = redacted ? (0, external_redact_integration_plugin_js_namespaceObject.resolveRedactAliases)(require1) : {};
|
|
82
|
+
const reactSpelling = new Map();
|
|
83
|
+
for (const [request, target] of Object.entries(external_redact_integration_plugin_js_namespaceObject.REDACT_ALIASES))if (!reactSpelling.has(target)) reactSpelling.set(target, request);
|
|
84
|
+
const requests = redacted ? Object.keys(aliases).map((key)=>key.slice(0, -1)) : [
|
|
85
|
+
'react',
|
|
86
|
+
'react-dom',
|
|
87
|
+
'react-dom/client',
|
|
88
|
+
'react/jsx-runtime',
|
|
89
|
+
'react/jsx-dev-runtime'
|
|
90
|
+
];
|
|
91
|
+
for (const request of requests){
|
|
92
|
+
const shareKey = redacted ? reactSpelling.get(external_redact_integration_plugin_js_namespaceObject.REDACT_ALIASES[request] ?? request) ?? request : request;
|
|
93
|
+
const version = !redacted && request.startsWith('react-dom') ? compatibility.profile.hydration.version : compatibility.runtime.version;
|
|
94
|
+
const previous = result[request];
|
|
95
|
+
if (previous && 'object' == typeof previous && 'shareKey' in previous && previous.shareKey !== request && previous.shareKey !== shareKey) throw (0, renderer_contract_namespaceObject.rendererFederationError)(`conflicting runtime shareKey for ${request}; React and Redact containers cannot mix.`);
|
|
96
|
+
result[request] = {
|
|
97
|
+
...previous && 'object' == typeof previous ? previous : {},
|
|
98
|
+
...redacted ? {
|
|
99
|
+
import: aliases[`${request}$`],
|
|
100
|
+
shareKey
|
|
101
|
+
} : {},
|
|
102
|
+
version,
|
|
103
|
+
requiredVersion: version,
|
|
104
|
+
strictVersion: true,
|
|
105
|
+
singleton: true,
|
|
106
|
+
treeShaking: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
69
111
|
exports.resolveReactFederationCompatibility = __webpack_exports__.resolveReactFederationCompatibility;
|
|
112
|
+
exports.withReactRuntimeShared = __webpack_exports__.withReactRuntimeShared;
|
|
70
113
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
71
|
-
"resolveReactFederationCompatibility"
|
|
114
|
+
"resolveReactFederationCompatibility",
|
|
115
|
+
"withReactRuntimeShared"
|
|
72
116
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
73
117
|
Object.defineProperty(exports, '__esModule', {
|
|
74
118
|
value: true
|