@rsbuild/webpack 1.6.1 → 1.6.2

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.
@@ -3,7 +3,7 @@ import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import picocolors from "picocolors";
4
4
  import webpack from "webpack";
5
5
  import { Console } from "node:console";
6
- import { logger } from "./index.js";
6
+ import { logger } from "./161.js";
7
7
  __webpack_require__.add({
8
8
  "../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js": function(module) {
9
9
  let ansiEscapes = module.exports;
@@ -1887,7 +1887,7 @@ function createNonTTYLogger() {
1887
1887
  let suffix = picocolors.gray(`(${id})`);
1888
1888
  if (done) {
1889
1889
  if (100 === prevPercentage) return;
1890
- prevPercentage = 100, hasErrors ? logger.error(`built failed in ${compileTime} ${suffix}`) : logger.ready(`built in ${compileTime} ${suffix}`);
1890
+ prevPercentage = 100, hasErrors ? logger.error(`build failed in ${compileTime} ${suffix}`) : logger.ready(`built in ${compileTime} ${suffix}`);
1891
1891
  } else current - prevPercentage > 10 && (prevPercentage = current, logger.info(`build progress: ${current.toFixed(0)}% ${suffix}`));
1892
1892
  }
1893
1893
  };
package/dist/161.js ADDED
@@ -0,0 +1,294 @@
1
+ import { logger } from "@rsbuild/core";
2
+ import MultiStats from "webpack/lib/MultiStats.js";
3
+ import { reduceConfigsWithContext } from "reduce-configs";
4
+ import node_fs from "node:fs";
5
+ let castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
6
+ arr
7
+ ];
8
+ async function modifyWebpackChain(context, utils, chain) {
9
+ logger.debug('modify webpack chain');
10
+ let [modifiedChain] = await context.hooks.modifyWebpackChain.callChain({
11
+ environment: utils.environment.name,
12
+ args: [
13
+ chain,
14
+ utils
15
+ ]
16
+ });
17
+ if (utils.environment.config.tools?.webpackChain) for (let item of castArray(utils.environment.config.tools.webpackChain))item(modifiedChain, utils);
18
+ return logger.debug('modify webpack chain done'), modifiedChain;
19
+ }
20
+ async function modifyWebpackConfig(context, webpackConfig, utils) {
21
+ logger.debug('modify webpack config');
22
+ let [modifiedConfig] = await context.hooks.modifyWebpackConfig.callChain({
23
+ environment: utils.environment.name,
24
+ args: [
25
+ webpackConfig,
26
+ utils
27
+ ]
28
+ });
29
+ return utils.environment.config.tools?.webpack && (modifiedConfig = reduceConfigsWithContext({
30
+ initial: modifiedConfig,
31
+ config: utils.environment.config.tools.webpack,
32
+ ctx: utils,
33
+ mergeFn: utils.mergeConfig
34
+ })), logger.debug('modify webpack config done'), modifiedConfig;
35
+ }
36
+ async function getChainUtils(target, environment, environments, helpers) {
37
+ let { default: webpack } = await import("webpack");
38
+ return {
39
+ ...helpers.getChainUtils(target, environment, environments),
40
+ name: ({
41
+ web: 'client',
42
+ node: 'server',
43
+ 'web-worker': 'web-worker'
44
+ })[target] || '',
45
+ webpack,
46
+ HtmlWebpackPlugin: helpers.getHTMLPlugin()
47
+ };
48
+ }
49
+ async function generateWebpackConfig({ target, context, environment, helpers }) {
50
+ let chainUtils = await getChainUtils(target, context.environments[environment], context.environments, helpers), { default: webpack } = await import("webpack"), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = webpack, bundlerChain = await helpers.modifyBundlerChain(context, {
51
+ ...chainUtils,
52
+ bundler: {
53
+ BannerPlugin,
54
+ DefinePlugin,
55
+ IgnorePlugin,
56
+ ProvidePlugin,
57
+ SourceMapDevToolPlugin,
58
+ HotModuleReplacementPlugin
59
+ }
60
+ }), webpackConfig = (await modifyWebpackChain(context, chainUtils, bundlerChain)).toConfig(), configUtils = helpers.getConfigUtils(()=>webpackConfig, chainUtils);
61
+ return webpackConfig = await modifyWebpackConfig(context, webpackConfig, configUtils);
62
+ }
63
+ async function initConfigs({ context, pluginManager, rsbuildOptions, helpers }) {
64
+ let normalizedConfig = await helpers.initRsbuildConfig({
65
+ context,
66
+ pluginManager
67
+ }), webpackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environment, config])=>generateWebpackConfig({
68
+ target: config.output.target,
69
+ context,
70
+ environment,
71
+ helpers
72
+ })));
73
+ if ('verbose' === logger.level) {
74
+ let inspect = async ()=>{
75
+ await helpers.inspectConfig({
76
+ context,
77
+ bundler: 'webpack',
78
+ pluginManager,
79
+ inspectOptions: {
80
+ verbose: !0,
81
+ writeToDisk: !0
82
+ },
83
+ rsbuildOptions,
84
+ bundlerConfigs: webpackConfigs
85
+ });
86
+ };
87
+ context.hooks.onBeforeBuild.tap(async ({ isFirstCompile })=>{
88
+ isFirstCompile && await inspect();
89
+ }), context.hooks.onAfterStartDevServer.tap(inspect);
90
+ }
91
+ return {
92
+ webpackConfigs
93
+ };
94
+ }
95
+ async function createCompiler_createCompiler(options) {
96
+ logger.debug('creating compiler');
97
+ let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
98
+ await context.hooks.onBeforeCreateCompiler.callBatch({
99
+ bundlerConfigs: webpackConfigs,
100
+ environments: context.environments
101
+ });
102
+ let { default: webpack } = await import("webpack"), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
103
+ return compiler.hooks.run.tap(HOOK_NAME, ()=>{
104
+ context.buildState.status = 'building';
105
+ }), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
106
+ context.buildState.status = 'building';
107
+ }), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
108
+ context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
109
+ }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
110
+ let stats = helpers.getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
111
+ context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
112
+ let { message, level } = helpers.formatStats(stats, hasErrors);
113
+ 'error' === level ? logger.error(message) : 'warning' === level && logger.warn(message);
114
+ }), 'dev' === context.action && helpers.registerDevHook({
115
+ compiler,
116
+ context,
117
+ bundlerConfigs: webpackConfigs,
118
+ MultiStatsCtor: MultiStats
119
+ }), await context.hooks.onAfterCreateCompiler.callBatch({
120
+ compiler,
121
+ environments: context.environments
122
+ }), logger.debug('compiler created'), {
123
+ compiler,
124
+ webpackConfigs
125
+ };
126
+ }
127
+ let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
128
+ let compiler, bundlerConfigs, { helpers, context } = initOptions;
129
+ if (customCompiler) compiler = customCompiler, bundlerConfigs = customCompiler.options;
130
+ else {
131
+ let result = await createCompiler_createCompiler(initOptions);
132
+ compiler = result.compiler, bundlerConfigs = result.webpackConfigs;
133
+ }
134
+ if (helpers.registerBuildHook({
135
+ context,
136
+ bundlerConfigs: bundlerConfigs,
137
+ compiler,
138
+ isWatch: !!watch,
139
+ MultiStatsCtor: MultiStats
140
+ }), watch) return compiler.watch({}, (err)=>{
141
+ err && logger.error(err);
142
+ }), {
143
+ close: ()=>new Promise((resolve)=>{
144
+ compiler.close(()=>{
145
+ resolve();
146
+ });
147
+ })
148
+ };
149
+ let { stats } = await new Promise((resolve, reject)=>{
150
+ compiler.run((err, stats)=>{
151
+ err ? reject(err) : context.buildState.hasErrors ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
152
+ closeErr && logger.error(closeErr), resolve({
153
+ stats
154
+ });
155
+ });
156
+ });
157
+ });
158
+ return {
159
+ stats,
160
+ close: async ()=>{}
161
+ };
162
+ };
163
+ async function applyTsConfigPathsPlugin({ chain, CHAIN_ID, mainFields, extensions, configFile }) {
164
+ let { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
165
+ chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
166
+ {
167
+ configFile,
168
+ extensions,
169
+ mainFields: mainFields
170
+ }
171
+ ]);
172
+ }
173
+ function isWebTarget(target) {
174
+ return castArray(target).includes('web') || target.includes('web-worker');
175
+ }
176
+ let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers })=>{
177
+ let { default: cssExtractPlugin } = await import("mini-css-extract-plugin");
178
+ if (helpers.setCssExtractPlugin(cssExtractPlugin), helpers.setHTMLPlugin) {
179
+ let { default: htmlPlugin } = await import("html-webpack-plugin");
180
+ helpers.setHTMLPlugin(htmlPlugin);
181
+ }
182
+ let createCompiler = async ()=>(await createCompiler_createCompiler({
183
+ context,
184
+ pluginManager,
185
+ rsbuildOptions,
186
+ helpers
187
+ })).compiler;
188
+ return pluginManager.addPlugins([
189
+ {
190
+ name: 'rsbuild-webpack:adaptor',
191
+ setup (api) {
192
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
193
+ let mainFields, { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
194
+ tsconfigPath && 'prefer-tsconfig' === aliasStrategy && await applyTsConfigPathsPlugin({
195
+ chain,
196
+ CHAIN_ID,
197
+ configFile: tsconfigPath,
198
+ mainFields: (mainFields = chain.resolve.mainFields.values()).length ? mainFields : isWebTarget(target) ? [
199
+ 'browser',
200
+ 'module',
201
+ 'main'
202
+ ] : [
203
+ 'module',
204
+ 'main'
205
+ ],
206
+ extensions: chain.resolve.extensions.values()
207
+ });
208
+ let { progressBar } = config.dev;
209
+ if (progressBar) {
210
+ let { ProgressPlugin } = await import("./0~999.js").then((mod)=>({
211
+ ProgressPlugin: mod.ProgressPlugin
212
+ }));
213
+ chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
214
+ {
215
+ id: environment.name,
216
+ prettyTime: helpers.prettyTime,
217
+ ...!0 === progressBar ? {} : progressBar
218
+ }
219
+ ]);
220
+ }
221
+ let { copy } = config.output;
222
+ if (copy) {
223
+ let { default: CopyPlugin } = await import("copy-webpack-plugin"), options = Array.isArray(copy) ? {
224
+ patterns: copy
225
+ } : copy;
226
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [
227
+ options
228
+ ]);
229
+ }
230
+ }), api.modifyWebpackConfig(async (config)=>{
231
+ let copyPlugin = config.plugins?.find((item)=>item?.constructor.name === 'CopyPlugin');
232
+ copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !node_fs.existsSync(pattern.context)) && (config.plugins = config.plugins?.filter((item)=>item?.constructor.name !== 'CopyPlugin'));
233
+ });
234
+ }
235
+ }
236
+ ]), {
237
+ bundler: 'webpack',
238
+ createCompiler,
239
+ async initConfigs () {
240
+ let { webpackConfigs } = await initConfigs({
241
+ context,
242
+ pluginManager,
243
+ rsbuildOptions,
244
+ helpers
245
+ });
246
+ return webpackConfigs;
247
+ },
248
+ async createDevServer (options) {
249
+ let config = await helpers.initRsbuildConfig({
250
+ context,
251
+ pluginManager
252
+ });
253
+ return helpers.createDevServer({
254
+ context,
255
+ pluginManager,
256
+ rsbuildOptions
257
+ }, createCompiler, config, options);
258
+ },
259
+ async startDevServer (options) {
260
+ let config = await helpers.initRsbuildConfig({
261
+ context,
262
+ pluginManager
263
+ });
264
+ return (await helpers.createDevServer({
265
+ context,
266
+ pluginManager,
267
+ rsbuildOptions
268
+ }, createCompiler, config, options)).listen();
269
+ },
270
+ build: async (options)=>build({
271
+ context,
272
+ pluginManager,
273
+ rsbuildOptions,
274
+ helpers
275
+ }, options),
276
+ async inspectConfig (inspectOptions) {
277
+ let bundlerConfigs = (await initConfigs({
278
+ context,
279
+ pluginManager,
280
+ rsbuildOptions,
281
+ helpers
282
+ })).webpackConfigs;
283
+ return await helpers.inspectConfig({
284
+ context,
285
+ pluginManager,
286
+ bundler: 'webpack',
287
+ bundlerConfigs,
288
+ rsbuildOptions,
289
+ inspectOptions
290
+ });
291
+ }
292
+ };
293
+ };
294
+ export { logger, webpackProvider };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
3
  exports.ids = [
4
- "363"
4
+ "56"
5
5
  ], exports.modules = {
6
6
  "./src/progress/ProgressPlugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7
7
  __webpack_require__.d(__webpack_exports__, {
@@ -134,7 +134,7 @@ exports.ids = [
134
134
  let suffix = external_picocolors_default().gray(`(${id})`);
135
135
  if (done) {
136
136
  if (100 === prevPercentage) return;
137
- prevPercentage = 100, hasErrors ? core_.logger.error(`built failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
137
+ prevPercentage = 100, hasErrors ? core_.logger.error(`build failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
138
138
  } else current - prevPercentage > 10 && (prevPercentage = current, core_.logger.info(`build progress: ${current.toFixed(0)}% ${suffix}`));
139
139
  }
140
140
  };
package/dist/index.cjs CHANGED
@@ -188,7 +188,7 @@ for(var __webpack_i__ in (()=>{
188
188
  }
189
189
  let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
190
190
  let compiler, bundlerConfigs, { helpers, context } = initOptions;
191
- if (customCompiler) compiler = customCompiler;
191
+ if (customCompiler) compiler = customCompiler, bundlerConfigs = customCompiler.options;
192
192
  else {
193
193
  let result = await createCompiler_createCompiler(initOptions);
194
194
  compiler = result.compiler, bundlerConfigs = result.webpackConfigs;
@@ -273,7 +273,7 @@ for(var __webpack_i__ in (()=>{
273
273
  if (progressBar) {
274
274
  let { ProgressPlugin } = await Promise.all([
275
275
  __webpack_require__.e("0"),
276
- __webpack_require__.e("363")
276
+ __webpack_require__.e("56")
277
277
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
278
278
  chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
279
279
  {
package/dist/index.js CHANGED
@@ -1,294 +1 @@
1
- import { logger } from "@rsbuild/core";
2
- import MultiStats from "webpack/lib/MultiStats.js";
3
- import { reduceConfigsWithContext } from "reduce-configs";
4
- import node_fs from "node:fs";
5
- let castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
6
- arr
7
- ];
8
- async function modifyWebpackChain(context, utils, chain) {
9
- logger.debug('modify webpack chain');
10
- let [modifiedChain] = await context.hooks.modifyWebpackChain.callChain({
11
- environment: utils.environment.name,
12
- args: [
13
- chain,
14
- utils
15
- ]
16
- });
17
- if (utils.environment.config.tools?.webpackChain) for (let item of castArray(utils.environment.config.tools.webpackChain))item(modifiedChain, utils);
18
- return logger.debug('modify webpack chain done'), modifiedChain;
19
- }
20
- async function modifyWebpackConfig(context, webpackConfig, utils) {
21
- logger.debug('modify webpack config');
22
- let [modifiedConfig] = await context.hooks.modifyWebpackConfig.callChain({
23
- environment: utils.environment.name,
24
- args: [
25
- webpackConfig,
26
- utils
27
- ]
28
- });
29
- return utils.environment.config.tools?.webpack && (modifiedConfig = reduceConfigsWithContext({
30
- initial: modifiedConfig,
31
- config: utils.environment.config.tools.webpack,
32
- ctx: utils,
33
- mergeFn: utils.mergeConfig
34
- })), logger.debug('modify webpack config done'), modifiedConfig;
35
- }
36
- async function getChainUtils(target, environment, environments, helpers) {
37
- let { default: webpack } = await import("webpack");
38
- return {
39
- ...helpers.getChainUtils(target, environment, environments),
40
- name: ({
41
- web: 'client',
42
- node: 'server',
43
- 'web-worker': 'web-worker'
44
- })[target] || '',
45
- webpack,
46
- HtmlWebpackPlugin: helpers.getHTMLPlugin()
47
- };
48
- }
49
- async function generateWebpackConfig({ target, context, environment, helpers }) {
50
- let chainUtils = await getChainUtils(target, context.environments[environment], context.environments, helpers), { default: webpack } = await import("webpack"), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = webpack, bundlerChain = await helpers.modifyBundlerChain(context, {
51
- ...chainUtils,
52
- bundler: {
53
- BannerPlugin,
54
- DefinePlugin,
55
- IgnorePlugin,
56
- ProvidePlugin,
57
- SourceMapDevToolPlugin,
58
- HotModuleReplacementPlugin
59
- }
60
- }), webpackConfig = (await modifyWebpackChain(context, chainUtils, bundlerChain)).toConfig(), configUtils = helpers.getConfigUtils(()=>webpackConfig, chainUtils);
61
- return webpackConfig = await modifyWebpackConfig(context, webpackConfig, configUtils);
62
- }
63
- async function initConfigs({ context, pluginManager, rsbuildOptions, helpers }) {
64
- let normalizedConfig = await helpers.initRsbuildConfig({
65
- context,
66
- pluginManager
67
- }), webpackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environment, config])=>generateWebpackConfig({
68
- target: config.output.target,
69
- context,
70
- environment,
71
- helpers
72
- })));
73
- if ('verbose' === logger.level) {
74
- let inspect = async ()=>{
75
- await helpers.inspectConfig({
76
- context,
77
- bundler: 'webpack',
78
- pluginManager,
79
- inspectOptions: {
80
- verbose: !0,
81
- writeToDisk: !0
82
- },
83
- rsbuildOptions,
84
- bundlerConfigs: webpackConfigs
85
- });
86
- };
87
- context.hooks.onBeforeBuild.tap(async ({ isFirstCompile })=>{
88
- isFirstCompile && await inspect();
89
- }), context.hooks.onAfterStartDevServer.tap(inspect);
90
- }
91
- return {
92
- webpackConfigs
93
- };
94
- }
95
- async function createCompiler_createCompiler(options) {
96
- logger.debug('creating compiler');
97
- let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
98
- await context.hooks.onBeforeCreateCompiler.callBatch({
99
- bundlerConfigs: webpackConfigs,
100
- environments: context.environments
101
- });
102
- let { default: webpack } = await import("webpack"), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
103
- return compiler.hooks.run.tap(HOOK_NAME, ()=>{
104
- context.buildState.status = 'building';
105
- }), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
106
- context.buildState.status = 'building';
107
- }), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
108
- context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
109
- }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
110
- let stats = helpers.getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
111
- context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
112
- let { message, level } = helpers.formatStats(stats, hasErrors);
113
- 'error' === level ? logger.error(message) : 'warning' === level && logger.warn(message);
114
- }), 'dev' === context.action && helpers.registerDevHook({
115
- compiler,
116
- context,
117
- bundlerConfigs: webpackConfigs,
118
- MultiStatsCtor: MultiStats
119
- }), await context.hooks.onAfterCreateCompiler.callBatch({
120
- compiler,
121
- environments: context.environments
122
- }), logger.debug('compiler created'), {
123
- compiler,
124
- webpackConfigs
125
- };
126
- }
127
- let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
128
- let compiler, bundlerConfigs, { helpers, context } = initOptions;
129
- if (customCompiler) compiler = customCompiler;
130
- else {
131
- let result = await createCompiler_createCompiler(initOptions);
132
- compiler = result.compiler, bundlerConfigs = result.webpackConfigs;
133
- }
134
- if (helpers.registerBuildHook({
135
- context,
136
- bundlerConfigs: bundlerConfigs,
137
- compiler,
138
- isWatch: !!watch,
139
- MultiStatsCtor: MultiStats
140
- }), watch) return compiler.watch({}, (err)=>{
141
- err && logger.error(err);
142
- }), {
143
- close: ()=>new Promise((resolve)=>{
144
- compiler.close(()=>{
145
- resolve();
146
- });
147
- })
148
- };
149
- let { stats } = await new Promise((resolve, reject)=>{
150
- compiler.run((err, stats)=>{
151
- err ? reject(err) : context.buildState.hasErrors ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
152
- closeErr && logger.error(closeErr), resolve({
153
- stats
154
- });
155
- });
156
- });
157
- });
158
- return {
159
- stats,
160
- close: async ()=>{}
161
- };
162
- };
163
- async function applyTsConfigPathsPlugin({ chain, CHAIN_ID, mainFields, extensions, configFile }) {
164
- let { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
165
- chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
166
- {
167
- configFile,
168
- extensions,
169
- mainFields: mainFields
170
- }
171
- ]);
172
- }
173
- function isWebTarget(target) {
174
- return castArray(target).includes('web') || target.includes('web-worker');
175
- }
176
- let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers })=>{
177
- let { default: cssExtractPlugin } = await import("mini-css-extract-plugin");
178
- if (helpers.setCssExtractPlugin(cssExtractPlugin), helpers.setHTMLPlugin) {
179
- let { default: htmlPlugin } = await import("html-webpack-plugin");
180
- helpers.setHTMLPlugin(htmlPlugin);
181
- }
182
- let createCompiler = async ()=>(await createCompiler_createCompiler({
183
- context,
184
- pluginManager,
185
- rsbuildOptions,
186
- helpers
187
- })).compiler;
188
- return pluginManager.addPlugins([
189
- {
190
- name: 'rsbuild-webpack:adaptor',
191
- setup (api) {
192
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
193
- let mainFields, { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
194
- tsconfigPath && 'prefer-tsconfig' === aliasStrategy && await applyTsConfigPathsPlugin({
195
- chain,
196
- CHAIN_ID,
197
- configFile: tsconfigPath,
198
- mainFields: (mainFields = chain.resolve.mainFields.values()).length ? mainFields : isWebTarget(target) ? [
199
- 'browser',
200
- 'module',
201
- 'main'
202
- ] : [
203
- 'module',
204
- 'main'
205
- ],
206
- extensions: chain.resolve.extensions.values()
207
- });
208
- let { progressBar } = config.dev;
209
- if (progressBar) {
210
- let { ProgressPlugin } = await import("./0~24.js").then((mod)=>({
211
- ProgressPlugin: mod.ProgressPlugin
212
- }));
213
- chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
214
- {
215
- id: environment.name,
216
- prettyTime: helpers.prettyTime,
217
- ...!0 === progressBar ? {} : progressBar
218
- }
219
- ]);
220
- }
221
- let { copy } = config.output;
222
- if (copy) {
223
- let { default: CopyPlugin } = await import("copy-webpack-plugin"), options = Array.isArray(copy) ? {
224
- patterns: copy
225
- } : copy;
226
- chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [
227
- options
228
- ]);
229
- }
230
- }), api.modifyWebpackConfig(async (config)=>{
231
- let copyPlugin = config.plugins?.find((item)=>item?.constructor.name === 'CopyPlugin');
232
- copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !node_fs.existsSync(pattern.context)) && (config.plugins = config.plugins?.filter((item)=>item?.constructor.name !== 'CopyPlugin'));
233
- });
234
- }
235
- }
236
- ]), {
237
- bundler: 'webpack',
238
- createCompiler,
239
- async initConfigs () {
240
- let { webpackConfigs } = await initConfigs({
241
- context,
242
- pluginManager,
243
- rsbuildOptions,
244
- helpers
245
- });
246
- return webpackConfigs;
247
- },
248
- async createDevServer (options) {
249
- let config = await helpers.initRsbuildConfig({
250
- context,
251
- pluginManager
252
- });
253
- return helpers.createDevServer({
254
- context,
255
- pluginManager,
256
- rsbuildOptions
257
- }, createCompiler, config, options);
258
- },
259
- async startDevServer (options) {
260
- let config = await helpers.initRsbuildConfig({
261
- context,
262
- pluginManager
263
- });
264
- return (await helpers.createDevServer({
265
- context,
266
- pluginManager,
267
- rsbuildOptions
268
- }, createCompiler, config, options)).listen();
269
- },
270
- build: async (options)=>build({
271
- context,
272
- pluginManager,
273
- rsbuildOptions,
274
- helpers
275
- }, options),
276
- async inspectConfig (inspectOptions) {
277
- let bundlerConfigs = (await initConfigs({
278
- context,
279
- pluginManager,
280
- rsbuildOptions,
281
- helpers
282
- })).webpackConfigs;
283
- return await helpers.inspectConfig({
284
- context,
285
- pluginManager,
286
- bundler: 'webpack',
287
- bundlerConfigs,
288
- rsbuildOptions,
289
- inspectOptions
290
- });
291
- }
292
- };
293
- };
294
- export { logger, webpackProvider };
1
+ export { webpackProvider } from "./161.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "homepage": "https://rsbuild.rs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,22 +24,22 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "copy-webpack-plugin": "11.0.0",
27
- "html-webpack-plugin": "^5.6.4",
27
+ "html-webpack-plugin": "^5.6.5",
28
28
  "mini-css-extract-plugin": "2.9.4",
29
29
  "picocolors": "^1.1.1",
30
30
  "reduce-configs": "^1.1.1",
31
31
  "tsconfig-paths-webpack-plugin": "4.2.0",
32
- "webpack": "^5.102.1"
32
+ "webpack": "^5.103.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@rslib/core": "0.17.1",
36
- "@types/node": "^24.9.2",
35
+ "@rslib/core": "0.18.0",
36
+ "@types/node": "^24.10.1",
37
37
  "ansi-escapes": "4.3.2",
38
38
  "cli-truncate": "2.1.0",
39
39
  "patch-console": "1.0.0",
40
40
  "typescript": "^5.9.3",
41
- "@scripts/test-helper": "1.0.1",
42
- "@rsbuild/core": "1.6.4"
41
+ "@rsbuild/core": "1.6.8",
42
+ "@scripts/test-helper": "1.0.1"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@rsbuild/core": "^1.3.21"