@rsbuild/core 0.4.14 → 0.5.0
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/cli/commands.js +1 -1
- package/dist/cli/prepare.js +2 -2
- package/dist/client/hmr.mjs +449 -230
- package/dist/createRsbuild.js +2 -2
- package/dist/index.js +1 -1
- package/dist/loadEnv.js +7 -7
- package/dist/mergeConfig.js +2 -2
- package/dist/pluginManager.js +19 -15
- package/dist/plugins/basic.js +2 -0
- package/dist/plugins/entry.js +2 -2
- package/dist/plugins/externals.js +2 -2
- package/dist/plugins/fileSize.js +2 -2
- package/dist/plugins/html.d.ts +1 -2
- package/dist/plugins/html.js +18 -38
- package/dist/plugins/moduleFederation.js +2 -2
- package/dist/plugins/rsdoctor.js +2 -2
- package/dist/plugins/splitChunks.js +4 -4
- package/dist/plugins/target.js +10 -12
- package/dist/provider/config.js +0 -1
- package/dist/provider/createContext.js +1 -1
- package/dist/provider/plugins/less.js +2 -2
- package/dist/provider/plugins/minimize.js +1 -2
- package/dist/provider/plugins/resolve.js +1 -4
- package/dist/provider/plugins/sass.js +2 -2
- package/dist/provider/plugins/transition.js +9 -1
- package/dist/provider/provider.js +6 -9
- package/dist/rspack/HtmlBasicPlugin.d.ts +25 -2
- package/dist/rspack/HtmlBasicPlugin.js +155 -25
- package/dist/rspack/HtmlCrossOriginPlugin.js +4 -8
- package/dist/rspack/HtmlNoncePlugin.js +2 -2
- package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
- package/dist/rspack/RemoveCssSourcemapPlugin.js +2 -2
- package/dist/server/devServer.d.ts +3 -10
- package/dist/server/devServer.js +108 -115
- package/dist/server/getDevMiddlewares.js +9 -7
- package/dist/server/helper.js +2 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -4
- package/dist/server/prodServer.js +2 -2
- package/dist/server/socketServer.js +6 -6
- package/package.json +5 -5
- package/dist/plugins/toml.d.ts +0 -0
- package/dist/plugins/toml.js +0 -1
- package/dist/plugins/yaml.d.ts +0 -0
- package/dist/plugins/yaml.js +0 -1
- package/dist/rspack/HtmlTagsPlugin.d.ts +0 -24
- package/dist/rspack/HtmlTagsPlugin.js +0 -186
|
@@ -65,7 +65,7 @@ class SocketServer {
|
|
|
65
65
|
import_shared.logger.error(err);
|
|
66
66
|
});
|
|
67
67
|
this.timer = setInterval(() => {
|
|
68
|
-
this.wsServer.clients
|
|
68
|
+
for (const socket of this.wsServer.clients) {
|
|
69
69
|
const extWs = socket;
|
|
70
70
|
if (!extWs.isAlive) {
|
|
71
71
|
extWs.terminate();
|
|
@@ -74,7 +74,7 @@ class SocketServer {
|
|
|
74
74
|
extWs.ping(() => {
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
}, 3e4);
|
|
79
79
|
this.wsServer.on("connection", (socket) => {
|
|
80
80
|
this.onConnect(socket);
|
|
@@ -86,17 +86,17 @@ class SocketServer {
|
|
|
86
86
|
}
|
|
87
87
|
// write message to each socket
|
|
88
88
|
sockWrite(type, data) {
|
|
89
|
-
this.sockets
|
|
89
|
+
for (const socket of this.sockets) {
|
|
90
90
|
this.send(socket, JSON.stringify({ type, data }));
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
}
|
|
93
93
|
singleWrite(socket, type, data) {
|
|
94
94
|
this.send(socket, JSON.stringify({ type, data }));
|
|
95
95
|
}
|
|
96
96
|
close() {
|
|
97
|
-
this.sockets
|
|
97
|
+
for (const socket of this.sockets) {
|
|
98
98
|
socket.close();
|
|
99
|
-
}
|
|
99
|
+
}
|
|
100
100
|
if (this.timer) {
|
|
101
101
|
clearInterval(this.timer);
|
|
102
102
|
this.timer = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"types.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@rspack/core": "0.5.
|
|
55
|
+
"@rspack/core": "0.5.7",
|
|
56
56
|
"@swc/helpers": "0.5.3",
|
|
57
|
-
"core-js": "~3.
|
|
57
|
+
"core-js": "~3.36.0",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.
|
|
60
|
+
"@rsbuild/shared": "0.5.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"webpack": "^5.89.0"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
|
-
"node": ">=
|
|
68
|
+
"node": ">=16.0.0"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public",
|
package/dist/plugins/toml.d.ts
DELETED
|
File without changes
|
package/dist/plugins/toml.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/plugins/yaml.d.ts
DELETED
|
File without changes
|
package/dist/plugins/yaml.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import { type HtmlInjectTag, type HtmlInjectTagDescriptor } from '@rsbuild/shared';
|
|
3
|
-
export interface HtmlTagsPluginOptions {
|
|
4
|
-
hash?: HtmlInjectTag['hash'];
|
|
5
|
-
publicPath?: HtmlInjectTag['publicPath'];
|
|
6
|
-
append?: HtmlInjectTag['append'];
|
|
7
|
-
includes?: string[];
|
|
8
|
-
tags?: HtmlInjectTagDescriptor[];
|
|
9
|
-
}
|
|
10
|
-
/** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Void_element} */
|
|
11
|
-
export declare const VOID_TAGS: string[];
|
|
12
|
-
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also} */
|
|
13
|
-
export declare const HEAD_TAGS: string[];
|
|
14
|
-
export declare const FILE_ATTRS: {
|
|
15
|
-
link: string;
|
|
16
|
-
script: string;
|
|
17
|
-
};
|
|
18
|
-
export declare class HtmlTagsPlugin {
|
|
19
|
-
readonly name: string;
|
|
20
|
-
meta: Record<string, string>;
|
|
21
|
-
ctx: HtmlTagsPluginOptions;
|
|
22
|
-
constructor(opts: HtmlTagsPluginOptions);
|
|
23
|
-
apply(compiler: Compiler): void;
|
|
24
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => {
|
|
21
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
var HtmlTagsPlugin_exports = {};
|
|
25
|
-
__export(HtmlTagsPlugin_exports, {
|
|
26
|
-
FILE_ATTRS: () => FILE_ATTRS,
|
|
27
|
-
HEAD_TAGS: () => HEAD_TAGS,
|
|
28
|
-
HtmlTagsPlugin: () => HtmlTagsPlugin,
|
|
29
|
-
VOID_TAGS: () => VOID_TAGS
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(HtmlTagsPlugin_exports);
|
|
32
|
-
var import_shared = require("@rsbuild/shared");
|
|
33
|
-
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
34
|
-
const VOID_TAGS = [
|
|
35
|
-
"area",
|
|
36
|
-
"base",
|
|
37
|
-
"br",
|
|
38
|
-
"col",
|
|
39
|
-
"embed",
|
|
40
|
-
"hr",
|
|
41
|
-
"img",
|
|
42
|
-
"input",
|
|
43
|
-
"keygen",
|
|
44
|
-
"link",
|
|
45
|
-
"meta",
|
|
46
|
-
"param",
|
|
47
|
-
"source",
|
|
48
|
-
"track",
|
|
49
|
-
"wbr"
|
|
50
|
-
];
|
|
51
|
-
const HEAD_TAGS = [
|
|
52
|
-
"title",
|
|
53
|
-
"base",
|
|
54
|
-
"link",
|
|
55
|
-
"style",
|
|
56
|
-
"meta",
|
|
57
|
-
"script",
|
|
58
|
-
"noscript",
|
|
59
|
-
"template"
|
|
60
|
-
];
|
|
61
|
-
const FILE_ATTRS = {
|
|
62
|
-
link: "href",
|
|
63
|
-
script: "src"
|
|
64
|
-
};
|
|
65
|
-
const withHash = (url, hash) => `${url}?${hash}`;
|
|
66
|
-
class HtmlTagsPlugin {
|
|
67
|
-
constructor(opts) {
|
|
68
|
-
__publicField(this, "name", "HtmlTagsPlugin");
|
|
69
|
-
__publicField(this, "meta", { plugin: this.name });
|
|
70
|
-
__publicField(this, "ctx");
|
|
71
|
-
this.ctx = {
|
|
72
|
-
append: true,
|
|
73
|
-
...opts
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
apply(compiler) {
|
|
77
|
-
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
78
|
-
const compilationHash = compilation.hash || "";
|
|
79
|
-
const hooks = (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation);
|
|
80
|
-
hooks.alterAssetTagGroups.tap(this.name, (params) => {
|
|
81
|
-
const includesCurrentFile = !this.ctx.includes || this.ctx.includes.includes(params.outputName);
|
|
82
|
-
if (!includesCurrentFile || !this.ctx.tags?.length) {
|
|
83
|
-
return params;
|
|
84
|
-
}
|
|
85
|
-
const fromWebpackTags = (tags2, override) => {
|
|
86
|
-
const ret = [];
|
|
87
|
-
for (const tag of tags2) {
|
|
88
|
-
ret.push({
|
|
89
|
-
tag: tag.tagName,
|
|
90
|
-
attrs: tag.attributes,
|
|
91
|
-
children: tag.innerHTML,
|
|
92
|
-
publicPath: false,
|
|
93
|
-
...override
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return ret;
|
|
97
|
-
};
|
|
98
|
-
const fromInjectTags = (tags2) => {
|
|
99
|
-
const ret = [];
|
|
100
|
-
for (const tag of tags2) {
|
|
101
|
-
const attrs = { ...tag.attrs };
|
|
102
|
-
const filenameTag = FILE_ATTRS[tag.tag];
|
|
103
|
-
let filename = attrs[filenameTag];
|
|
104
|
-
if (typeof filename === "string") {
|
|
105
|
-
const optPublicPath = tag.publicPath ?? this.ctx.publicPath;
|
|
106
|
-
if (typeof optPublicPath === "function") {
|
|
107
|
-
filename = optPublicPath(filename, params.publicPath);
|
|
108
|
-
} else if (typeof optPublicPath === "string") {
|
|
109
|
-
filename = (0, import_shared.withPublicPath)(filename, optPublicPath);
|
|
110
|
-
} else if (optPublicPath !== false) {
|
|
111
|
-
filename = (0, import_shared.withPublicPath)(filename, params.publicPath);
|
|
112
|
-
}
|
|
113
|
-
const optHash = tag.hash ?? this.ctx.hash;
|
|
114
|
-
if (typeof optHash === "function") {
|
|
115
|
-
if (compilationHash.length) {
|
|
116
|
-
filename = optHash(filename, compilationHash);
|
|
117
|
-
}
|
|
118
|
-
} else if (typeof optHash === "string") {
|
|
119
|
-
if (optHash.length) {
|
|
120
|
-
filename = withHash(filename, optHash);
|
|
121
|
-
}
|
|
122
|
-
} else if (optHash === true) {
|
|
123
|
-
if (compilationHash.length) {
|
|
124
|
-
filename = withHash(filename, compilationHash);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
attrs[filenameTag] = filename;
|
|
128
|
-
}
|
|
129
|
-
ret.push({
|
|
130
|
-
tagName: tag.tag,
|
|
131
|
-
attributes: attrs,
|
|
132
|
-
meta: this.meta,
|
|
133
|
-
voidTag: VOID_TAGS.includes(tag.tag),
|
|
134
|
-
innerHTML: tag.children
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return ret;
|
|
138
|
-
};
|
|
139
|
-
const handlers = [];
|
|
140
|
-
let tags = [
|
|
141
|
-
...fromWebpackTags(params.headTags, { head: true }),
|
|
142
|
-
...fromWebpackTags(params.bodyTags, { head: false })
|
|
143
|
-
];
|
|
144
|
-
this.ctx.tags.forEach((tag) => {
|
|
145
|
-
if ((0, import_shared.isFunction)(tag)) {
|
|
146
|
-
handlers.push(tag);
|
|
147
|
-
} else {
|
|
148
|
-
tags.push(tag);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
const getPriority = (tag) => {
|
|
152
|
-
const head = tag.head ?? HEAD_TAGS.includes(tag.tag);
|
|
153
|
-
let priority = head ? -2 : 2;
|
|
154
|
-
const append = tag.append ?? this.ctx.append;
|
|
155
|
-
if (typeof append === "boolean") {
|
|
156
|
-
priority += append ? 1 : -1;
|
|
157
|
-
}
|
|
158
|
-
return priority;
|
|
159
|
-
};
|
|
160
|
-
tags = tags.sort((tag1, tag2) => getPriority(tag1) - getPriority(tag2));
|
|
161
|
-
const utils = {
|
|
162
|
-
outputName: params.outputName,
|
|
163
|
-
publicPath: params.publicPath,
|
|
164
|
-
hash: compilationHash
|
|
165
|
-
};
|
|
166
|
-
for (const handler of handlers) {
|
|
167
|
-
tags = handler(tags, utils) || tags;
|
|
168
|
-
}
|
|
169
|
-
const [headTags, bodyTags] = (0, import_shared.partition)(
|
|
170
|
-
tags,
|
|
171
|
-
(tag) => tag.head ?? HEAD_TAGS.includes(tag.tag)
|
|
172
|
-
);
|
|
173
|
-
params.headTags = fromInjectTags(headTags);
|
|
174
|
-
params.bodyTags = fromInjectTags(bodyTags);
|
|
175
|
-
return params;
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
-
0 && (module.exports = {
|
|
182
|
-
FILE_ATTRS,
|
|
183
|
-
HEAD_TAGS,
|
|
184
|
-
HtmlTagsPlugin,
|
|
185
|
-
VOID_TAGS
|
|
186
|
-
});
|