@modern-js/uni-builder 2.69.5 → 2.69.7
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.
|
@@ -45,6 +45,7 @@ const CSS_RULE_NAMES = [
|
|
|
45
45
|
"scss",
|
|
46
46
|
"sass"
|
|
47
47
|
];
|
|
48
|
+
const createVirtualModule = (content) => `data:text/javascript,${encodeURIComponent(content)}`;
|
|
48
49
|
const checkReactVersionAtLeast19 = async (appDir) => {
|
|
49
50
|
const packageJsonPath = import_node_path.default.resolve(appDir, "package.json");
|
|
50
51
|
const packageJson = await import_fs_extra.default.readJSON(packageJsonPath);
|
|
@@ -71,7 +72,7 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
|
|
|
71
72
|
name: "uni-builder:rsc-rsbuild-plugin",
|
|
72
73
|
setup(api) {
|
|
73
74
|
api.modifyBundlerChain({
|
|
74
|
-
handler: async (chain, { isServer, CHAIN_ID }) => {
|
|
75
|
+
handler: async (chain, { isServer, CHAIN_ID, isWebWorker }) => {
|
|
75
76
|
if (!await checkReactVersionAtLeast19(appDir)) {
|
|
76
77
|
import_core.logger.error("Enable react server component, please make sure the react and react-dom versions are greater than or equal to 19.0.0");
|
|
77
78
|
process.exit(1);
|
|
@@ -149,11 +150,17 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
|
|
|
149
150
|
flightCssHandler();
|
|
150
151
|
jsHandler();
|
|
151
152
|
addServerRscPlugin();
|
|
152
|
-
} else {
|
|
153
|
+
} else if (!isWebWorker) {
|
|
153
154
|
chain.name("client");
|
|
154
155
|
chain.dependencies([
|
|
155
156
|
"server"
|
|
156
157
|
]);
|
|
158
|
+
const entries = chain.entryPoints.entries();
|
|
159
|
+
for (const entryName of Object.keys(entries)) {
|
|
160
|
+
const entryPoint = chain.entry(entryName);
|
|
161
|
+
const code = `window.__MODERN_JS_ENTRY_NAME="${entryName}";`;
|
|
162
|
+
entryPoint.add(createVirtualModule(code));
|
|
163
|
+
}
|
|
157
164
|
addRscClientLoader();
|
|
158
165
|
addRscClientPlugin();
|
|
159
166
|
}
|
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(rsc_client_plugin_exports);
|
|
|
24
24
|
var import_common = require("../common");
|
|
25
25
|
class RscClientPlugin {
|
|
26
26
|
apply(compiler) {
|
|
27
|
-
const { AsyncDependenciesBlock,
|
|
27
|
+
const { AsyncDependenciesBlock, WebpackError, dependencies: { ModuleDependency, NullDependency }, sources: { RawSource } } = compiler.webpack;
|
|
28
28
|
const ssrManifest = {
|
|
29
29
|
moduleMap: {},
|
|
30
30
|
moduleLoading: null,
|
|
@@ -35,7 +35,7 @@ class RscClientPlugin {
|
|
|
35
35
|
return `client-reference`;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const getEntryModule = (compilation) => {
|
|
38
|
+
const getEntryModule = (compilation, type) => {
|
|
39
39
|
const entryModules = [];
|
|
40
40
|
for (const [, entryValue] of compilation.entries.entries()) {
|
|
41
41
|
const entryDependency = entryValue.dependencies.find((dependency) => dependency.constructor.name === `EntryDependency`);
|
|
@@ -49,7 +49,9 @@ class RscClientPlugin {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
if (entryModules.length === 0) {
|
|
52
|
-
|
|
52
|
+
if (type === "finishMake") {
|
|
53
|
+
compilation.errors.push(new WebpackError(`Could not find any entries in the compilation.`));
|
|
54
|
+
}
|
|
53
55
|
return [];
|
|
54
56
|
}
|
|
55
57
|
return entryModules;
|
|
@@ -74,7 +76,7 @@ class RscClientPlugin {
|
|
|
74
76
|
};
|
|
75
77
|
compiler.hooks.finishMake.tap(RscClientPlugin.name, (compilation) => {
|
|
76
78
|
if (compiler.watchMode) {
|
|
77
|
-
const entryModules = getEntryModule(compilation);
|
|
79
|
+
const entryModules = getEntryModule(compilation, "finishMake");
|
|
78
80
|
for (const entryModule of entryModules) {
|
|
79
81
|
entryModule.blocks = entryModule.blocks.filter((block) => block.dependencies.some((dependency) => !(dependency instanceof ClientReferenceDependency) || this.clientReferencesMap.has(dependency.request)));
|
|
80
82
|
addClientReferencesChunks(entryModule);
|
|
@@ -84,29 +86,13 @@ class RscClientPlugin {
|
|
|
84
86
|
compiler.hooks.compilation.tap(RscClientPlugin.name, (compilation, { normalModuleFactory }) => {
|
|
85
87
|
compilation.dependencyFactories.set(ClientReferenceDependency, normalModuleFactory);
|
|
86
88
|
compilation.dependencyTemplates.set(ClientReferenceDependency, new NullDependency.Template());
|
|
87
|
-
class EntryNameRuntimeModule extends compiler.webpack.RuntimeModule {
|
|
88
|
-
generate() {
|
|
89
|
-
return `window.__MODERN_JS_ENTRY_NAME="${this.entryName}";`;
|
|
90
|
-
}
|
|
91
|
-
constructor(entryName) {
|
|
92
|
-
super("entry-name", 10);
|
|
93
|
-
this.entryName = entryName;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.ensureChunk).tap(RscClientPlugin.name, (chunk, set) => {
|
|
97
|
-
Array.from(compilation.entrypoints.entries()).forEach(([entryName, entrypoint]) => {
|
|
98
|
-
if (entrypoint.chunks.includes(chunk)) {
|
|
99
|
-
compilation.addRuntimeModule(chunk, new EntryNameRuntimeModule(entryName));
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
89
|
});
|
|
104
90
|
compiler.hooks.thisCompilation.tap(RscClientPlugin.name, (compilation, { normalModuleFactory }) => {
|
|
105
91
|
this.styles = import_common.sharedData.get("styles");
|
|
106
92
|
this.clientReferencesMap = import_common.sharedData.get("clientReferencesMap");
|
|
107
93
|
const onNormalModuleFactoryParser = (parser) => {
|
|
108
94
|
parser.hooks.program.tap(RscClientPlugin.name, () => {
|
|
109
|
-
const entryModules = getEntryModule(compilation);
|
|
95
|
+
const entryModules = getEntryModule(compilation, "jsParse");
|
|
110
96
|
for (const entryModule of entryModules) {
|
|
111
97
|
if (entryModule === parser.state.module) {
|
|
112
98
|
addClientReferencesChunks(entryModule);
|
|
@@ -118,8 +104,8 @@ class RscClientPlugin {
|
|
|
118
104
|
normalModuleFactory.hooks.parser.for(`javascript/dynamic`).tap(`HarmonyModulesPlugin`, onNormalModuleFactoryParser);
|
|
119
105
|
normalModuleFactory.hooks.parser.for(`javascript/esm`).tap(`HarmonyModulesPlugin`, onNormalModuleFactoryParser);
|
|
120
106
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(RscClientPlugin.name, (_chunk, runtimeRequirements) => {
|
|
121
|
-
runtimeRequirements.add(RuntimeGlobals.ensureChunk);
|
|
122
|
-
runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
|
|
107
|
+
runtimeRequirements.add(compiler.webpack.RuntimeGlobals.ensureChunk);
|
|
108
|
+
runtimeRequirements.add(compiler.webpack.RuntimeGlobals.compatGetDefaultExport);
|
|
123
109
|
});
|
|
124
110
|
compilation.hooks.processAssets.tap(RscClientPlugin.name, () => {
|
|
125
111
|
const clientManifest = {};
|
|
@@ -38,7 +38,7 @@ const hasExtension = (filePath) => {
|
|
|
38
38
|
};
|
|
39
39
|
class RspackRscClientPlugin {
|
|
40
40
|
apply(compiler) {
|
|
41
|
-
const { EntryPlugin, RuntimeGlobals,
|
|
41
|
+
const { EntryPlugin, RuntimeGlobals, WebpackError, sources: { RawSource } } = compiler.webpack;
|
|
42
42
|
const ssrManifest = {
|
|
43
43
|
moduleMap: {},
|
|
44
44
|
moduleLoading: null,
|
|
@@ -122,24 +122,6 @@ class RspackRscClientPlugin {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
|
-
compiler.hooks.compilation.tap(RspackRscClientPlugin.name, (compilation, { normalModuleFactory }) => {
|
|
126
|
-
class EntryNameRuntimeModule extends RuntimeModule {
|
|
127
|
-
generate() {
|
|
128
|
-
return `window.__MODERN_JS_ENTRY_NAME="${this.entryName}";`;
|
|
129
|
-
}
|
|
130
|
-
constructor(entryName) {
|
|
131
|
-
super("entry-name", 10);
|
|
132
|
-
this.entryName = entryName;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.ensureChunk).tap(RspackRscClientPlugin.name, (chunk, set) => {
|
|
136
|
-
Array.from(compilation.entrypoints.entries()).forEach(([entryName, entrypoint]) => {
|
|
137
|
-
if (entrypoint.chunks.includes(chunk)) {
|
|
138
|
-
compilation.addRuntimeModule(chunk, new EntryNameRuntimeModule(entryName));
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
125
|
compiler.hooks.thisCompilation.tap(RspackRscClientPlugin.name, (compilation, { normalModuleFactory }) => {
|
|
144
126
|
this.styles = import_common.sharedData.get("styles");
|
|
145
127
|
this.clientReferencesMap = import_common.sharedData.get("clientReferencesMap");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.69.
|
|
3
|
+
"version": "2.69.7",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@babel/preset-react": "^7.22.15",
|
|
41
41
|
"@babel/types": "^7.26.0",
|
|
42
42
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.16",
|
|
43
|
-
"@rsbuild/core": "1.
|
|
43
|
+
"@rsbuild/core": "1.7.1",
|
|
44
44
|
"@rsbuild/plugin-assets-retry": "1.5.0",
|
|
45
45
|
"@rsbuild/plugin-babel": "1.0.6",
|
|
46
46
|
"@rsbuild/plugin-check-syntax": "1.6.0",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"@rsbuild/plugin-rem": "1.0.4",
|
|
52
52
|
"@rsbuild/plugin-sass": "1.4.0",
|
|
53
53
|
"@rsbuild/plugin-source-build": "1.0.3",
|
|
54
|
-
"@rsbuild/plugin-styled-components": "1.
|
|
54
|
+
"@rsbuild/plugin-styled-components": "1.6.0",
|
|
55
55
|
"@rsbuild/plugin-svgr": "1.2.3",
|
|
56
56
|
"@rsbuild/plugin-toml": "1.1.1",
|
|
57
57
|
"@rsbuild/plugin-type-check": "1.3.2",
|
|
58
58
|
"@rsbuild/plugin-typed-css-modules": "1.2.0",
|
|
59
59
|
"@rsbuild/plugin-yaml": "1.0.3",
|
|
60
60
|
"@rsbuild/webpack": "1.6.1",
|
|
61
|
-
"@swc/core": "1.
|
|
61
|
+
"@swc/core": "1.15.8",
|
|
62
62
|
"@swc/helpers": "^0.5.17",
|
|
63
63
|
"autoprefixer": "10.4.21",
|
|
64
64
|
"babel-loader": "9.2.1",
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"ts-loader": "9.4.4",
|
|
91
91
|
"webpack": "^5.103.0",
|
|
92
92
|
"webpack-subresource-integrity": "5.1.0",
|
|
93
|
-
"@modern-js/babel-preset": "2.69.
|
|
94
|
-
"@modern-js/flight-server-transform-plugin": "2.69.
|
|
95
|
-
"@modern-js/utils": "2.69.
|
|
93
|
+
"@modern-js/babel-preset": "2.69.7",
|
|
94
|
+
"@modern-js/flight-server-transform-plugin": "2.69.7",
|
|
95
|
+
"@modern-js/utils": "2.69.7"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@rsbuild/plugin-webpack-swc": "1.1.2",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"react-dom": "^18.2.0",
|
|
104
104
|
"terser": "^5.31.1",
|
|
105
105
|
"typescript": "^5.3.0",
|
|
106
|
-
"@modern-js/types": "2.69.
|
|
106
|
+
"@modern-js/types": "2.69.7",
|
|
107
107
|
"@scripts/build": "2.66.0",
|
|
108
108
|
"@scripts/vitest-config": "2.66.0"
|
|
109
109
|
},
|