@rsbuild/core 0.1.8 → 0.2.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/compiled/commander/package.json +1 -1
- package/compiled/connect-history-api-fallback/package.json +1 -1
- package/compiled/dotenv/package.json +1 -1
- package/compiled/dotenv-expand/package.json +1 -1
- package/compiled/http-compression/package.json +1 -1
- package/compiled/open/package.json +1 -1
- package/compiled/sirv/package.json +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/cli/commands.js +6 -3
- package/dist/cli/config.d.ts +7 -1
- package/dist/cli/config.js +7 -4
- package/dist/cli/prepare.js +1 -1
- package/dist/createRsbuild.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/loadEnv.d.ts +2 -2
- package/dist/loadEnv.js +2 -2
- package/dist/plugins/asset.js +2 -2
- package/dist/plugins/basic.d.ts +5 -0
- package/dist/plugins/basic.js +68 -0
- package/dist/plugins/fileSize.js +1 -1
- package/dist/plugins/html.d.ts +1 -2
- package/dist/plugins/html.js +8 -8
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/inlineChunk.js +25 -28
- package/dist/plugins/networkPerformance.js +3 -11
- package/dist/plugins/nodeAddons.js +1 -1
- package/dist/plugins/preloadOrPrefetch.js +4 -10
- package/dist/plugins/wasm.js +1 -1
- package/dist/provider/core/createCompiler.js +17 -9
- package/dist/provider/core/createContext.d.ts +3 -3
- package/dist/provider/core/createContext.js +13 -27
- package/dist/provider/core/initConfigs.d.ts +2 -2
- package/dist/provider/core/initConfigs.js +4 -3
- package/dist/provider/core/initPlugins.js +15 -12
- package/dist/provider/core/inspectConfig.d.ts +2 -20
- package/dist/provider/core/inspectConfig.js +6 -6
- package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/{postcss-icss-extract-plugin.js → postcssIcssExtractPlugin.js} +5 -5
- package/dist/provider/index.d.ts +1 -2
- package/dist/provider/index.js +4 -7
- package/dist/provider/plugins/css.js +5 -10
- package/dist/provider/plugins/less.js +2 -2
- package/dist/provider/plugins/minimize.d.ts +1 -4
- package/dist/provider/plugins/minimize.js +18 -15
- package/dist/provider/plugins/output.js +2 -2
- package/dist/provider/plugins/resolve.js +0 -5
- package/dist/provider/plugins/rspackProfile.js +7 -4
- package/dist/provider/plugins/sass.js +2 -2
- package/dist/provider/plugins/server.d.ts +2 -0
- package/dist/provider/plugins/server.js +70 -0
- package/dist/provider/plugins/swc.js +1 -8
- package/dist/provider/provider.js +15 -1
- package/dist/provider/shared.d.ts +2 -3
- package/dist/provider/shared.js +4 -18
- package/dist/rspack/HtmlAppIconPlugin.d.ts +0 -3
- package/dist/rspack/HtmlAppIconPlugin.js +2 -2
- package/dist/rspack/HtmlBasicPlugin.d.ts +0 -3
- package/dist/rspack/HtmlBasicPlugin.js +24 -10
- package/dist/rspack/HtmlCrossOriginPlugin.d.ts +0 -3
- package/dist/rspack/HtmlCrossOriginPlugin.js +12 -2
- package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +1 -3
- package/dist/rspack/HtmlNetworkPerformancePlugin.js +13 -3
- package/dist/rspack/HtmlNoncePlugin.d.ts +0 -3
- package/dist/rspack/HtmlNoncePlugin.js +12 -2
- package/dist/rspack/HtmlTagsPlugin.d.ts +1 -7
- package/dist/rspack/HtmlTagsPlugin.js +12 -1
- package/dist/rspack/InlineChunkHtmlPlugin.d.ts +2 -3
- package/dist/rspack/InlineChunkHtmlPlugin.js +17 -3
- package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +1 -3
- package/dist/rspack/RemoveCssSourcemapPlugin.js +1 -2
- package/dist/rspack/{HtmlPreloadOrPrefetchPlugin/index.d.ts → preload/HtmlPreloadOrPrefetchPlugin.d.ts} +3 -4
- package/dist/rspack/{HtmlPreloadOrPrefetchPlugin/index.js → preload/HtmlPreloadOrPrefetchPlugin.js} +17 -7
- package/dist/server/{dev-middleware → compiler-dev-middleware}/index.d.ts +2 -2
- package/dist/server/{dev-middleware → compiler-dev-middleware}/index.js +3 -3
- package/dist/server/{dev-middleware → compiler-dev-middleware}/socketServer.d.ts +2 -2
- package/dist/server/devMiddlewares.d.ts +7 -0
- package/dist/server/devMiddlewares.js +156 -0
- package/dist/server/devServer.d.ts +10 -23
- package/dist/server/devServer.js +77 -162
- package/dist/server/httpServer.d.ts +8 -0
- package/dist/server/httpServer.js +48 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/prodServer.d.ts +0 -5
- package/dist/server/prodServer.js +13 -27
- package/package.json +5 -4
- package/compiled/jiti/index.js +0 -1885
- package/compiled/jiti/license +0 -21
- package/compiled/jiti/package.json +0 -1
- package/compiled/jiti/types/jiti.d.ts +0 -19
- package/compiled/jiti/types/types.d.ts +0 -31
- package/dist/plugins/devtool.d.ts +0 -2
- package/dist/plugins/devtool.js +0 -46
- package/dist/plugins/server.d.ts +0 -2
- package/dist/plugins/server.js +0 -56
- package/dist/provider/plugins/basic.d.ts +0 -5
- package/dist/provider/plugins/basic.js +0 -34
- /package/dist/provider/css-modules-typescript-pre-loader/{postcss-icss-extract-plugin.d.ts → postcssIcssExtractPlugin.d.ts} +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/determineAsValue.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/determineAsValue.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/doesChunkBelongToHtml.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/doesChunkBelongToHtml.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/extractChunks.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/extractChunks.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/index.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/index.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/type.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/type.js +0 -0
- /package/dist/server/{dev-middleware → compiler-dev-middleware}/socketServer.js +0 -0
|
@@ -41,7 +41,11 @@ function rspackProvider({
|
|
|
41
41
|
}) {
|
|
42
42
|
const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(originalRsbuildConfig);
|
|
43
43
|
return async ({ pluginStore, rsbuildOptions, plugins }) => {
|
|
44
|
-
const context = await (0, import_createContext.createContext)(
|
|
44
|
+
const context = await (0, import_createContext.createContext)(
|
|
45
|
+
rsbuildOptions,
|
|
46
|
+
rsbuildConfig,
|
|
47
|
+
"rspack"
|
|
48
|
+
);
|
|
45
49
|
const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context, pluginStore });
|
|
46
50
|
context.pluginAPI = pluginAPI;
|
|
47
51
|
return {
|
|
@@ -63,6 +67,16 @@ function rspackProvider({
|
|
|
63
67
|
rspackConfigs
|
|
64
68
|
});
|
|
65
69
|
},
|
|
70
|
+
async createDevServer(options) {
|
|
71
|
+
const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
|
|
72
|
+
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
|
|
73
|
+
await (0, import_initConfigs.initRsbuildConfig)({ context, pluginStore });
|
|
74
|
+
return createDevServer(
|
|
75
|
+
{ context, pluginStore, rsbuildOptions },
|
|
76
|
+
createDevMiddleware,
|
|
77
|
+
options
|
|
78
|
+
);
|
|
79
|
+
},
|
|
66
80
|
async startDevServer(options) {
|
|
67
81
|
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
|
|
68
82
|
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { RsbuildPlugin } from '../types';
|
|
2
|
-
import { Plugins } from '@rsbuild/shared';
|
|
2
|
+
import { type Plugins } from '@rsbuild/shared';
|
|
3
3
|
export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const rspackMinVersion = "0.3.6";
|
|
4
|
+
export declare const rspackMinVersion = "0.4.0";
|
|
6
5
|
export declare const isSatisfyRspackVersion: (version: string) => Promise<boolean>;
|
|
7
6
|
export declare const getCompiledPath: (packageName: string) => string;
|
|
8
7
|
export declare const BUILTIN_LOADER = "builtin:";
|
package/dist/provider/shared.js
CHANGED
|
@@ -31,7 +31,6 @@ __export(shared_exports, {
|
|
|
31
31
|
BUILTIN_LOADER: () => BUILTIN_LOADER,
|
|
32
32
|
applyDefaultPlugins: () => applyDefaultPlugins,
|
|
33
33
|
getCompiledPath: () => getCompiledPath,
|
|
34
|
-
getRspackVersion: () => getRspackVersion,
|
|
35
34
|
isSatisfyRspackVersion: () => isSatisfyRspackVersion,
|
|
36
35
|
rspackMinVersion: () => rspackMinVersion
|
|
37
36
|
});
|
|
@@ -42,12 +41,11 @@ var import_shared2 = require("@rsbuild/shared");
|
|
|
42
41
|
var import_shared3 = require("@rsbuild/shared");
|
|
43
42
|
const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
44
43
|
Promise.resolve().then(() => __toESM(require("./plugins/transition"))).then((m) => m.pluginTransition()),
|
|
45
|
-
|
|
44
|
+
plugins.basic(),
|
|
46
45
|
plugins.entry(),
|
|
47
46
|
// plugins.cache(),
|
|
48
47
|
plugins.target(),
|
|
49
48
|
Promise.resolve().then(() => __toESM(require("./plugins/output"))).then((m) => m.pluginOutput()),
|
|
50
|
-
plugins.devtool(),
|
|
51
49
|
Promise.resolve().then(() => __toESM(require("./plugins/resolve"))).then((m) => m.pluginResolve()),
|
|
52
50
|
plugins.fileSize(),
|
|
53
51
|
// cleanOutput plugin should before the html plugin
|
|
@@ -75,20 +73,10 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
|
75
73
|
plugins.networkPerformance(),
|
|
76
74
|
plugins.preloadOrPrefetch(),
|
|
77
75
|
plugins.performance(),
|
|
78
|
-
plugins.
|
|
76
|
+
Promise.resolve().then(() => __toESM(require("./plugins/server"))).then((m) => m.pluginServer()),
|
|
79
77
|
Promise.resolve().then(() => __toESM(require("./plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
|
|
80
78
|
]);
|
|
81
|
-
const
|
|
82
|
-
try {
|
|
83
|
-
const core = require.resolve("@rspack/core");
|
|
84
|
-
const pkg = await Promise.resolve().then(() => __toESM(require((0, import_path.join)(core, "../../package.json"))));
|
|
85
|
-
return pkg?.version;
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.error(err);
|
|
88
|
-
return "";
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const rspackMinVersion = "0.3.6";
|
|
79
|
+
const rspackMinVersion = "0.4.0";
|
|
92
80
|
const compareSemver = (version1, version2) => {
|
|
93
81
|
const parts1 = version1.split(".").map(Number);
|
|
94
82
|
const parts2 = version2.split(".").map(Number);
|
|
@@ -118,9 +106,8 @@ const getCompiledPath = (packageName) => {
|
|
|
118
106
|
const providerCompilerPath = (0, import_path.join)(__dirname, "../../compiled", packageName);
|
|
119
107
|
if (import_shared2.fse.existsSync(providerCompilerPath)) {
|
|
120
108
|
return providerCompilerPath;
|
|
121
|
-
} else {
|
|
122
|
-
return (0, import_shared.getSharedPkgCompiledPath)(packageName);
|
|
123
109
|
}
|
|
110
|
+
return (0, import_shared.getSharedPkgCompiledPath)(packageName);
|
|
124
111
|
};
|
|
125
112
|
const BUILTIN_LOADER = "builtin:";
|
|
126
113
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -128,7 +115,6 @@ const BUILTIN_LOADER = "builtin:";
|
|
|
128
115
|
BUILTIN_LOADER,
|
|
129
116
|
applyDefaultPlugins,
|
|
130
117
|
getCompiledPath,
|
|
131
|
-
getRspackVersion,
|
|
132
118
|
isSatisfyRspackVersion,
|
|
133
119
|
rspackMinVersion
|
|
134
120
|
});
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import type { Compiler } from '@rspack/core';
|
|
3
2
|
type AppIconOptions = {
|
|
4
3
|
distDir: string;
|
|
5
4
|
iconPath: string;
|
|
6
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
7
5
|
};
|
|
8
6
|
export declare class HtmlAppIconPlugin {
|
|
9
7
|
readonly name: string;
|
|
10
8
|
readonly distDir: string;
|
|
11
9
|
readonly iconPath: string;
|
|
12
|
-
readonly HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
13
10
|
constructor(options: AppIconOptions);
|
|
14
11
|
apply(compiler: Compiler): void;
|
|
15
12
|
}
|
|
@@ -33,6 +33,7 @@ __export(HtmlAppIconPlugin_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(HtmlAppIconPlugin_exports);
|
|
34
34
|
var import_fs = __toESM(require("fs"));
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
36
37
|
var import_webpack_sources = __toESM(require("@rsbuild/shared/webpack-sources"));
|
|
37
38
|
var import_shared = require("@rsbuild/shared");
|
|
38
39
|
class HtmlAppIconPlugin {
|
|
@@ -40,7 +41,6 @@ class HtmlAppIconPlugin {
|
|
|
40
41
|
this.name = "HtmlAppIconPlugin";
|
|
41
42
|
this.distDir = options.distDir;
|
|
42
43
|
this.iconPath = options.iconPath;
|
|
43
|
-
this.HtmlPlugin = options.HtmlPlugin;
|
|
44
44
|
}
|
|
45
45
|
apply(compiler) {
|
|
46
46
|
if (!import_fs.default.existsSync(this.iconPath)) {
|
|
@@ -53,7 +53,7 @@ class HtmlAppIconPlugin {
|
|
|
53
53
|
import_path.default.basename(this.iconPath)
|
|
54
54
|
);
|
|
55
55
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
56
|
-
|
|
56
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTagGroups.tap(
|
|
57
57
|
this.name,
|
|
58
58
|
(data) => {
|
|
59
59
|
const { publicPath } = compiler.options.output;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import type { Compiler } from '@rspack/core';
|
|
3
2
|
export type HtmlInfo = {
|
|
4
3
|
title?: string;
|
|
@@ -7,13 +6,11 @@ export type HtmlInfo = {
|
|
|
7
6
|
};
|
|
8
7
|
export type HtmlBasicPluginOptions = {
|
|
9
8
|
info: Record<string, HtmlInfo>;
|
|
10
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
11
9
|
};
|
|
12
10
|
export declare const hasTitle: (html?: string) => boolean;
|
|
13
11
|
export declare class HtmlBasicPlugin {
|
|
14
12
|
readonly name: string;
|
|
15
13
|
readonly options: HtmlBasicPluginOptions;
|
|
16
|
-
readonly HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
17
14
|
constructor(options: HtmlBasicPluginOptions);
|
|
18
15
|
apply(compiler: Compiler): void;
|
|
19
16
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var HtmlBasicPlugin_exports = {};
|
|
20
30
|
__export(HtmlBasicPlugin_exports, {
|
|
@@ -22,16 +32,16 @@ __export(HtmlBasicPlugin_exports, {
|
|
|
22
32
|
hasTitle: () => hasTitle
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(HtmlBasicPlugin_exports);
|
|
35
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
25
36
|
const hasTitle = (html) => html ? /<title/i.test(html) && /<\/title/i.test(html) : false;
|
|
26
37
|
class HtmlBasicPlugin {
|
|
27
38
|
constructor(options) {
|
|
28
39
|
this.name = "HtmlBasicPlugin";
|
|
29
40
|
this.options = options;
|
|
30
|
-
this.HtmlPlugin = options.HtmlPlugin;
|
|
31
41
|
}
|
|
32
42
|
apply(compiler) {
|
|
33
|
-
const addTitleTag = (headTags,
|
|
34
|
-
const { title } = this.options.info[
|
|
43
|
+
const addTitleTag = (headTags, entryName) => {
|
|
44
|
+
const { title } = this.options.info[entryName];
|
|
35
45
|
if (title) {
|
|
36
46
|
headTags.unshift({
|
|
37
47
|
tagName: "title",
|
|
@@ -42,8 +52,8 @@ class HtmlBasicPlugin {
|
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
54
|
};
|
|
45
|
-
const addFavicon = (headTags,
|
|
46
|
-
const { favicon } = this.options.info[
|
|
55
|
+
const addFavicon = (headTags, entryName) => {
|
|
56
|
+
const { favicon } = this.options.info[entryName];
|
|
47
57
|
if (favicon) {
|
|
48
58
|
headTags.unshift({
|
|
49
59
|
tagName: "link",
|
|
@@ -57,15 +67,19 @@ class HtmlBasicPlugin {
|
|
|
57
67
|
}
|
|
58
68
|
};
|
|
59
69
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
60
|
-
|
|
70
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTagGroups.tap(
|
|
61
71
|
this.name,
|
|
62
72
|
(data) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
73
|
+
const entryName = data.plugin.options?.entryName;
|
|
74
|
+
if (!entryName) {
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
const { headTags } = data;
|
|
78
|
+
const { templateContent } = this.options.info[entryName];
|
|
65
79
|
if (!hasTitle(templateContent)) {
|
|
66
|
-
addTitleTag(headTags,
|
|
80
|
+
addTitleTag(headTags, entryName);
|
|
67
81
|
}
|
|
68
|
-
addFavicon(headTags,
|
|
82
|
+
addFavicon(headTags, entryName);
|
|
69
83
|
return data;
|
|
70
84
|
}
|
|
71
85
|
);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import type { CrossOrigin } from '@rsbuild/shared';
|
|
3
2
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
4
3
|
type CrossOriginOptions = {
|
|
5
4
|
crossOrigin: CrossOrigin;
|
|
6
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
7
5
|
};
|
|
8
6
|
export declare class HtmlCrossOriginPlugin implements RspackPluginInstance {
|
|
9
7
|
readonly name: string;
|
|
10
8
|
readonly crossOrigin: CrossOrigin;
|
|
11
|
-
readonly HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
12
9
|
constructor(options: CrossOriginOptions);
|
|
13
10
|
apply(compiler: Compiler): void;
|
|
14
11
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var HtmlCrossOriginPlugin_exports = {};
|
|
20
30
|
__export(HtmlCrossOriginPlugin_exports, {
|
|
21
31
|
HtmlCrossOriginPlugin: () => HtmlCrossOriginPlugin
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
|
|
34
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
24
35
|
class HtmlCrossOriginPlugin {
|
|
25
36
|
constructor(options) {
|
|
26
37
|
const { crossOrigin } = options;
|
|
27
38
|
this.name = "HtmlCrossOriginPlugin";
|
|
28
39
|
this.crossOrigin = crossOrigin;
|
|
29
|
-
this.HtmlPlugin = options.HtmlPlugin;
|
|
30
40
|
}
|
|
31
41
|
apply(compiler) {
|
|
32
42
|
if (!this.crossOrigin || // align with crossOriginLoading logic
|
|
@@ -35,7 +45,7 @@ class HtmlCrossOriginPlugin {
|
|
|
35
45
|
return;
|
|
36
46
|
}
|
|
37
47
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
38
|
-
|
|
48
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
|
|
39
49
|
this.name,
|
|
40
50
|
(alterAssetTags) => {
|
|
41
51
|
const {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
2
|
import { type Preconnect, type DnsPrefetch } from '@rsbuild/shared';
|
|
3
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
3
|
type NetworkPerformanceType = 'preconnect' | 'dnsPrefetch';
|
|
5
4
|
export declare class HtmlNetworkPerformancePlugin implements RspackPluginInstance {
|
|
6
5
|
readonly options: DnsPrefetch | Preconnect;
|
|
7
6
|
readonly type: NetworkPerformanceType;
|
|
8
|
-
|
|
9
|
-
constructor(options: DnsPrefetch | Preconnect, type: NetworkPerformanceType, HtmlPlugin: typeof HtmlWebpackPlugin);
|
|
7
|
+
constructor(options: DnsPrefetch | Preconnect, type: NetworkPerformanceType);
|
|
10
8
|
apply(compiler: Compiler): void;
|
|
11
9
|
}
|
|
12
10
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var HtmlNetworkPerformancePlugin_exports = {};
|
|
20
30
|
__export(HtmlNetworkPerformancePlugin_exports, {
|
|
@@ -22,6 +32,7 @@ __export(HtmlNetworkPerformancePlugin_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(HtmlNetworkPerformancePlugin_exports);
|
|
24
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
25
36
|
function generateLinks(options, type) {
|
|
26
37
|
const relMap = {
|
|
27
38
|
preconnect: "preconnect",
|
|
@@ -38,16 +49,15 @@ function generateLinks(options, type) {
|
|
|
38
49
|
}));
|
|
39
50
|
}
|
|
40
51
|
class HtmlNetworkPerformancePlugin {
|
|
41
|
-
constructor(options, type
|
|
52
|
+
constructor(options, type) {
|
|
42
53
|
this.options = options;
|
|
43
54
|
this.type = type;
|
|
44
|
-
this.HtmlPlugin = HtmlPlugin;
|
|
45
55
|
}
|
|
46
56
|
apply(compiler) {
|
|
47
57
|
compiler.hooks.compilation.tap(
|
|
48
58
|
`HTML${this.type}Plugin`,
|
|
49
59
|
(compilation) => {
|
|
50
|
-
|
|
60
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTagGroups.tap(
|
|
51
61
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
52
62
|
(htmlPluginData) => {
|
|
53
63
|
const { headTags } = htmlPluginData;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
3
2
|
type NonceOptions = {
|
|
4
3
|
nonce: string;
|
|
5
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
6
4
|
};
|
|
7
5
|
export declare class HtmlNoncePlugin implements RspackPluginInstance {
|
|
8
6
|
readonly name: string;
|
|
9
7
|
readonly nonce: string;
|
|
10
|
-
readonly HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
11
8
|
constructor(options: NonceOptions);
|
|
12
9
|
apply(compiler: Compiler): void;
|
|
13
10
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,25 +17,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var HtmlNoncePlugin_exports = {};
|
|
20
30
|
__export(HtmlNoncePlugin_exports, {
|
|
21
31
|
HtmlNoncePlugin: () => HtmlNoncePlugin
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(HtmlNoncePlugin_exports);
|
|
34
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
24
35
|
class HtmlNoncePlugin {
|
|
25
36
|
constructor(options) {
|
|
26
37
|
const { nonce } = options;
|
|
27
38
|
this.name = "HtmlNoncePlugin";
|
|
28
39
|
this.nonce = nonce;
|
|
29
|
-
this.HtmlPlugin = options.HtmlPlugin;
|
|
30
40
|
}
|
|
31
41
|
apply(compiler) {
|
|
32
42
|
if (!this.nonce) {
|
|
33
43
|
return;
|
|
34
44
|
}
|
|
35
45
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
36
|
-
|
|
46
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
|
|
37
47
|
this.name,
|
|
38
48
|
(alterAssetTags) => {
|
|
39
49
|
const {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
1
|
import type { Compiler } from '@rspack/core';
|
|
3
2
|
import { type HtmlInjectTag, type HtmlInjectTagDescriptor } from '@rsbuild/shared';
|
|
4
3
|
export interface HtmlTagsPluginOptions {
|
|
@@ -7,12 +6,7 @@ export interface HtmlTagsPluginOptions {
|
|
|
7
6
|
append?: HtmlInjectTag['append'];
|
|
8
7
|
includes?: string[];
|
|
9
8
|
tags?: HtmlInjectTagDescriptor[];
|
|
10
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
11
9
|
}
|
|
12
|
-
export interface AdditionalContext {
|
|
13
|
-
HtmlPlugin: Extract<HtmlTagsPluginOptions['HtmlPlugin'], Function>;
|
|
14
|
-
}
|
|
15
|
-
export type Context = Omit<HtmlTagsPluginOptions, keyof AdditionalContext> & AdditionalContext;
|
|
16
10
|
/** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Void_element} */
|
|
17
11
|
export declare const VOID_TAGS: string[];
|
|
18
12
|
/** @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also} */
|
|
@@ -24,7 +18,7 @@ export declare const FILE_ATTRS: {
|
|
|
24
18
|
export declare class HtmlTagsPlugin {
|
|
25
19
|
readonly name: string;
|
|
26
20
|
meta: Record<string, string>;
|
|
27
|
-
ctx:
|
|
21
|
+
ctx: HtmlTagsPluginOptions;
|
|
28
22
|
constructor(opts: HtmlTagsPluginOptions);
|
|
29
23
|
apply(compiler: Compiler): void;
|
|
30
24
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var HtmlTagsPlugin_exports = {};
|
|
20
30
|
__export(HtmlTagsPlugin_exports, {
|
|
@@ -24,6 +34,7 @@ __export(HtmlTagsPlugin_exports, {
|
|
|
24
34
|
VOID_TAGS: () => VOID_TAGS
|
|
25
35
|
});
|
|
26
36
|
module.exports = __toCommonJS(HtmlTagsPlugin_exports);
|
|
37
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
27
38
|
var import_shared = require("@rsbuild/shared");
|
|
28
39
|
const VOID_TAGS = [
|
|
29
40
|
"area",
|
|
@@ -69,7 +80,7 @@ class HtmlTagsPlugin {
|
|
|
69
80
|
apply(compiler) {
|
|
70
81
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
71
82
|
const compilationHash = compilation.hash || "";
|
|
72
|
-
const hooks =
|
|
83
|
+
const hooks = import_html_webpack_plugin.default.getHooks(compilation);
|
|
73
84
|
hooks.alterAssetTagGroups.tap(this.name, (params) => {
|
|
74
85
|
const includesCurrentFile = !this.ctx.includes || this.ctx.includes.includes(params.outputName);
|
|
75
86
|
if (!includesCurrentFile || !this.ctx.tags?.length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InlineChunkTest } from '@rsbuild/shared';
|
|
2
2
|
import type { Compiler, Compilation } from '@rspack/core';
|
|
3
|
-
import
|
|
3
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
4
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
5
5
|
export type InlineChunkHtmlPluginOptions = {
|
|
6
6
|
styleTests: InlineChunkTest[];
|
|
@@ -16,8 +16,7 @@ export declare class InlineChunkHtmlPlugin {
|
|
|
16
16
|
scriptTests: InlineChunkTest[];
|
|
17
17
|
distPath: InlineChunkHtmlPluginOptions['distPath'];
|
|
18
18
|
inlinedAssets: Set<string>;
|
|
19
|
-
|
|
20
|
-
constructor(htmlPlugin: typeof HtmlWebpackPlugin, {
|
|
19
|
+
constructor({
|
|
21
20
|
styleTests,
|
|
22
21
|
scriptTests,
|
|
23
22
|
distPath
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var InlineChunkHtmlPlugin_exports = {};
|
|
20
30
|
__export(InlineChunkHtmlPlugin_exports, {
|
|
@@ -23,14 +33,18 @@ __export(InlineChunkHtmlPlugin_exports, {
|
|
|
23
33
|
module.exports = __toCommonJS(InlineChunkHtmlPlugin_exports);
|
|
24
34
|
var import_path = require("path");
|
|
25
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
26
37
|
class InlineChunkHtmlPlugin {
|
|
27
|
-
constructor(
|
|
38
|
+
constructor({
|
|
39
|
+
styleTests,
|
|
40
|
+
scriptTests,
|
|
41
|
+
distPath
|
|
42
|
+
}) {
|
|
28
43
|
this.name = "InlineChunkHtmlPlugin";
|
|
29
44
|
this.styleTests = styleTests;
|
|
30
45
|
this.scriptTests = scriptTests;
|
|
31
46
|
this.distPath = distPath;
|
|
32
47
|
this.inlinedAssets = /* @__PURE__ */ new Set();
|
|
33
|
-
this.htmlPlugin = htmlPlugin;
|
|
34
48
|
}
|
|
35
49
|
/**
|
|
36
50
|
* If we inlined the chunk to HTML,we should update the value of sourceMappingURL,
|
|
@@ -146,7 +160,7 @@ class InlineChunkHtmlPlugin {
|
|
|
146
160
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
147
161
|
const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
|
|
148
162
|
const tagFunction = (tag) => this.getInlinedTag(publicPath, tag, compilation);
|
|
149
|
-
const hooks =
|
|
163
|
+
const hooks = import_html_webpack_plugin.default.getHooks(compilation);
|
|
150
164
|
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
151
165
|
assets.headTags = assets.headTags.map(tagFunction);
|
|
152
166
|
assets.bodyTags = assets.bodyTags.map(tagFunction);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type HtmlPlugin from 'html-webpack-plugin';
|
|
3
2
|
export declare class RemoveCssSourcemapPlugin {
|
|
4
3
|
name: string;
|
|
5
|
-
|
|
6
|
-
constructor(htmlPlugin: typeof HtmlPlugin);
|
|
4
|
+
constructor();
|
|
7
5
|
apply(compiler: Compiler): void;
|
|
8
6
|
}
|
|
@@ -23,9 +23,8 @@ __export(RemoveCssSourcemapPlugin_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
25
|
class RemoveCssSourcemapPlugin {
|
|
26
|
-
constructor(
|
|
26
|
+
constructor() {
|
|
27
27
|
this.name = "RemoveCssSourcemapPlugin";
|
|
28
|
-
this.htmlPlugin = htmlPlugin;
|
|
29
28
|
}
|
|
30
29
|
apply(compiler) {
|
|
31
30
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
@@ -15,16 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
18
|
-
import
|
|
18
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
19
19
|
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
type LinkType = 'preload' | 'prefetch';
|
|
21
|
-
export declare class
|
|
21
|
+
export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
|
|
22
22
|
readonly options: PreloadOrPreFetchOption;
|
|
23
23
|
resourceHints: HtmlWebpackPlugin.HtmlTagObject[];
|
|
24
24
|
type: LinkType;
|
|
25
|
-
HtmlPlugin: typeof HtmlWebpackPlugin;
|
|
26
25
|
HTMLCount: number;
|
|
27
|
-
constructor(options: true | PreloadOrPreFetchOption, type: LinkType,
|
|
26
|
+
constructor(options: true | PreloadOrPreFetchOption, type: LinkType, HTMLCount: number);
|
|
28
27
|
apply(compiler: Compiler): void;
|
|
29
28
|
}
|
|
30
29
|
export {};
|