@rsbuild/core 0.1.9 → 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/dist/cli/commands.js +6 -3
- package/dist/cli/config.d.ts +7 -1
- package/dist/cli/config.js +6 -3
- 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/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 +15 -7
- 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 +3 -7
- package/dist/provider/plugins/less.js +1 -1
- package/dist/provider/plugins/output.js +2 -2
- package/dist/provider/plugins/resolve.js +0 -5
- package/dist/provider/plugins/server.d.ts +2 -0
- package/dist/provider/plugins/server.js +70 -0
- package/dist/provider/plugins/swc.js +1 -1
- package/dist/provider/provider.js +15 -1
- package/dist/provider/shared.d.ts +1 -2
- package/dist/provider/shared.js +2 -15
- 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 +11 -25
- package/package.json +4 -4
- 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
|
@@ -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 {};
|
package/dist/rspack/{HtmlPreloadOrPrefetchPlugin/index.js → preload/HtmlPreloadOrPrefetchPlugin.js}
RENAMED
|
@@ -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,12 +17,21 @@ 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 HtmlPreloadOrPrefetchPlugin_exports = {};
|
|
20
30
|
__export(HtmlPreloadOrPrefetchPlugin_exports, {
|
|
21
|
-
|
|
31
|
+
HtmlPreloadOrPrefetchPlugin: () => HtmlPreloadOrPrefetchPlugin
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(HtmlPreloadOrPrefetchPlugin_exports);
|
|
34
|
+
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
24
35
|
var import_shared = require("@rsbuild/shared");
|
|
25
36
|
var import_helpers = require("./helpers");
|
|
26
37
|
/**
|
|
@@ -117,20 +128,19 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
|
|
|
117
128
|
}
|
|
118
129
|
return links;
|
|
119
130
|
}
|
|
120
|
-
class
|
|
121
|
-
constructor(options, type,
|
|
131
|
+
class HtmlPreloadOrPrefetchPlugin {
|
|
132
|
+
constructor(options, type, HTMLCount) {
|
|
122
133
|
this.resourceHints = [];
|
|
123
134
|
this.options = {
|
|
124
135
|
...defaultOptions,
|
|
125
136
|
...typeof options === "boolean" ? {} : options
|
|
126
137
|
};
|
|
127
138
|
this.type = type;
|
|
128
|
-
this.HtmlPlugin = HtmlPlugin;
|
|
129
139
|
this.HTMLCount = HTMLCount;
|
|
130
140
|
}
|
|
131
141
|
apply(compiler) {
|
|
132
142
|
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
133
|
-
|
|
143
|
+
import_html_webpack_plugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(
|
|
134
144
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
135
145
|
(htmlPluginData) => {
|
|
136
146
|
this.resourceHints = generateLinks(
|
|
@@ -143,7 +153,7 @@ class HTMLPreloadOrPrefetchPlugin {
|
|
|
143
153
|
return htmlPluginData;
|
|
144
154
|
}
|
|
145
155
|
);
|
|
146
|
-
|
|
156
|
+
import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
|
|
147
157
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
148
158
|
(htmlPluginData) => {
|
|
149
159
|
if (this.resourceHints) {
|
|
@@ -163,5 +173,5 @@ class HTMLPreloadOrPrefetchPlugin {
|
|
|
163
173
|
}
|
|
164
174
|
// Annotate the CommonJS export names for ESM import in node:
|
|
165
175
|
0 && (module.exports = {
|
|
166
|
-
|
|
176
|
+
HtmlPreloadOrPrefetchPlugin
|
|
167
177
|
});
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Server } from 'http';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RsbuildDevMiddlewareOptions, DevMiddlewareAPI, DevMiddleware as CustomDevMiddleware } from '@rsbuild/shared';
|
|
6
6
|
type Options = {
|
|
7
7
|
publicPaths: string[];
|
|
8
|
-
dev:
|
|
8
|
+
dev: RsbuildDevMiddlewareOptions['dev'];
|
|
9
9
|
devMiddleware?: CustomDevMiddleware;
|
|
10
10
|
};
|
|
11
11
|
export default class DevMiddleware extends EventEmitter {
|
|
@@ -26,11 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var compiler_dev_middleware_exports = {};
|
|
30
|
+
__export(compiler_dev_middleware_exports, {
|
|
31
31
|
default: () => DevMiddleware
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(compiler_dev_middleware_exports);
|
|
34
34
|
var import_events = require("events");
|
|
35
35
|
var import_socketServer = __toESM(require("./socketServer"));
|
|
36
36
|
const noop = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Server } from 'http';
|
|
3
3
|
import ws from '../../../compiled/ws';
|
|
4
|
-
import { type Stats, type
|
|
4
|
+
import { type Stats, type RsbuildDevMiddlewareOptions } from '@rsbuild/shared';
|
|
5
5
|
export default class SocketServer {
|
|
6
6
|
private wsServer;
|
|
7
7
|
private readonly sockets;
|
|
@@ -9,7 +9,7 @@ export default class SocketServer {
|
|
|
9
9
|
private app?;
|
|
10
10
|
private stats?;
|
|
11
11
|
private timer;
|
|
12
|
-
constructor(options:
|
|
12
|
+
constructor(options: RsbuildDevMiddlewareOptions['dev']);
|
|
13
13
|
prepare(app: Server): void;
|
|
14
14
|
updateStats(stats: Stats): void;
|
|
15
15
|
sockWrite(type: string, data?: Record<string, any> | string | boolean): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Server } from 'http';
|
|
3
|
+
import { RequestHandler, RsbuildDevMiddlewareOptions } from '@rsbuild/shared';
|
|
4
|
+
export declare const getMiddlewares: (options: RsbuildDevMiddlewareOptions, app: Server) => Promise<{
|
|
5
|
+
close: () => Promise<void>;
|
|
6
|
+
middlewares: RequestHandler[];
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
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
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var devMiddlewares_exports = {};
|
|
30
|
+
__export(devMiddlewares_exports, {
|
|
31
|
+
getMiddlewares: () => getMiddlewares
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(devMiddlewares_exports);
|
|
34
|
+
var import_url = __toESM(require("url"));
|
|
35
|
+
var import_compiler_dev_middleware = __toESM(require("./compiler-dev-middleware"));
|
|
36
|
+
var import_middlewares = require("./middlewares");
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
const applySetupMiddlewares = (dev, devMiddleware) => {
|
|
39
|
+
const setupMiddlewares = dev.setupMiddlewares || [];
|
|
40
|
+
const serverOptions = {
|
|
41
|
+
sockWrite: (type, data) => devMiddleware.sockWrite(type, data)
|
|
42
|
+
};
|
|
43
|
+
const before = [];
|
|
44
|
+
const after = [];
|
|
45
|
+
setupMiddlewares.forEach((handler) => {
|
|
46
|
+
handler(
|
|
47
|
+
{
|
|
48
|
+
unshift: (...handlers) => before.unshift(...handlers),
|
|
49
|
+
push: (...handlers) => after.push(...handlers)
|
|
50
|
+
},
|
|
51
|
+
serverOptions
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
return { before, after };
|
|
55
|
+
};
|
|
56
|
+
const applyDefaultMiddlewares = async ({
|
|
57
|
+
app,
|
|
58
|
+
middlewares,
|
|
59
|
+
dev,
|
|
60
|
+
devMiddleware,
|
|
61
|
+
output,
|
|
62
|
+
pwd
|
|
63
|
+
}) => {
|
|
64
|
+
if (dev.compress) {
|
|
65
|
+
const { default: compression } = await Promise.resolve().then(() => __toESM(require("../../compiled/http-compression")));
|
|
66
|
+
middlewares.push((req, res, next) => {
|
|
67
|
+
compression({
|
|
68
|
+
gzip: true,
|
|
69
|
+
brotli: false
|
|
70
|
+
})(req, res, next);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
middlewares.push((req, res, next) => {
|
|
74
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
75
|
+
const path = req.url ? import_url.default.parse(req.url).pathname : "";
|
|
76
|
+
if (path?.includes("hot-update")) {
|
|
77
|
+
res.setHeader("Access-Control-Allow-Credentials", "false");
|
|
78
|
+
}
|
|
79
|
+
const confHeaders = dev.headers;
|
|
80
|
+
if (confHeaders) {
|
|
81
|
+
for (const [key, value] of Object.entries(confHeaders)) {
|
|
82
|
+
res.setHeader(key, value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
next();
|
|
86
|
+
});
|
|
87
|
+
if (dev.proxy) {
|
|
88
|
+
const { createProxyMiddleware } = await Promise.resolve().then(() => __toESM(require("./proxy")));
|
|
89
|
+
const { middlewares: proxyMiddlewares } = createProxyMiddleware(
|
|
90
|
+
dev.proxy,
|
|
91
|
+
app
|
|
92
|
+
);
|
|
93
|
+
proxyMiddlewares.forEach((middleware) => {
|
|
94
|
+
middlewares.push(middleware);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
devMiddleware.init(app);
|
|
98
|
+
devMiddleware.middleware && middlewares.push(devMiddleware.middleware);
|
|
99
|
+
if (dev.publicDir && dev.publicDir.name) {
|
|
100
|
+
const { default: sirv } = await Promise.resolve().then(() => __toESM(require("../../compiled/sirv")));
|
|
101
|
+
const { name } = dev.publicDir;
|
|
102
|
+
const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(pwd, name);
|
|
103
|
+
const assetMiddleware = sirv(publicDir, {
|
|
104
|
+
etag: true,
|
|
105
|
+
dev: true
|
|
106
|
+
});
|
|
107
|
+
middlewares.push(assetMiddleware);
|
|
108
|
+
}
|
|
109
|
+
const { distPath } = output;
|
|
110
|
+
middlewares.push(
|
|
111
|
+
(0, import_middlewares.getHtmlFallbackMiddleware)({
|
|
112
|
+
distPath: (0, import_path.isAbsolute)(distPath) ? distPath : (0, import_path.join)(pwd, distPath),
|
|
113
|
+
callback: devMiddleware.middleware,
|
|
114
|
+
htmlFallback: dev.htmlFallback
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
if (dev.historyApiFallback) {
|
|
118
|
+
const { default: connectHistoryApiFallback } = await Promise.resolve().then(() => __toESM(require("../../compiled/connect-history-api-fallback")));
|
|
119
|
+
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
120
|
+
dev.historyApiFallback === true ? {} : dev.historyApiFallback
|
|
121
|
+
);
|
|
122
|
+
middlewares.push(historyApiFallbackMiddleware);
|
|
123
|
+
devMiddleware.middleware && middlewares.push(devMiddleware.middleware);
|
|
124
|
+
}
|
|
125
|
+
middlewares.push(import_middlewares.faviconFallbackMiddleware);
|
|
126
|
+
middlewares.push(import_middlewares.notFoundMiddleware);
|
|
127
|
+
};
|
|
128
|
+
const getMiddlewares = async (options, app) => {
|
|
129
|
+
const middlewares = [];
|
|
130
|
+
const devMiddleware = new import_compiler_dev_middleware.default({
|
|
131
|
+
dev: options.dev,
|
|
132
|
+
publicPaths: options.output.publicPaths,
|
|
133
|
+
devMiddleware: options.devMiddleware
|
|
134
|
+
});
|
|
135
|
+
const { before, after } = applySetupMiddlewares(options.dev, devMiddleware);
|
|
136
|
+
before.forEach((fn) => middlewares.push(fn));
|
|
137
|
+
await applyDefaultMiddlewares({
|
|
138
|
+
app,
|
|
139
|
+
middlewares,
|
|
140
|
+
dev: options.dev,
|
|
141
|
+
devMiddleware,
|
|
142
|
+
output: options.output,
|
|
143
|
+
pwd: options.pwd
|
|
144
|
+
});
|
|
145
|
+
after.forEach((fn) => middlewares.push(fn));
|
|
146
|
+
return {
|
|
147
|
+
close: async () => {
|
|
148
|
+
devMiddleware.close();
|
|
149
|
+
},
|
|
150
|
+
middlewares
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
getMiddlewares
|
|
156
|
+
});
|