@rsbuild/core 0.2.7 → 0.2.8
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.d.ts +12 -15
- package/dist/cli/commands.js +1 -1
- package/dist/cli/config.d.ts +12 -12
- package/dist/cli/prepare.d.ts +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr/createSocketUrl.d.ts +6 -11
- package/dist/client/hmr/index.d.ts +1 -1
- package/dist/client/hmr.js +236 -33
- package/dist/createRsbuild.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/loadEnv.d.ts +6 -9
- package/dist/plugins/asset.d.ts +1 -1
- package/dist/plugins/basic.d.ts +1 -1
- package/dist/plugins/bundleAnalyzer.d.ts +1 -1
- package/dist/plugins/cache.d.ts +1 -1
- package/dist/plugins/cleanOutput.d.ts +1 -1
- package/dist/plugins/define.d.ts +1 -1
- package/dist/plugins/entry.d.ts +1 -1
- package/dist/plugins/entry.js +7 -2
- package/dist/plugins/externals.d.ts +1 -1
- package/dist/plugins/fileSize.d.ts +1 -1
- package/dist/plugins/html.d.ts +5 -5
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/inlineChunk.d.ts +1 -1
- package/dist/plugins/moment.d.ts +1 -1
- package/dist/plugins/networkPerformance.d.ts +1 -1
- package/dist/plugins/nodeAddons.d.ts +1 -1
- package/dist/plugins/performance.d.ts +1 -1
- package/dist/plugins/preloadOrPrefetch.d.ts +1 -1
- package/dist/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/startUrl.d.ts +1 -1
- package/dist/plugins/target.d.ts +1 -1
- package/dist/plugins/toml.d.ts +1 -1
- package/dist/plugins/wasm.d.ts +1 -1
- package/dist/plugins/yaml.d.ts +1 -1
- package/dist/provider/config.d.ts +1 -1
- package/dist/provider/core/build.d.ts +10 -14
- package/dist/provider/core/createCompiler.d.ts +4 -7
- package/dist/provider/core/createContext.d.ts +1 -1
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/core/devMiddleware.d.ts +1 -1
- package/dist/provider/core/initConfigs.d.ts +7 -14
- package/dist/provider/core/initHooks.d.ts +18 -18
- package/dist/provider/core/initPlugins.d.ts +4 -7
- package/dist/provider/core/inspectConfig.d.ts +4 -10
- package/dist/provider/core/rspackConfig.d.ts +4 -7
- package/dist/provider/core/rspackConfig.js +2 -2
- package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +3 -3
- package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.d.ts +5 -5
- package/dist/provider/htmlPluginUtil.d.ts +9 -0
- package/dist/provider/htmlPluginUtil.js +47 -0
- package/dist/provider/index.d.ts +2 -1
- package/dist/provider/index.js +5 -0
- package/dist/provider/plugins/css.d.ts +7 -19
- package/dist/provider/plugins/hmr.d.ts +1 -1
- package/dist/provider/plugins/less.d.ts +1 -1
- package/dist/provider/plugins/minimize.d.ts +1 -1
- package/dist/provider/plugins/output.d.ts +1 -1
- package/dist/provider/plugins/progress.d.ts +1 -1
- package/dist/provider/plugins/resolve.d.ts +1 -1
- package/dist/provider/plugins/rspackProfile.d.ts +1 -1
- package/dist/provider/plugins/sass.d.ts +1 -1
- package/dist/provider/plugins/server.d.ts +1 -1
- package/dist/provider/plugins/swc.d.ts +1 -1
- package/dist/provider/plugins/swc.js +29 -37
- package/dist/provider/plugins/transition.d.ts +1 -1
- package/dist/provider/provider.d.ts +1 -1
- package/dist/provider/shared.d.ts +1 -1
- package/dist/rspack/HtmlAppIconPlugin.d.ts +8 -8
- package/dist/rspack/HtmlAppIconPlugin.js +15 -18
- package/dist/rspack/HtmlBasicPlugin.d.ts +8 -8
- package/dist/rspack/HtmlBasicPlugin.js +12 -25
- package/dist/rspack/HtmlCrossOriginPlugin.d.ts +6 -6
- package/dist/rspack/HtmlCrossOriginPlugin.js +13 -26
- package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +5 -5
- package/dist/rspack/HtmlNetworkPerformancePlugin.js +2 -12
- package/dist/rspack/HtmlNoncePlugin.d.ts +6 -6
- package/dist/rspack/HtmlNoncePlugin.js +8 -21
- package/dist/rspack/HtmlTagsPlugin.d.ts +13 -13
- package/dist/rspack/HtmlTagsPlugin.js +2 -12
- package/dist/rspack/InlineChunkHtmlPlugin.d.ts +39 -49
- package/dist/rspack/InlineChunkHtmlPlugin.js +2 -12
- package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +4 -4
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +8 -8
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -13
- package/dist/rspack/preload/helpers/determineAsValue.d.ts +4 -7
- package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +6 -9
- package/dist/rspack/preload/helpers/extractChunks.d.ts +4 -7
- package/dist/rspack/preload/helpers/index.d.ts +1 -1
- package/dist/rspack/preload/helpers/type.d.ts +10 -10
- package/dist/server/compilerDevMiddleware.d.ts +15 -19
- package/dist/server/devServer.d.ts +7 -15
- package/dist/server/getDevMiddlewares.d.ts +10 -10
- package/dist/server/httpServer.d.ts +3 -3
- package/dist/server/index.d.ts +1 -1
- package/dist/server/middlewares.d.ts +4 -4
- package/dist/server/prodServer.d.ts +16 -19
- package/dist/server/proxy.d.ts +3 -3
- package/dist/server/restart.d.ts +3 -5
- package/dist/server/socketServer.d.ts +17 -17
- package/dist/types.d.ts +11 -11
- package/package.json +3 -3
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlBasicPlugin_exports = {};
|
|
30
20
|
__export(HtmlBasicPlugin_exports, {
|
|
@@ -32,7 +22,7 @@ __export(HtmlBasicPlugin_exports, {
|
|
|
32
22
|
hasTitle: () => hasTitle
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(HtmlBasicPlugin_exports);
|
|
35
|
-
var
|
|
25
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
36
26
|
const hasTitle = (html) => html ? /<title/i.test(html) && /<\/title/i.test(html) : false;
|
|
37
27
|
class HtmlBasicPlugin {
|
|
38
28
|
constructor(options) {
|
|
@@ -64,22 +54,19 @@ class HtmlBasicPlugin {
|
|
|
64
54
|
}
|
|
65
55
|
};
|
|
66
56
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
const entryName = data.plugin.options?.entryName;
|
|
71
|
-
if (!entryName) {
|
|
72
|
-
return data;
|
|
73
|
-
}
|
|
74
|
-
const { headTags } = data;
|
|
75
|
-
const { templateContent } = this.options.info[entryName];
|
|
76
|
-
if (!hasTitle(templateContent)) {
|
|
77
|
-
addTitleTag(headTags, data.plugin.options?.title);
|
|
78
|
-
}
|
|
79
|
-
addFavicon(headTags, entryName);
|
|
57
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
|
|
58
|
+
const entryName = data.plugin.options?.entryName;
|
|
59
|
+
if (!entryName) {
|
|
80
60
|
return data;
|
|
81
61
|
}
|
|
82
|
-
|
|
62
|
+
const { headTags } = data;
|
|
63
|
+
const { templateContent } = this.options.info[entryName];
|
|
64
|
+
if (!hasTitle(templateContent)) {
|
|
65
|
+
addTitleTag(headTags, data.plugin.options?.title);
|
|
66
|
+
}
|
|
67
|
+
addFavicon(headTags, entryName);
|
|
68
|
+
return data;
|
|
69
|
+
});
|
|
83
70
|
});
|
|
84
71
|
}
|
|
85
72
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { CrossOrigin } from '@rsbuild/shared';
|
|
2
2
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
3
3
|
type CrossOriginOptions = {
|
|
4
|
-
|
|
4
|
+
crossOrigin: CrossOrigin;
|
|
5
5
|
};
|
|
6
6
|
export declare class HtmlCrossOriginPlugin implements RspackPluginInstance {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly crossOrigin: CrossOrigin;
|
|
9
|
+
constructor(options: CrossOriginOptions);
|
|
10
|
+
apply(compiler: Compiler): void;
|
|
11
11
|
}
|
|
12
|
-
export {};
|
|
12
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlCrossOriginPlugin_exports = {};
|
|
30
20
|
__export(HtmlCrossOriginPlugin_exports, {
|
|
31
21
|
HtmlCrossOriginPlugin: () => HtmlCrossOriginPlugin
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
35
25
|
class HtmlCrossOriginPlugin {
|
|
36
26
|
constructor(options) {
|
|
37
27
|
const { crossOrigin } = options;
|
|
@@ -45,21 +35,18 @@ class HtmlCrossOriginPlugin {
|
|
|
45
35
|
return;
|
|
46
36
|
}
|
|
47
37
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return alterAssetTags;
|
|
61
|
-
}
|
|
62
|
-
);
|
|
38
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
|
|
39
|
+
const {
|
|
40
|
+
assetTags: { scripts, styles }
|
|
41
|
+
} = alterAssetTags;
|
|
42
|
+
scripts.forEach(
|
|
43
|
+
(script) => script.attributes.crossorigin = this.crossOrigin
|
|
44
|
+
);
|
|
45
|
+
styles.forEach(
|
|
46
|
+
(style) => style.attributes.crossorigin = this.crossOrigin
|
|
47
|
+
);
|
|
48
|
+
return alterAssetTags;
|
|
49
|
+
});
|
|
63
50
|
});
|
|
64
51
|
}
|
|
65
52
|
}
|
|
@@ -2,9 +2,9 @@ import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
|
2
2
|
import { type Preconnect, type DnsPrefetch } from '@rsbuild/shared';
|
|
3
3
|
type NetworkPerformanceType = 'preconnect' | 'dnsPrefetch';
|
|
4
4
|
export declare class HtmlNetworkPerformancePlugin implements RspackPluginInstance {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
readonly options: DnsPrefetch | Preconnect;
|
|
6
|
+
readonly type: NetworkPerformanceType;
|
|
7
|
+
constructor(options: DnsPrefetch | Preconnect, type: NetworkPerformanceType);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
9
|
}
|
|
10
|
-
export {};
|
|
10
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlNetworkPerformancePlugin_exports = {};
|
|
30
20
|
__export(HtmlNetworkPerformancePlugin_exports, {
|
|
@@ -32,7 +22,7 @@ __export(HtmlNetworkPerformancePlugin_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(HtmlNetworkPerformancePlugin_exports);
|
|
34
24
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var
|
|
25
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
36
26
|
function generateLinks(options, type) {
|
|
37
27
|
const relMap = {
|
|
38
28
|
preconnect: "preconnect",
|
|
@@ -57,7 +47,7 @@ class HtmlNetworkPerformancePlugin {
|
|
|
57
47
|
compiler.hooks.compilation.tap(
|
|
58
48
|
`HTML${this.type}Plugin`,
|
|
59
49
|
(compilation) => {
|
|
60
|
-
|
|
50
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(
|
|
61
51
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
62
52
|
(htmlPluginData) => {
|
|
63
53
|
const { headTags } = htmlPluginData;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
2
|
type NonceOptions = {
|
|
3
|
-
|
|
3
|
+
nonce: string;
|
|
4
4
|
};
|
|
5
5
|
export declare class HtmlNoncePlugin implements RspackPluginInstance {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly nonce: string;
|
|
8
|
+
constructor(options: NonceOptions);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
10
|
}
|
|
11
|
-
export {};
|
|
11
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlNoncePlugin_exports = {};
|
|
30
20
|
__export(HtmlNoncePlugin_exports, {
|
|
31
21
|
HtmlNoncePlugin: () => HtmlNoncePlugin
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(HtmlNoncePlugin_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
35
25
|
class HtmlNoncePlugin {
|
|
36
26
|
constructor(options) {
|
|
37
27
|
const { nonce } = options;
|
|
@@ -43,16 +33,13 @@ class HtmlNoncePlugin {
|
|
|
43
33
|
return;
|
|
44
34
|
}
|
|
45
35
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return alterAssetTags;
|
|
54
|
-
}
|
|
55
|
-
);
|
|
36
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
|
|
37
|
+
const {
|
|
38
|
+
assetTags: { scripts }
|
|
39
|
+
} = alterAssetTags;
|
|
40
|
+
scripts.forEach((script) => script.attributes.nonce = this.nonce);
|
|
41
|
+
return alterAssetTags;
|
|
42
|
+
});
|
|
56
43
|
});
|
|
57
44
|
}
|
|
58
45
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
2
|
import { type HtmlInjectTag, type HtmlInjectTagDescriptor } from '@rsbuild/shared';
|
|
3
3
|
export interface HtmlTagsPluginOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
hash?: HtmlInjectTag['hash'];
|
|
5
|
+
publicPath?: HtmlInjectTag['publicPath'];
|
|
6
|
+
append?: HtmlInjectTag['append'];
|
|
7
|
+
includes?: string[];
|
|
8
|
+
tags?: HtmlInjectTagDescriptor[];
|
|
9
9
|
}
|
|
10
10
|
/** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Void_element} */
|
|
11
11
|
export declare const VOID_TAGS: string[];
|
|
12
12
|
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also} */
|
|
13
13
|
export declare const HEAD_TAGS: string[];
|
|
14
14
|
export declare const FILE_ATTRS: {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
link: string;
|
|
16
|
+
script: string;
|
|
17
17
|
};
|
|
18
18
|
export declare class HtmlTagsPlugin {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
19
|
+
readonly name: string;
|
|
20
|
+
meta: Record<string, string>;
|
|
21
|
+
ctx: HtmlTagsPluginOptions;
|
|
22
|
+
constructor(opts: HtmlTagsPluginOptions);
|
|
23
|
+
apply(compiler: Compiler): void;
|
|
24
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlTagsPlugin_exports = {};
|
|
30
20
|
__export(HtmlTagsPlugin_exports, {
|
|
@@ -34,8 +24,8 @@ __export(HtmlTagsPlugin_exports, {
|
|
|
34
24
|
VOID_TAGS: () => VOID_TAGS
|
|
35
25
|
});
|
|
36
26
|
module.exports = __toCommonJS(HtmlTagsPlugin_exports);
|
|
37
|
-
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
38
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
39
29
|
const VOID_TAGS = [
|
|
40
30
|
"area",
|
|
41
31
|
"base",
|
|
@@ -80,7 +70,7 @@ class HtmlTagsPlugin {
|
|
|
80
70
|
apply(compiler) {
|
|
81
71
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
82
72
|
const compilationHash = compilation.hash || "";
|
|
83
|
-
const hooks =
|
|
73
|
+
const hooks = (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation);
|
|
84
74
|
hooks.alterAssetTagGroups.tap(this.name, (params) => {
|
|
85
75
|
const includesCurrentFile = !this.ctx.includes || this.ctx.includes.includes(params.outputName);
|
|
86
76
|
if (!includesCurrentFile || !this.ctx.tags?.length) {
|
|
@@ -1,56 +1,46 @@
|
|
|
1
1
|
import { type InlineChunkTest } from '@rsbuild/shared';
|
|
2
2
|
import type { Compiler, Compilation } from '@rspack/core';
|
|
3
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
3
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
5
4
|
export type InlineChunkHtmlPluginOptions = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
styleTests: InlineChunkTest[];
|
|
6
|
+
scriptTests: InlineChunkTest[];
|
|
7
|
+
distPath: {
|
|
8
|
+
js?: string;
|
|
9
|
+
css?: string;
|
|
10
|
+
};
|
|
12
11
|
};
|
|
13
12
|
export declare class InlineChunkHtmlPlugin {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
publicPath,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
attributes: {
|
|
45
|
-
[x: string]: string | boolean | null | undefined;
|
|
13
|
+
name: string;
|
|
14
|
+
styleTests: InlineChunkTest[];
|
|
15
|
+
scriptTests: InlineChunkTest[];
|
|
16
|
+
distPath: InlineChunkHtmlPluginOptions['distPath'];
|
|
17
|
+
inlinedAssets: Set<string>;
|
|
18
|
+
constructor({ styleTests, scriptTests, distPath, }: InlineChunkHtmlPluginOptions);
|
|
19
|
+
/**
|
|
20
|
+
* If we inlined the chunk to HTML,we should update the value of sourceMappingURL,
|
|
21
|
+
* because the relative path of source code has been changed.
|
|
22
|
+
* @param source
|
|
23
|
+
*/
|
|
24
|
+
updateSourceMappingURL({ source, compilation, publicPath, type, }: {
|
|
25
|
+
source: string;
|
|
26
|
+
compilation: Compilation;
|
|
27
|
+
publicPath: string;
|
|
28
|
+
type: 'js' | 'css';
|
|
29
|
+
}): string;
|
|
30
|
+
matchTests(name: string, source: string, tests: InlineChunkTest[]): boolean;
|
|
31
|
+
getInlinedScriptTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject | {
|
|
32
|
+
tagName: string;
|
|
33
|
+
innerHTML: string;
|
|
34
|
+
attributes: {
|
|
35
|
+
[x: string]: string | boolean | null | undefined;
|
|
36
|
+
};
|
|
37
|
+
closeTag: boolean;
|
|
38
|
+
};
|
|
39
|
+
getInlinedCSSTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject | {
|
|
40
|
+
tagName: string;
|
|
41
|
+
innerHTML: string;
|
|
42
|
+
closeTag: boolean;
|
|
46
43
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
tagName: string;
|
|
51
|
-
innerHTML: string;
|
|
52
|
-
closeTag: boolean;
|
|
53
|
-
};
|
|
54
|
-
getInlinedTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlWebpackPlugin.HtmlTagObject;
|
|
55
|
-
apply(compiler: Compiler): void;
|
|
56
|
-
}
|
|
44
|
+
getInlinedTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject;
|
|
45
|
+
apply(compiler: Compiler): void;
|
|
46
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var InlineChunkHtmlPlugin_exports = {};
|
|
30
20
|
__export(InlineChunkHtmlPlugin_exports, {
|
|
@@ -33,7 +23,7 @@ __export(InlineChunkHtmlPlugin_exports, {
|
|
|
33
23
|
module.exports = __toCommonJS(InlineChunkHtmlPlugin_exports);
|
|
34
24
|
var import_path = require("path");
|
|
35
25
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
var
|
|
26
|
+
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
37
27
|
class InlineChunkHtmlPlugin {
|
|
38
28
|
constructor({
|
|
39
29
|
styleTests,
|
|
@@ -160,7 +150,7 @@ class InlineChunkHtmlPlugin {
|
|
|
160
150
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
161
151
|
const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
|
|
162
152
|
const tagFunction = (tag) => this.getInlinedTag(publicPath, tag, compilation);
|
|
163
|
-
const hooks =
|
|
153
|
+
const hooks = (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation);
|
|
164
154
|
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
165
155
|
assets.headTags = assets.headTags.map(tagFunction);
|
|
166
156
|
assets.bodyTags = assets.bodyTags.map(tagFunction);
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
18
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
18
|
+
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
19
19
|
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
type LinkType = 'preload' | 'prefetch';
|
|
21
21
|
export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
readonly options: PreloadOrPreFetchOption;
|
|
23
|
+
resourceHints: HtmlWebpackPlugin.HtmlTagObject[];
|
|
24
|
+
type: LinkType;
|
|
25
|
+
HTMLCount: number;
|
|
26
|
+
constructor(options: true | PreloadOrPreFetchOption, type: LinkType, HTMLCount: number);
|
|
27
|
+
apply(compiler: Compiler): void;
|
|
28
28
|
}
|
|
29
|
-
export {};
|
|
29
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,23 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var HtmlPreloadOrPrefetchPlugin_exports = {};
|
|
30
20
|
__export(HtmlPreloadOrPrefetchPlugin_exports, {
|
|
31
21
|
HtmlPreloadOrPrefetchPlugin: () => HtmlPreloadOrPrefetchPlugin
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(HtmlPreloadOrPrefetchPlugin_exports);
|
|
34
|
-
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
35
24
|
var import_shared = require("@rsbuild/shared");
|
|
36
25
|
var import_helpers = require("./helpers");
|
|
26
|
+
var import_htmlPluginUtil = require("../../provider/htmlPluginUtil");
|
|
37
27
|
/**
|
|
38
28
|
* @license
|
|
39
29
|
* Copyright 2018 Google Inc.
|
|
@@ -140,7 +130,7 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
140
130
|
}
|
|
141
131
|
apply(compiler) {
|
|
142
132
|
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
143
|
-
|
|
133
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).beforeAssetTagGeneration.tap(
|
|
144
134
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
145
135
|
(htmlPluginData) => {
|
|
146
136
|
this.resourceHints = generateLinks(
|
|
@@ -153,7 +143,7 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
153
143
|
return htmlPluginData;
|
|
154
144
|
}
|
|
155
145
|
);
|
|
156
|
-
|
|
146
|
+
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(
|
|
157
147
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
158
148
|
(htmlPluginData) => {
|
|
159
149
|
if (this.resourceHints) {
|
|
@@ -16,10 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
import type { As } from './type';
|
|
19
|
-
export declare function determineAsValue({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}:
|
|
23
|
-
href: string;
|
|
24
|
-
file: string;
|
|
25
|
-
}): As;
|
|
19
|
+
export declare function determineAsValue({ href, file, }: {
|
|
20
|
+
href: string;
|
|
21
|
+
file: string;
|
|
22
|
+
}): As;
|
|
@@ -19,13 +19,10 @@ import type { Chunk } from 'webpack';
|
|
|
19
19
|
import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
import { BeforeAssetTagGenerationHtmlPluginData } from './type';
|
|
21
21
|
interface DoesChunkBelongToHtmlOptions {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
chunk: Chunk;
|
|
23
|
+
compilation?: Compilation;
|
|
24
|
+
htmlPluginData: BeforeAssetTagGenerationHtmlPluginData;
|
|
25
|
+
pluginOptions?: PreloadOrPreFetchOption;
|
|
26
26
|
}
|
|
27
|
-
export declare function doesChunkBelongToHtml({
|
|
28
|
-
|
|
29
|
-
htmlPluginData
|
|
30
|
-
}: DoesChunkBelongToHtmlOptions): boolean;
|
|
31
|
-
export {};
|
|
27
|
+
export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
|
|
28
|
+
export {};
|
|
@@ -18,11 +18,8 @@ import { Chunk, Compilation } from 'webpack';
|
|
|
18
18
|
import type { PreloadIncludeType } from '@rsbuild/shared';
|
|
19
19
|
export type ChunkGroup = Compilation['chunkGroups'][0];
|
|
20
20
|
interface ExtractChunks {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
compilation: Compilation;
|
|
22
|
+
includeType?: PreloadIncludeType;
|
|
23
23
|
}
|
|
24
|
-
export declare function extractChunks({
|
|
25
|
-
|
|
26
|
-
includeType
|
|
27
|
-
}: ExtractChunks): Chunk[];
|
|
28
|
-
export {};
|
|
24
|
+
export declare function extractChunks({ compilation, includeType, }: ExtractChunks): Chunk[];
|
|
25
|
+
export {};
|