@bleedingdev/modern-js-builder 3.9.0-ultramodern.4 → 3.9.0-ultramodern.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createBuilder.js +15 -6
- package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +68 -0
- package/dist/esm/createBuilder.mjs +16 -7
- package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +20 -0
- package/dist/esm-node/createBuilder.mjs +16 -7
- package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +25 -0
- package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +2 -0
- package/package.json +3 -4
- package/dist/cjs/shared/rsc/rscDisabledRuntime.js +0 -117
- package/dist/esm/shared/rsc/rscDisabledRuntime.mjs +0 -79
- package/dist/esm-node/shared/rsc/rscDisabledRuntime.mjs +0 -81
- package/dist/types/shared/rsc/rscDisabledRuntime.d.ts +0 -2
|
@@ -34,7 +34,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
34
34
|
const core_namespaceObject = require("@rsbuild/core");
|
|
35
35
|
const rscConfig_js_namespaceObject = require("./plugins/rscConfig.js");
|
|
36
36
|
const parseCommonConfig_js_namespaceObject = require("./shared/parseCommonConfig.js");
|
|
37
|
-
const
|
|
37
|
+
const rscClientBrowserFallback_js_namespaceObject = require("./shared/rsc/rscClientBrowserFallback.js");
|
|
38
38
|
async function parseConfig(builderConfig, options) {
|
|
39
39
|
builderConfig.performance ??= {};
|
|
40
40
|
builderConfig.performance.buildCache ??= true;
|
|
@@ -62,10 +62,7 @@ async function parseConfig(builderConfig, options) {
|
|
|
62
62
|
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
63
63
|
const rscPlugins = await (0, rscConfig_js_namespaceObject.getRscPlugins)(enableRsc, options.internalDirectory, rscEnvironments);
|
|
64
64
|
rsbuildPlugins.push(...rscPlugins);
|
|
65
|
-
} else
|
|
66
|
-
...rsbuildConfig.plugins ?? [],
|
|
67
|
-
(0, rscDisabledRuntime_js_namespaceObject.rscDisabledRuntimePlugin)()
|
|
68
|
-
];
|
|
65
|
+
} else rsbuildPlugins.push((0, rscClientBrowserFallback_js_namespaceObject.rscClientBrowserFallbackPlugin)());
|
|
69
66
|
return {
|
|
70
67
|
rsbuildConfig,
|
|
71
68
|
rsbuildPlugins
|
|
@@ -83,7 +80,19 @@ async function createRspackBuilder(options) {
|
|
|
83
80
|
];
|
|
84
81
|
const rsbuild = await (0, core_namespaceObject.createRsbuild)({
|
|
85
82
|
cwd,
|
|
86
|
-
rsbuildConfig
|
|
83
|
+
rsbuildConfig: (0, core_namespaceObject.mergeRsbuildConfig)({
|
|
84
|
+
tools: {
|
|
85
|
+
rspack: {
|
|
86
|
+
module: {
|
|
87
|
+
parser: {
|
|
88
|
+
javascript: {
|
|
89
|
+
createRequire: true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, rsbuildConfig)
|
|
87
96
|
});
|
|
88
97
|
return {
|
|
89
98
|
...rsbuild
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
rscClientBrowserFallbackPlugin: ()=>rscClientBrowserFallbackPlugin
|
|
41
|
+
});
|
|
42
|
+
const external_path_namespaceObject = require("path");
|
|
43
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
44
|
+
function rscClientBrowserFallbackPlugin() {
|
|
45
|
+
return {
|
|
46
|
+
name: 'builder:rsc-client-browser-fallback',
|
|
47
|
+
setup (api) {
|
|
48
|
+
let emptyModulePath;
|
|
49
|
+
try {
|
|
50
|
+
emptyModulePath = require.resolve('./rscEmptyModule');
|
|
51
|
+
} catch {
|
|
52
|
+
emptyModulePath = external_path_default().resolve(__dirname, 'rscEmptyModule');
|
|
53
|
+
}
|
|
54
|
+
api.modifyRspackConfig((config)=>{
|
|
55
|
+
config.resolve ??= {};
|
|
56
|
+
config.resolve.fallback ??= {};
|
|
57
|
+
config.resolve.fallback['react-server-dom-rspack/client.browser'] = emptyModulePath;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.rscClientBrowserFallbackPlugin = __webpack_exports__.rscClientBrowserFallbackPlugin;
|
|
63
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
+
"rscClientBrowserFallbackPlugin"
|
|
65
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
|
+
Object.defineProperty(exports, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createRsbuild } from "@rsbuild/core";
|
|
1
|
+
import { createRsbuild, mergeRsbuildConfig } from "@rsbuild/core";
|
|
2
2
|
import { getRscPlugins } from "./plugins/rscConfig.mjs";
|
|
3
3
|
import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { rscClientBrowserFallbackPlugin } from "./shared/rsc/rscClientBrowserFallback.mjs";
|
|
5
5
|
async function parseConfig(builderConfig, options) {
|
|
6
6
|
builderConfig.performance ??= {};
|
|
7
7
|
builderConfig.performance.buildCache ??= true;
|
|
@@ -29,10 +29,7 @@ async function parseConfig(builderConfig, options) {
|
|
|
29
29
|
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
30
30
|
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
31
31
|
rsbuildPlugins.push(...rscPlugins);
|
|
32
|
-
} else
|
|
33
|
-
...rsbuildConfig.plugins ?? [],
|
|
34
|
-
rscDisabledRuntimePlugin()
|
|
35
|
-
];
|
|
32
|
+
} else rsbuildPlugins.push(rscClientBrowserFallbackPlugin());
|
|
36
33
|
return {
|
|
37
34
|
rsbuildConfig,
|
|
38
35
|
rsbuildPlugins
|
|
@@ -50,7 +47,19 @@ async function createRspackBuilder(options) {
|
|
|
50
47
|
];
|
|
51
48
|
const rsbuild = await createRsbuild({
|
|
52
49
|
cwd,
|
|
53
|
-
rsbuildConfig
|
|
50
|
+
rsbuildConfig: mergeRsbuildConfig({
|
|
51
|
+
tools: {
|
|
52
|
+
rspack: {
|
|
53
|
+
module: {
|
|
54
|
+
parser: {
|
|
55
|
+
javascript: {
|
|
56
|
+
createRequire: true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, rsbuildConfig)
|
|
54
63
|
});
|
|
55
64
|
return {
|
|
56
65
|
...rsbuild
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
function rscClientBrowserFallbackPlugin() {
|
|
3
|
+
return {
|
|
4
|
+
name: 'builder:rsc-client-browser-fallback',
|
|
5
|
+
setup (api) {
|
|
6
|
+
let emptyModulePath;
|
|
7
|
+
try {
|
|
8
|
+
emptyModulePath = require.resolve('./rscEmptyModule');
|
|
9
|
+
} catch {
|
|
10
|
+
emptyModulePath = path.resolve(__dirname, 'rscEmptyModule');
|
|
11
|
+
}
|
|
12
|
+
api.modifyRspackConfig((config)=>{
|
|
13
|
+
config.resolve ??= {};
|
|
14
|
+
config.resolve.fallback ??= {};
|
|
15
|
+
config.resolve.fallback['react-server-dom-rspack/client.browser'] = emptyModulePath;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export { rscClientBrowserFallbackPlugin };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { createRsbuild } from "@rsbuild/core";
|
|
2
|
+
import { createRsbuild, mergeRsbuildConfig } from "@rsbuild/core";
|
|
3
3
|
import { getRscPlugins } from "./plugins/rscConfig.mjs";
|
|
4
4
|
import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { rscClientBrowserFallbackPlugin } from "./shared/rsc/rscClientBrowserFallback.mjs";
|
|
6
6
|
async function parseConfig(builderConfig, options) {
|
|
7
7
|
builderConfig.performance ??= {};
|
|
8
8
|
builderConfig.performance.buildCache ??= true;
|
|
@@ -30,10 +30,7 @@ async function parseConfig(builderConfig, options) {
|
|
|
30
30
|
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
31
31
|
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
32
32
|
rsbuildPlugins.push(...rscPlugins);
|
|
33
|
-
} else
|
|
34
|
-
...rsbuildConfig.plugins ?? [],
|
|
35
|
-
rscDisabledRuntimePlugin()
|
|
36
|
-
];
|
|
33
|
+
} else rsbuildPlugins.push(rscClientBrowserFallbackPlugin());
|
|
37
34
|
return {
|
|
38
35
|
rsbuildConfig,
|
|
39
36
|
rsbuildPlugins
|
|
@@ -51,7 +48,19 @@ async function createRspackBuilder(options) {
|
|
|
51
48
|
];
|
|
52
49
|
const rsbuild = await createRsbuild({
|
|
53
50
|
cwd,
|
|
54
|
-
rsbuildConfig
|
|
51
|
+
rsbuildConfig: mergeRsbuildConfig({
|
|
52
|
+
tools: {
|
|
53
|
+
rspack: {
|
|
54
|
+
module: {
|
|
55
|
+
parser: {
|
|
56
|
+
javascript: {
|
|
57
|
+
createRequire: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, rsbuildConfig)
|
|
55
64
|
});
|
|
56
65
|
return {
|
|
57
66
|
...rsbuild
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
6
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
7
|
+
function rscClientBrowserFallbackPlugin() {
|
|
8
|
+
return {
|
|
9
|
+
name: 'builder:rsc-client-browser-fallback',
|
|
10
|
+
setup (api) {
|
|
11
|
+
let emptyModulePath;
|
|
12
|
+
try {
|
|
13
|
+
emptyModulePath = require.resolve('./rscEmptyModule');
|
|
14
|
+
} catch {
|
|
15
|
+
emptyModulePath = path.resolve(__rspack_import_meta_dirname__, 'rscEmptyModule');
|
|
16
|
+
}
|
|
17
|
+
api.modifyRspackConfig((config)=>{
|
|
18
|
+
config.resolve ??= {};
|
|
19
|
+
config.resolve.fallback ??= {};
|
|
20
|
+
config.resolve.fallback['react-server-dom-rspack/client.browser'] = emptyModulePath;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export { rscClientBrowserFallbackPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-builder",
|
|
3
|
-
"version": "3.9.0-ultramodern.
|
|
3
|
+
"version": "3.9.0-ultramodern.5",
|
|
4
4
|
"description": "A builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
30
|
-
"@modern-js/
|
|
31
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.4",
|
|
30
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.5",
|
|
32
31
|
"@rsbuild/core": "2.2.3",
|
|
33
32
|
"@rsbuild/plugin-assets-retry": "2.0.2",
|
|
34
33
|
"@rsbuild/plugin-check-syntax": "2.0.1",
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"ts-deepmerge": "8.0.0"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
64
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.5",
|
|
66
65
|
"@rsdoctor/rspack-plugin": "^1.6.3",
|
|
67
66
|
"@rslib/core": "1.0.0",
|
|
68
67
|
"@scripts/rstest-config": "2.66.0",
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
const disabledRuntimeModules = {
|
|
31
|
-
'react-server-dom-rspack/client.browser': './rscDisabledClientBrowserRuntime',
|
|
32
|
-
'react-server-dom-rspack/client.edge': './rscDisabledClientEdgeRuntime',
|
|
33
|
-
'react-server-dom-rspack/client.node': './rscDisabledClientNodeRuntime',
|
|
34
|
-
'react-server-dom-rspack/server.edge': './rscDisabledServerEdgeRuntime',
|
|
35
|
-
'react-server-dom-rspack/server.node': './rscDisabledServerNodeRuntime'
|
|
36
|
-
};
|
|
37
|
-
const disabledRuntimeRequests = Object.keys(disabledRuntimeModules);
|
|
38
|
-
function aliasMatchesRequest(aliasName, request) {
|
|
39
|
-
const exact = aliasName.endsWith('$');
|
|
40
|
-
const normalizedName = exact ? aliasName.slice(0, -1) : aliasName;
|
|
41
|
-
return exact ? normalizedName === request : request === normalizedName || request.startsWith(`${normalizedName}/`);
|
|
42
|
-
}
|
|
43
|
-
function objectAliasMatchesDisabledRuntime(aliasName) {
|
|
44
|
-
return disabledRuntimeRequests.some((request)=>aliasMatchesRequest(aliasName, request));
|
|
45
|
-
}
|
|
46
|
-
function arrayAliasMatchesDisabledRuntime(alias) {
|
|
47
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
48
|
-
return objectAliasMatchesDisabledRuntime(aliasName);
|
|
49
|
-
}
|
|
50
|
-
function normalizeArrayAliases(aliases) {
|
|
51
|
-
const normalized = {};
|
|
52
|
-
for (const alias of aliases){
|
|
53
|
-
if (arrayAliasMatchesDisabledRuntime(alias)) continue;
|
|
54
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
55
|
-
const existing = normalized[aliasName];
|
|
56
|
-
if (void 0 === existing) {
|
|
57
|
-
normalized[aliasName] = alias.alias;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
normalized[aliasName] = [
|
|
61
|
-
...Array.isArray(existing) ? existing : [
|
|
62
|
-
existing
|
|
63
|
-
],
|
|
64
|
-
...Array.isArray(alias.alias) ? alias.alias : [
|
|
65
|
-
alias.alias
|
|
66
|
-
]
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
return normalized;
|
|
70
|
-
}
|
|
71
|
-
function resolveDisabledRuntimeModules() {
|
|
72
|
-
return Object.fromEntries(Object.entries(disabledRuntimeModules).map(([request, moduleRequest])=>[
|
|
73
|
-
`${request}$`,
|
|
74
|
-
require.resolve(`@modern-js/runtime-extensions/rsc-disabled/${moduleRequest.slice(2)}`)
|
|
75
|
-
]));
|
|
76
|
-
}
|
|
77
|
-
function applyDisabledRuntimeAliases(config, disabledAliases) {
|
|
78
|
-
config.resolve ??= {};
|
|
79
|
-
if (Array.isArray(config.resolve.alias)) config.resolve.alias = {
|
|
80
|
-
...disabledAliases,
|
|
81
|
-
...normalizeArrayAliases(config.resolve.alias)
|
|
82
|
-
};
|
|
83
|
-
else config.resolve.alias = {
|
|
84
|
-
...disabledAliases,
|
|
85
|
-
...Object.fromEntries(Object.entries(config.resolve.alias ?? {}).filter(([aliasName])=>!objectAliasMatchesDisabledRuntime(aliasName)))
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function rscDisabledRuntimePlugin() {
|
|
89
|
-
return {
|
|
90
|
-
name: 'builder:rsc-disabled-runtime',
|
|
91
|
-
setup (api) {
|
|
92
|
-
const disabledAliases = resolveDisabledRuntimeModules();
|
|
93
|
-
api.modifyRspackConfig({
|
|
94
|
-
order: 'post',
|
|
95
|
-
handler (config) {
|
|
96
|
-
applyDisabledRuntimeAliases(config, disabledAliases);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
api.onBeforeCreateCompiler({
|
|
100
|
-
order: 'post',
|
|
101
|
-
handler ({ bundlerConfigs }) {
|
|
102
|
-
for (const config of bundlerConfigs)applyDisabledRuntimeAliases(config, disabledAliases);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
109
|
-
rscDisabledRuntimePlugin: ()=>rscDisabledRuntimePlugin
|
|
110
|
-
});
|
|
111
|
-
exports.rscDisabledRuntimePlugin = __webpack_exports__.rscDisabledRuntimePlugin;
|
|
112
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
113
|
-
"rscDisabledRuntimePlugin"
|
|
114
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
115
|
-
Object.defineProperty(exports, '__esModule', {
|
|
116
|
-
value: true
|
|
117
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const disabledRuntimeModules = {
|
|
2
|
-
'react-server-dom-rspack/client.browser': './rscDisabledClientBrowserRuntime',
|
|
3
|
-
'react-server-dom-rspack/client.edge': './rscDisabledClientEdgeRuntime',
|
|
4
|
-
'react-server-dom-rspack/client.node': './rscDisabledClientNodeRuntime',
|
|
5
|
-
'react-server-dom-rspack/server.edge': './rscDisabledServerEdgeRuntime',
|
|
6
|
-
'react-server-dom-rspack/server.node': './rscDisabledServerNodeRuntime'
|
|
7
|
-
};
|
|
8
|
-
const disabledRuntimeRequests = Object.keys(disabledRuntimeModules);
|
|
9
|
-
function aliasMatchesRequest(aliasName, request) {
|
|
10
|
-
const exact = aliasName.endsWith('$');
|
|
11
|
-
const normalizedName = exact ? aliasName.slice(0, -1) : aliasName;
|
|
12
|
-
return exact ? normalizedName === request : request === normalizedName || request.startsWith(`${normalizedName}/`);
|
|
13
|
-
}
|
|
14
|
-
function objectAliasMatchesDisabledRuntime(aliasName) {
|
|
15
|
-
return disabledRuntimeRequests.some((request)=>aliasMatchesRequest(aliasName, request));
|
|
16
|
-
}
|
|
17
|
-
function arrayAliasMatchesDisabledRuntime(alias) {
|
|
18
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
19
|
-
return objectAliasMatchesDisabledRuntime(aliasName);
|
|
20
|
-
}
|
|
21
|
-
function normalizeArrayAliases(aliases) {
|
|
22
|
-
const normalized = {};
|
|
23
|
-
for (const alias of aliases){
|
|
24
|
-
if (arrayAliasMatchesDisabledRuntime(alias)) continue;
|
|
25
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
26
|
-
const existing = normalized[aliasName];
|
|
27
|
-
if (void 0 === existing) {
|
|
28
|
-
normalized[aliasName] = alias.alias;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
normalized[aliasName] = [
|
|
32
|
-
...Array.isArray(existing) ? existing : [
|
|
33
|
-
existing
|
|
34
|
-
],
|
|
35
|
-
...Array.isArray(alias.alias) ? alias.alias : [
|
|
36
|
-
alias.alias
|
|
37
|
-
]
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
return normalized;
|
|
41
|
-
}
|
|
42
|
-
function resolveDisabledRuntimeModules() {
|
|
43
|
-
return Object.fromEntries(Object.entries(disabledRuntimeModules).map(([request, moduleRequest])=>[
|
|
44
|
-
`${request}$`,
|
|
45
|
-
require.resolve(`@modern-js/runtime-extensions/rsc-disabled/${moduleRequest.slice(2)}`)
|
|
46
|
-
]));
|
|
47
|
-
}
|
|
48
|
-
function applyDisabledRuntimeAliases(config, disabledAliases) {
|
|
49
|
-
config.resolve ??= {};
|
|
50
|
-
if (Array.isArray(config.resolve.alias)) config.resolve.alias = {
|
|
51
|
-
...disabledAliases,
|
|
52
|
-
...normalizeArrayAliases(config.resolve.alias)
|
|
53
|
-
};
|
|
54
|
-
else config.resolve.alias = {
|
|
55
|
-
...disabledAliases,
|
|
56
|
-
...Object.fromEntries(Object.entries(config.resolve.alias ?? {}).filter(([aliasName])=>!objectAliasMatchesDisabledRuntime(aliasName)))
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function rscDisabledRuntimePlugin() {
|
|
60
|
-
return {
|
|
61
|
-
name: 'builder:rsc-disabled-runtime',
|
|
62
|
-
setup (api) {
|
|
63
|
-
const disabledAliases = resolveDisabledRuntimeModules();
|
|
64
|
-
api.modifyRspackConfig({
|
|
65
|
-
order: 'post',
|
|
66
|
-
handler (config) {
|
|
67
|
-
applyDisabledRuntimeAliases(config, disabledAliases);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
api.onBeforeCreateCompiler({
|
|
71
|
-
order: 'post',
|
|
72
|
-
handler ({ bundlerConfigs }) {
|
|
73
|
-
for (const config of bundlerConfigs)applyDisabledRuntimeAliases(config, disabledAliases);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
export { rscDisabledRuntimePlugin };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import __rslib_shim_module__ from "node:module";
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
-
const disabledRuntimeModules = {
|
|
4
|
-
'react-server-dom-rspack/client.browser': './rscDisabledClientBrowserRuntime',
|
|
5
|
-
'react-server-dom-rspack/client.edge': './rscDisabledClientEdgeRuntime',
|
|
6
|
-
'react-server-dom-rspack/client.node': './rscDisabledClientNodeRuntime',
|
|
7
|
-
'react-server-dom-rspack/server.edge': './rscDisabledServerEdgeRuntime',
|
|
8
|
-
'react-server-dom-rspack/server.node': './rscDisabledServerNodeRuntime'
|
|
9
|
-
};
|
|
10
|
-
const disabledRuntimeRequests = Object.keys(disabledRuntimeModules);
|
|
11
|
-
function aliasMatchesRequest(aliasName, request) {
|
|
12
|
-
const exact = aliasName.endsWith('$');
|
|
13
|
-
const normalizedName = exact ? aliasName.slice(0, -1) : aliasName;
|
|
14
|
-
return exact ? normalizedName === request : request === normalizedName || request.startsWith(`${normalizedName}/`);
|
|
15
|
-
}
|
|
16
|
-
function objectAliasMatchesDisabledRuntime(aliasName) {
|
|
17
|
-
return disabledRuntimeRequests.some((request)=>aliasMatchesRequest(aliasName, request));
|
|
18
|
-
}
|
|
19
|
-
function arrayAliasMatchesDisabledRuntime(alias) {
|
|
20
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
21
|
-
return objectAliasMatchesDisabledRuntime(aliasName);
|
|
22
|
-
}
|
|
23
|
-
function normalizeArrayAliases(aliases) {
|
|
24
|
-
const normalized = {};
|
|
25
|
-
for (const alias of aliases){
|
|
26
|
-
if (arrayAliasMatchesDisabledRuntime(alias)) continue;
|
|
27
|
-
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
28
|
-
const existing = normalized[aliasName];
|
|
29
|
-
if (void 0 === existing) {
|
|
30
|
-
normalized[aliasName] = alias.alias;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
normalized[aliasName] = [
|
|
34
|
-
...Array.isArray(existing) ? existing : [
|
|
35
|
-
existing
|
|
36
|
-
],
|
|
37
|
-
...Array.isArray(alias.alias) ? alias.alias : [
|
|
38
|
-
alias.alias
|
|
39
|
-
]
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
return normalized;
|
|
43
|
-
}
|
|
44
|
-
function resolveDisabledRuntimeModules() {
|
|
45
|
-
return Object.fromEntries(Object.entries(disabledRuntimeModules).map(([request, moduleRequest])=>[
|
|
46
|
-
`${request}$`,
|
|
47
|
-
require.resolve(`@modern-js/runtime-extensions/rsc-disabled/${moduleRequest.slice(2)}`)
|
|
48
|
-
]));
|
|
49
|
-
}
|
|
50
|
-
function applyDisabledRuntimeAliases(config, disabledAliases) {
|
|
51
|
-
config.resolve ??= {};
|
|
52
|
-
if (Array.isArray(config.resolve.alias)) config.resolve.alias = {
|
|
53
|
-
...disabledAliases,
|
|
54
|
-
...normalizeArrayAliases(config.resolve.alias)
|
|
55
|
-
};
|
|
56
|
-
else config.resolve.alias = {
|
|
57
|
-
...disabledAliases,
|
|
58
|
-
...Object.fromEntries(Object.entries(config.resolve.alias ?? {}).filter(([aliasName])=>!objectAliasMatchesDisabledRuntime(aliasName)))
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function rscDisabledRuntimePlugin() {
|
|
62
|
-
return {
|
|
63
|
-
name: 'builder:rsc-disabled-runtime',
|
|
64
|
-
setup (api) {
|
|
65
|
-
const disabledAliases = resolveDisabledRuntimeModules();
|
|
66
|
-
api.modifyRspackConfig({
|
|
67
|
-
order: 'post',
|
|
68
|
-
handler (config) {
|
|
69
|
-
applyDisabledRuntimeAliases(config, disabledAliases);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
api.onBeforeCreateCompiler({
|
|
73
|
-
order: 'post',
|
|
74
|
-
handler ({ bundlerConfigs }) {
|
|
75
|
-
for (const config of bundlerConfigs)applyDisabledRuntimeAliases(config, disabledAliases);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
export { rscDisabledRuntimePlugin };
|