@rsbuild/core 0.3.11 → 0.4.1
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 +2 -2
- package/dist/cli/config.d.ts +1 -6
- package/dist/cli/config.js +20 -34
- package/dist/cli/prepare.js +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -3
- package/dist/createRsbuild.js +6 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -3
- package/dist/pluginManager.d.ts +7 -0
- package/dist/pluginManager.js +176 -0
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/moduleFederation.d.ts +2 -0
- package/dist/plugins/moduleFederation.js +123 -0
- package/dist/provider/config.d.ts +1 -1
- package/dist/provider/config.js +107 -8
- package/dist/provider/{core/createCompiler.d.ts → createCompiler.d.ts} +1 -1
- package/dist/provider/{core/createCompiler.js → createCompiler.js} +1 -1
- package/dist/provider/{core/createContext.d.ts → createContext.d.ts} +1 -1
- package/dist/provider/{core/createContext.js → createContext.js} +2 -2
- package/dist/provider/index.d.ts +6 -6
- package/dist/provider/index.js +11 -9
- package/dist/provider/initConfigs.d.ts +11 -0
- package/dist/provider/{core/initConfigs.js → initConfigs.js} +8 -7
- package/dist/provider/{core/initHooks.d.ts → initHooks.d.ts} +2 -1
- package/dist/provider/{core/initHooks.js → initHooks.js} +1 -0
- package/dist/provider/initPlugins.d.ts +7 -0
- package/dist/provider/{core/initPlugins.js → initPlugins.js} +3 -2
- package/dist/provider/{core/inspectConfig.d.ts → inspectConfig.d.ts} +1 -1
- package/dist/provider/{core/inspectConfig.js → inspectConfig.js} +3 -3
- package/dist/provider/plugins/css.js +0 -1
- package/dist/provider/plugins/less.js +2 -1
- package/dist/provider/plugins/swc.js +1 -1
- package/dist/provider/provider.js +20 -20
- package/dist/provider/{core/rspackConfig.d.ts → rspackConfig.d.ts} +1 -1
- package/dist/provider/{core/rspackConfig.js → rspackConfig.js} +2 -2
- package/dist/provider/shared.d.ts +1 -1
- package/dist/provider/shared.js +79 -14
- package/dist/server/devServer.js +1 -0
- package/dist/server/helper.d.ts +14 -0
- package/dist/server/helper.js +64 -1
- package/dist/server/proxy.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
- package/dist/provider/core/initConfigs.d.ts +0 -11
- package/dist/provider/core/initPlugins.d.ts +0 -7
- /package/dist/provider/{core/build.d.ts → build.d.ts} +0 -0
- /package/dist/provider/{core/build.js → build.js} +0 -0
- /package/dist/provider/{core/devMiddleware.d.ts → devMiddleware.d.ts} +0 -0
- /package/dist/provider/{core/devMiddleware.js → devMiddleware.js} +0 -0
package/dist/provider/config.js
CHANGED
|
@@ -24,15 +24,114 @@ __export(config_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(config_exports);
|
|
25
25
|
var import_node_path = require("node:path");
|
|
26
26
|
var import_shared = require("@rsbuild/shared");
|
|
27
|
+
const getDefaultDevConfig = () => ({
|
|
28
|
+
hmr: true,
|
|
29
|
+
liveReload: true,
|
|
30
|
+
assetPrefix: import_shared.DEFAULT_ASSET_PREFIX,
|
|
31
|
+
startUrl: false
|
|
32
|
+
});
|
|
33
|
+
const getDefaultServerConfig = () => ({
|
|
34
|
+
port: import_shared.DEFAULT_PORT,
|
|
35
|
+
host: import_shared.DEFAULT_DEV_HOST,
|
|
36
|
+
htmlFallback: "index",
|
|
37
|
+
compress: true,
|
|
38
|
+
printUrls: true,
|
|
39
|
+
strictPort: false,
|
|
40
|
+
publicDir: {
|
|
41
|
+
name: "public",
|
|
42
|
+
copyOnBuild: true
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const getDefaultSourceConfig = () => ({
|
|
46
|
+
alias: {},
|
|
47
|
+
define: {},
|
|
48
|
+
aliasStrategy: "prefer-tsconfig",
|
|
49
|
+
preEntry: [],
|
|
50
|
+
decorators: {
|
|
51
|
+
version: "legacy"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const getDefaultHtmlConfig = () => ({
|
|
55
|
+
meta: {
|
|
56
|
+
charset: { charset: "UTF-8" },
|
|
57
|
+
viewport: "width=device-width, initial-scale=1.0"
|
|
58
|
+
},
|
|
59
|
+
title: "Rsbuild App",
|
|
60
|
+
inject: "head",
|
|
61
|
+
mountId: import_shared.DEFAULT_MOUNT_ID,
|
|
62
|
+
crossorigin: false,
|
|
63
|
+
outputStructure: "flat",
|
|
64
|
+
scriptLoading: "defer"
|
|
65
|
+
});
|
|
66
|
+
const getDefaultSecurityConfig = () => ({
|
|
67
|
+
nonce: ""
|
|
68
|
+
});
|
|
69
|
+
const getDefaultToolsConfig = () => ({
|
|
70
|
+
cssExtract: {
|
|
71
|
+
loaderOptions: {},
|
|
72
|
+
pluginOptions: {}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const getDefaultPerformanceConfig = () => ({
|
|
76
|
+
profile: false,
|
|
77
|
+
buildCache: true,
|
|
78
|
+
printFileSize: true,
|
|
79
|
+
removeConsole: false,
|
|
80
|
+
removeMomentLocale: false,
|
|
81
|
+
chunkSplit: {
|
|
82
|
+
strategy: "split-by-experience"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const getDefaultOutputConfig = () => ({
|
|
86
|
+
targets: ["web"],
|
|
87
|
+
distPath: {
|
|
88
|
+
root: import_shared.ROOT_DIST_DIR,
|
|
89
|
+
js: import_shared.JS_DIST_DIR,
|
|
90
|
+
css: import_shared.CSS_DIST_DIR,
|
|
91
|
+
svg: import_shared.SVG_DIST_DIR,
|
|
92
|
+
font: import_shared.FONT_DIST_DIR,
|
|
93
|
+
html: import_shared.HTML_DIST_DIR,
|
|
94
|
+
wasm: import_shared.WASM_DIST_DIR,
|
|
95
|
+
image: import_shared.IMAGE_DIST_DIR,
|
|
96
|
+
media: import_shared.MEDIA_DIST_DIR,
|
|
97
|
+
server: import_shared.SERVER_DIST_DIR,
|
|
98
|
+
worker: import_shared.SERVICE_WORKER_DIST_DIR
|
|
99
|
+
},
|
|
100
|
+
assetPrefix: import_shared.DEFAULT_ASSET_PREFIX,
|
|
101
|
+
filename: {},
|
|
102
|
+
charset: "ascii",
|
|
103
|
+
polyfill: "usage",
|
|
104
|
+
dataUriLimit: {
|
|
105
|
+
svg: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
106
|
+
font: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
107
|
+
image: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
108
|
+
media: import_shared.DEFAULT_DATA_URL_SIZE
|
|
109
|
+
},
|
|
110
|
+
legalComments: "linked",
|
|
111
|
+
injectStyles: false,
|
|
112
|
+
disableMinimize: false,
|
|
113
|
+
sourceMap: {
|
|
114
|
+
js: void 0,
|
|
115
|
+
css: false
|
|
116
|
+
},
|
|
117
|
+
filenameHash: true,
|
|
118
|
+
enableCssModuleTSDeclaration: false,
|
|
119
|
+
inlineScripts: false,
|
|
120
|
+
inlineStyles: false,
|
|
121
|
+
cssModules: {
|
|
122
|
+
auto: true,
|
|
123
|
+
exportLocalsConvention: "camelCase"
|
|
124
|
+
}
|
|
125
|
+
});
|
|
27
126
|
const createDefaultConfig = () => ({
|
|
28
|
-
dev:
|
|
29
|
-
server:
|
|
30
|
-
html:
|
|
31
|
-
source:
|
|
32
|
-
output:
|
|
33
|
-
tools:
|
|
34
|
-
security:
|
|
35
|
-
performance:
|
|
127
|
+
dev: getDefaultDevConfig(),
|
|
128
|
+
server: getDefaultServerConfig(),
|
|
129
|
+
html: getDefaultHtmlConfig(),
|
|
130
|
+
source: getDefaultSourceConfig(),
|
|
131
|
+
output: getDefaultOutputConfig(),
|
|
132
|
+
tools: getDefaultToolsConfig(),
|
|
133
|
+
security: getDefaultSecurityConfig(),
|
|
134
|
+
performance: getDefaultPerformanceConfig()
|
|
36
135
|
});
|
|
37
136
|
function getDefaultEntry(root) {
|
|
38
137
|
const files = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RspackConfig, type RspackCompiler, type RspackMultiCompiler, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
|
|
2
2
|
import { type InitConfigsOptions } from './initConfigs';
|
|
3
|
-
import type { InternalContext } from '
|
|
3
|
+
import type { InternalContext } from '../types';
|
|
4
4
|
export declare function createCompiler({ context, rspackConfigs, }: {
|
|
5
5
|
context: InternalContext;
|
|
6
6
|
rspackConfigs: RspackConfig[];
|
|
@@ -34,7 +34,7 @@ __export(createCompiler_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(createCompiler_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
var import_initConfigs = require("./initConfigs");
|
|
37
|
-
var import_shared2 = require("
|
|
37
|
+
var import_shared2 = require("./shared");
|
|
38
38
|
async function createCompiler({
|
|
39
39
|
context,
|
|
40
40
|
rspackConfigs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BundlerType, type RsbuildConfig, type RsbuildContext, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { InternalContext } from '
|
|
2
|
+
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function updateContextByNormalizedConfig(context: RsbuildContext, config: NormalizedConfig): void;
|
|
4
4
|
export declare function createPublicContext(context: RsbuildContext): Readonly<RsbuildContext>;
|
|
5
5
|
/**
|
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(createContext_exports);
|
|
|
26
26
|
var import_node_path = require("node:path");
|
|
27
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
28
|
var import_initHooks = require("./initHooks");
|
|
29
|
-
var import_config = require("
|
|
29
|
+
var import_config = require("./config");
|
|
30
30
|
function getAbsolutePath(root, filepath) {
|
|
31
31
|
return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
|
|
32
32
|
}
|
|
@@ -43,7 +43,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
43
43
|
const context = {
|
|
44
44
|
entry: config.source?.entry || {},
|
|
45
45
|
targets: config.output?.targets || [],
|
|
46
|
-
version: "0.
|
|
46
|
+
version: "0.4.1",
|
|
47
47
|
rootPath,
|
|
48
48
|
distPath,
|
|
49
49
|
cachePath,
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { rspackProvider } from './provider';
|
|
2
2
|
export type { Rspack, RspackConfig } from '@rsbuild/shared';
|
|
3
|
-
export { createContext, createPublicContext } from './
|
|
4
|
-
export { initPlugins } from '
|
|
5
|
-
export { initHooks, type Hooks } from './
|
|
6
|
-
export { initRsbuildConfig } from './
|
|
7
|
-
export { getPluginAPI } from './
|
|
3
|
+
export { createContext, createPublicContext } from './createContext';
|
|
4
|
+
export { initPlugins, createPluginManager } from '../pluginManager';
|
|
5
|
+
export { initHooks, type Hooks } from './initHooks';
|
|
6
|
+
export { initRsbuildConfig } from './initConfigs';
|
|
7
|
+
export { getPluginAPI } from './initPlugins';
|
|
8
8
|
export { applyBaseCSSRule, applyCSSModuleRule } from './plugins/css';
|
|
9
9
|
export type { InternalContext } from '../types';
|
|
10
10
|
export { setHTMLPlugin, getHTMLPlugin } from './htmlPluginUtil';
|
|
11
11
|
export { formatStats } from './shared';
|
|
12
|
-
export { getChainUtils } from './
|
|
12
|
+
export { getChainUtils } from './rspackConfig';
|
|
13
13
|
export { applySwcDecoratorConfig } from './plugins/swc';
|
package/dist/provider/index.js
CHANGED
|
@@ -22,28 +22,29 @@ __export(provider_exports, {
|
|
|
22
22
|
applyCSSModuleRule: () => import_css.applyCSSModuleRule,
|
|
23
23
|
applySwcDecoratorConfig: () => import_swc.applySwcDecoratorConfig,
|
|
24
24
|
createContext: () => import_createContext.createContext,
|
|
25
|
+
createPluginManager: () => import_pluginManager.createPluginManager,
|
|
25
26
|
createPublicContext: () => import_createContext.createPublicContext,
|
|
26
|
-
formatStats: () =>
|
|
27
|
+
formatStats: () => import_shared.formatStats,
|
|
27
28
|
getChainUtils: () => import_rspackConfig.getChainUtils,
|
|
28
29
|
getHTMLPlugin: () => import_htmlPluginUtil.getHTMLPlugin,
|
|
29
30
|
getPluginAPI: () => import_initPlugins.getPluginAPI,
|
|
30
31
|
initHooks: () => import_initHooks.initHooks,
|
|
31
|
-
initPlugins: () =>
|
|
32
|
+
initPlugins: () => import_pluginManager.initPlugins,
|
|
32
33
|
initRsbuildConfig: () => import_initConfigs.initRsbuildConfig,
|
|
33
34
|
rspackProvider: () => import_provider.rspackProvider,
|
|
34
35
|
setHTMLPlugin: () => import_htmlPluginUtil.setHTMLPlugin
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(provider_exports);
|
|
37
38
|
var import_provider = require("./provider");
|
|
38
|
-
var import_createContext = require("./
|
|
39
|
-
var
|
|
40
|
-
var import_initHooks = require("./
|
|
41
|
-
var import_initConfigs = require("./
|
|
42
|
-
var import_initPlugins = require("./
|
|
39
|
+
var import_createContext = require("./createContext");
|
|
40
|
+
var import_pluginManager = require("../pluginManager");
|
|
41
|
+
var import_initHooks = require("./initHooks");
|
|
42
|
+
var import_initConfigs = require("./initConfigs");
|
|
43
|
+
var import_initPlugins = require("./initPlugins");
|
|
43
44
|
var import_css = require("./plugins/css");
|
|
44
45
|
var import_htmlPluginUtil = require("./htmlPluginUtil");
|
|
45
|
-
var
|
|
46
|
-
var import_rspackConfig = require("./
|
|
46
|
+
var import_shared = require("./shared");
|
|
47
|
+
var import_rspackConfig = require("./rspackConfig");
|
|
47
48
|
var import_swc = require("./plugins/swc");
|
|
48
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
50
|
0 && (module.exports = {
|
|
@@ -51,6 +52,7 @@ var import_swc = require("./plugins/swc");
|
|
|
51
52
|
applyCSSModuleRule,
|
|
52
53
|
applySwcDecoratorConfig,
|
|
53
54
|
createContext,
|
|
55
|
+
createPluginManager,
|
|
54
56
|
createPublicContext,
|
|
55
57
|
formatStats,
|
|
56
58
|
getChainUtils,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PluginManager, type RspackConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { InternalContext, NormalizedConfig } from '../types';
|
|
3
|
+
export type InitConfigsOptions = {
|
|
4
|
+
context: InternalContext;
|
|
5
|
+
pluginManager: PluginManager;
|
|
6
|
+
rsbuildOptions: Required<CreateRsbuildOptions>;
|
|
7
|
+
};
|
|
8
|
+
export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
|
|
9
|
+
export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
|
|
10
|
+
rspackConfigs: RspackConfig[];
|
|
11
|
+
}>;
|
|
@@ -26,7 +26,8 @@ var import_shared = require("@rsbuild/shared");
|
|
|
26
26
|
var import_createContext = require("./createContext");
|
|
27
27
|
var import_inspectConfig = require("./inspectConfig");
|
|
28
28
|
var import_rspackConfig = require("./rspackConfig");
|
|
29
|
-
var import_config = require("
|
|
29
|
+
var import_config = require("./config");
|
|
30
|
+
var import_pluginManager = require("../pluginManager");
|
|
30
31
|
async function modifyRsbuildConfig(context) {
|
|
31
32
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
32
33
|
const [modified] = await context.hooks.modifyRsbuildConfig.call(
|
|
@@ -38,14 +39,14 @@ async function modifyRsbuildConfig(context) {
|
|
|
38
39
|
}
|
|
39
40
|
async function initRsbuildConfig({
|
|
40
41
|
context,
|
|
41
|
-
|
|
42
|
+
pluginManager
|
|
42
43
|
}) {
|
|
43
44
|
if (context.normalizedConfig) {
|
|
44
45
|
return context.normalizedConfig;
|
|
45
46
|
}
|
|
46
|
-
await (0,
|
|
47
|
+
await (0, import_pluginManager.initPlugins)({
|
|
47
48
|
pluginAPI: context.pluginAPI,
|
|
48
|
-
|
|
49
|
+
pluginManager
|
|
49
50
|
});
|
|
50
51
|
await modifyRsbuildConfig(context);
|
|
51
52
|
context.normalizedConfig = (0, import_config.normalizeConfig)(context.config);
|
|
@@ -54,10 +55,10 @@ async function initRsbuildConfig({
|
|
|
54
55
|
}
|
|
55
56
|
async function initConfigs({
|
|
56
57
|
context,
|
|
57
|
-
|
|
58
|
+
pluginManager,
|
|
58
59
|
rsbuildOptions
|
|
59
60
|
}) {
|
|
60
|
-
const normalizedConfig = await initRsbuildConfig({ context,
|
|
61
|
+
const normalizedConfig = await initRsbuildConfig({ context, pluginManager });
|
|
61
62
|
const { targets } = normalizedConfig.output;
|
|
62
63
|
const rspackConfigs = await Promise.all(
|
|
63
64
|
targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
|
|
@@ -70,7 +71,7 @@ async function initConfigs({
|
|
|
70
71
|
};
|
|
71
72
|
(0, import_inspectConfig.inspectConfig)({
|
|
72
73
|
context,
|
|
73
|
-
|
|
74
|
+
pluginManager,
|
|
74
75
|
inspectOptions,
|
|
75
76
|
rsbuildOptions,
|
|
76
77
|
bundlerConfigs: rspackConfigs
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
|
|
1
|
+
import type { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
|
|
2
2
|
export declare function initHooks(): {
|
|
3
3
|
/** parameters are not bundler-related */
|
|
4
4
|
onExit: import("@rsbuild/shared").AsyncHook<OnExitFn>;
|
|
5
5
|
onDevCompileDone: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
|
|
6
|
+
onCloseDevServer: import("@rsbuild/shared").AsyncHook<OnCloseDevServerFn>;
|
|
6
7
|
onAfterStartDevServer: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
|
|
7
8
|
onBeforeStartDevServer: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
|
|
8
9
|
onAfterStartProdServer: import("@rsbuild/shared").AsyncHook<OnAfterStartProdServerFn>;
|
|
@@ -27,6 +27,7 @@ function initHooks() {
|
|
|
27
27
|
/** parameters are not bundler-related */
|
|
28
28
|
onExit: (0, import_shared.createAsyncHook)(),
|
|
29
29
|
onDevCompileDone: (0, import_shared.createAsyncHook)(),
|
|
30
|
+
onCloseDevServer: (0, import_shared.createAsyncHook)(),
|
|
30
31
|
onAfterStartDevServer: (0, import_shared.createAsyncHook)(),
|
|
31
32
|
onBeforeStartDevServer: (0, import_shared.createAsyncHook)(),
|
|
32
33
|
onAfterStartProdServer: (0, import_shared.createAsyncHook)(),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PluginManager, type RsbuildPluginAPI } from '@rsbuild/shared';
|
|
2
|
+
import type { InternalContext, NormalizedConfig } from '../types';
|
|
3
|
+
export declare function getHTMLPathByEntry(entryName: string, config: NormalizedConfig): string;
|
|
4
|
+
export declare function getPluginAPI({ context, pluginManager, }: {
|
|
5
|
+
context: InternalContext;
|
|
6
|
+
pluginManager: PluginManager;
|
|
7
|
+
}): RsbuildPluginAPI;
|
|
@@ -31,7 +31,7 @@ function getHTMLPathByEntry(entryName, config) {
|
|
|
31
31
|
}
|
|
32
32
|
function getPluginAPI({
|
|
33
33
|
context,
|
|
34
|
-
|
|
34
|
+
pluginManager
|
|
35
35
|
}) {
|
|
36
36
|
const { hooks } = context;
|
|
37
37
|
const publicContext = (0, import_createContext.createPublicContext)(context);
|
|
@@ -71,11 +71,12 @@ function getPluginAPI({
|
|
|
71
71
|
getHTMLPaths,
|
|
72
72
|
getRsbuildConfig,
|
|
73
73
|
getNormalizedConfig,
|
|
74
|
-
isPluginExists:
|
|
74
|
+
isPluginExists: pluginManager.isPluginExists,
|
|
75
75
|
// Hooks
|
|
76
76
|
onExit: hooks.onExit.tap,
|
|
77
77
|
onAfterBuild: hooks.onAfterBuild.tap,
|
|
78
78
|
onBeforeBuild: hooks.onBeforeBuild.tap,
|
|
79
|
+
onCloseDevServer: hooks.onCloseDevServer.tap,
|
|
79
80
|
onDevCompileDone: hooks.onDevCompileDone.tap,
|
|
80
81
|
modifyBundlerChain: hooks.modifyBundlerChain.tap,
|
|
81
82
|
modifyRspackConfig: hooks.modifyRspackConfig.tap,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InitConfigsOptions } from './initConfigs';
|
|
2
2
|
import { type RspackConfig, type InspectConfigResult, type InspectConfigOptions } from '@rsbuild/shared';
|
|
3
|
-
export declare function inspectConfig({ context,
|
|
3
|
+
export declare function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
|
|
4
4
|
inspectOptions?: InspectConfigOptions;
|
|
5
5
|
bundlerConfigs?: RspackConfig[];
|
|
6
6
|
}): Promise<InspectConfigResult<'rspack'>>;
|
|
@@ -26,7 +26,7 @@ var import_initConfigs = require("./initConfigs");
|
|
|
26
26
|
var import_shared = require("@rsbuild/shared");
|
|
27
27
|
async function inspectConfig({
|
|
28
28
|
context,
|
|
29
|
-
|
|
29
|
+
pluginManager,
|
|
30
30
|
rsbuildOptions,
|
|
31
31
|
bundlerConfigs,
|
|
32
32
|
inspectOptions = {}
|
|
@@ -38,12 +38,12 @@ async function inspectConfig({
|
|
|
38
38
|
}
|
|
39
39
|
const rspackConfigs = bundlerConfigs || (await (0, import_initConfigs.initConfigs)({
|
|
40
40
|
context,
|
|
41
|
-
|
|
41
|
+
pluginManager,
|
|
42
42
|
rsbuildOptions
|
|
43
43
|
})).rspackConfigs;
|
|
44
44
|
const rsbuildDebugConfig = {
|
|
45
45
|
...context.normalizedConfig,
|
|
46
|
-
pluginNames:
|
|
46
|
+
pluginNames: pluginManager.plugins.map((p) => p.name)
|
|
47
47
|
};
|
|
48
48
|
const rawRsbuildConfig = await (0, import_shared.stringifyConfig)(
|
|
49
49
|
rsbuildDebugConfig,
|
|
@@ -42,7 +42,8 @@ function pluginLess() {
|
|
|
42
42
|
const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(import_shared.LESS_REGEX);
|
|
43
43
|
const { excludes, options } = (0, import_shared.getLessLoaderOptions)(
|
|
44
44
|
config.tools.less,
|
|
45
|
-
config.output.sourceMap.css
|
|
45
|
+
config.output.sourceMap.css,
|
|
46
|
+
api.context.rootPath
|
|
46
47
|
);
|
|
47
48
|
excludes.forEach((item) => {
|
|
48
49
|
rule.exclude.add(item);
|
|
@@ -97,7 +97,7 @@ const pluginSwc = () => ({
|
|
|
97
97
|
rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
|
|
98
98
|
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
99
99
|
or: ["text/javascript", "application/javascript"]
|
|
100
|
-
}).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
|
|
100
|
+
}).resolve.set("fullySpecified", false).end().use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -32,24 +32,24 @@ __export(provider_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(provider_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_createContext = require("./
|
|
36
|
-
var import_initConfigs = require("./
|
|
37
|
-
var import_initPlugins = require("./
|
|
35
|
+
var import_createContext = require("./createContext");
|
|
36
|
+
var import_initConfigs = require("./initConfigs");
|
|
37
|
+
var import_initPlugins = require("./initPlugins");
|
|
38
38
|
var import_shared2 = require("./shared");
|
|
39
39
|
const rspackProvider = async ({
|
|
40
|
-
|
|
40
|
+
pluginManager,
|
|
41
41
|
rsbuildOptions,
|
|
42
42
|
plugins
|
|
43
43
|
}) => {
|
|
44
44
|
const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
|
|
45
45
|
const context = await (0, import_createContext.createContext)(rsbuildOptions, rsbuildConfig, "rspack");
|
|
46
|
-
const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context,
|
|
46
|
+
const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context, pluginManager });
|
|
47
47
|
context.pluginAPI = pluginAPI;
|
|
48
48
|
const createCompiler = async () => {
|
|
49
|
-
const { createCompiler: createCompiler2 } = await Promise.resolve().then(() => __toESM(require("./
|
|
49
|
+
const { createCompiler: createCompiler2 } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
|
|
50
50
|
const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
|
|
51
51
|
context,
|
|
52
|
-
|
|
52
|
+
pluginManager,
|
|
53
53
|
rsbuildOptions
|
|
54
54
|
});
|
|
55
55
|
return createCompiler2({
|
|
@@ -63,50 +63,50 @@ const rspackProvider = async ({
|
|
|
63
63
|
createCompiler,
|
|
64
64
|
publicContext: (0, import_createContext.createPublicContext)(context),
|
|
65
65
|
async applyDefaultPlugins() {
|
|
66
|
-
|
|
66
|
+
pluginManager.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
|
|
67
67
|
},
|
|
68
68
|
async getServerAPIs(options) {
|
|
69
69
|
const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
|
|
70
|
-
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./
|
|
71
|
-
await (0, import_initConfigs.initRsbuildConfig)({ context,
|
|
70
|
+
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
|
|
71
|
+
await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
|
|
72
72
|
return getServerAPIs(
|
|
73
|
-
{ context,
|
|
73
|
+
{ context, pluginManager, rsbuildOptions },
|
|
74
74
|
createDevMiddleware,
|
|
75
75
|
options
|
|
76
76
|
);
|
|
77
77
|
},
|
|
78
78
|
async startDevServer(options) {
|
|
79
79
|
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
|
|
80
|
-
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./
|
|
81
|
-
await (0, import_initConfigs.initRsbuildConfig)({ context,
|
|
80
|
+
const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
|
|
81
|
+
await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
|
|
82
82
|
return startDevServer(
|
|
83
|
-
{ context,
|
|
83
|
+
{ context, pluginManager, rsbuildOptions },
|
|
84
84
|
createDevMiddleware,
|
|
85
85
|
options
|
|
86
86
|
);
|
|
87
87
|
},
|
|
88
88
|
async preview(options) {
|
|
89
89
|
const { startProdServer } = await Promise.resolve().then(() => __toESM(require("../server/prodServer")));
|
|
90
|
-
await (0, import_initConfigs.initRsbuildConfig)({ context,
|
|
90
|
+
await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
|
|
91
91
|
return startProdServer(context, context.config, options);
|
|
92
92
|
},
|
|
93
93
|
async build(options) {
|
|
94
|
-
const { build } = await Promise.resolve().then(() => __toESM(require("./
|
|
95
|
-
return build({ context,
|
|
94
|
+
const { build } = await Promise.resolve().then(() => __toESM(require("./build")));
|
|
95
|
+
return build({ context, pluginManager, rsbuildOptions }, options);
|
|
96
96
|
},
|
|
97
97
|
async initConfigs() {
|
|
98
98
|
const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
|
|
99
99
|
context,
|
|
100
|
-
|
|
100
|
+
pluginManager,
|
|
101
101
|
rsbuildOptions
|
|
102
102
|
});
|
|
103
103
|
return rspackConfigs;
|
|
104
104
|
},
|
|
105
105
|
async inspectConfig(inspectOptions) {
|
|
106
|
-
const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./
|
|
106
|
+
const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./inspectConfig")));
|
|
107
107
|
return inspectConfig({
|
|
108
108
|
context,
|
|
109
|
-
|
|
109
|
+
pluginManager,
|
|
110
110
|
rsbuildOptions,
|
|
111
111
|
inspectOptions
|
|
112
112
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RspackConfig, type RsbuildTarget, type ModifyChainUtils } from '@rsbuild/shared';
|
|
2
|
-
import type { InternalContext } from '
|
|
2
|
+
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function getChainUtils(target: RsbuildTarget): ModifyChainUtils;
|
|
4
4
|
export declare function generateRspackConfig({ target, context, }: {
|
|
5
5
|
target: RsbuildTarget;
|
|
@@ -33,8 +33,8 @@ __export(rspackConfig_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackConfig_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
var import_shared2 = require("
|
|
37
|
-
var import_htmlPluginUtil = require("
|
|
36
|
+
var import_shared2 = require("./shared");
|
|
37
|
+
var import_htmlPluginUtil = require("./htmlPluginUtil");
|
|
38
38
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
39
39
|
(0, import_shared.debug)("modify Rspack config");
|
|
40
40
|
let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
|
|
@@ -6,7 +6,7 @@ export declare const rspackMinVersion = "0.5.0";
|
|
|
6
6
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
|
7
7
|
export declare const getCompiledPath: (packageName: string) => string;
|
|
8
8
|
export declare const BUILTIN_LOADER = "builtin:";
|
|
9
|
-
export declare function formatStats(stats: Stats | MultiStats
|
|
9
|
+
export declare function formatStats(stats: Stats | MultiStats): {
|
|
10
10
|
message: string;
|
|
11
11
|
level: string;
|
|
12
12
|
} | {
|