@rsbuild/webpack 1.0.1-beta.8 → 1.0.1-beta.9

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/index.cjs CHANGED
@@ -39,7 +39,7 @@ var __publicField = (obj, key, value) => {
39
39
  };
40
40
 
41
41
  // src/shared.ts
42
- var import_core, getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, getRsbuildInspectConfig, chainToConfig, modifyBundlerChain, onCompileDone, prettyTime, castArray;
42
+ var import_core, getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, getRsbuildInspectConfig, chainToConfig, modifyBundlerChain, onBeforeBuild, onCompileDone, prettyTime, castArray;
43
43
  var init_shared = __esm({
44
44
  "src/shared.ts"() {
45
45
  "use strict";
@@ -56,6 +56,7 @@ var init_shared = __esm({
56
56
  getRsbuildInspectConfig,
57
57
  chainToConfig,
58
58
  modifyBundlerChain,
59
+ onBeforeBuild,
59
60
  onCompileDone,
60
61
  prettyTime
61
62
  } = import_core.__internalHelper);
@@ -275,7 +276,11 @@ async function initConfigs({
275
276
  bundlerConfigs: webpackConfigs
276
277
  });
277
278
  };
278
- context.hooks.onBeforeBuild.tap(inspect);
279
+ context.hooks.onBeforeBuild.tap(({ isFirstCompile }) => {
280
+ if (isFirstCompile) {
281
+ inspect();
282
+ }
283
+ });
279
284
  context.hooks.onAfterStartDevServer.tap(inspect);
280
285
  }
281
286
  return {
@@ -2458,10 +2463,11 @@ var init_build = __esm({
2458
2463
  bundlerConfigs = webpackConfigs;
2459
2464
  }
2460
2465
  let isFirstCompile = true;
2461
- await context.hooks.onBeforeBuild.call({
2466
+ const beforeBuild = async () => await context.hooks.onBeforeBuild.call({
2462
2467
  bundlerConfigs,
2463
2468
  environments: context.environments,
2464
- isWatch: Boolean(watch)
2469
+ isWatch: Boolean(watch),
2470
+ isFirstCompile
2465
2471
  });
2466
2472
  const onDone = async (stats) => {
2467
2473
  const p = context.hooks.onAfterBuild.call({
@@ -2473,14 +2479,19 @@ var init_build = __esm({
2473
2479
  isFirstCompile = false;
2474
2480
  await p;
2475
2481
  };
2482
+ onBeforeBuild(compiler, beforeBuild, watch);
2476
2483
  onCompileDone(compiler, onDone, import_MultiStats2.default);
2477
2484
  if (watch) {
2478
- compiler.watch({}, (err) => {
2485
+ const watching = compiler.watch({}, (err) => {
2479
2486
  if (err) {
2480
2487
  import_core7.logger.error(err);
2481
2488
  }
2482
2489
  });
2483
- return;
2490
+ return {
2491
+ close: () => new Promise((resolve) => {
2492
+ watching.close(resolve);
2493
+ })
2494
+ };
2484
2495
  }
2485
2496
  await new Promise(
2486
2497
  (resolve, reject) => {
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ var init_esm = __esm({
57
57
 
58
58
  // src/shared.ts
59
59
  import { __internalHelper } from "@rsbuild/core";
60
- var getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, getRsbuildInspectConfig, chainToConfig, modifyBundlerChain, onCompileDone, prettyTime, castArray;
60
+ var getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, getRsbuildInspectConfig, chainToConfig, modifyBundlerChain, onBeforeBuild, onCompileDone, prettyTime, castArray;
61
61
  var init_shared = __esm({
62
62
  "src/shared.ts"() {
63
63
  "use strict";
@@ -74,6 +74,7 @@ var init_shared = __esm({
74
74
  getRsbuildInspectConfig,
75
75
  chainToConfig,
76
76
  modifyBundlerChain,
77
+ onBeforeBuild,
77
78
  onCompileDone,
78
79
  prettyTime
79
80
  } = __internalHelper);
@@ -300,7 +301,11 @@ async function initConfigs({
300
301
  bundlerConfigs: webpackConfigs
301
302
  });
302
303
  };
303
- context.hooks.onBeforeBuild.tap(inspect);
304
+ context.hooks.onBeforeBuild.tap(({ isFirstCompile }) => {
305
+ if (isFirstCompile) {
306
+ inspect();
307
+ }
308
+ });
304
309
  context.hooks.onAfterStartDevServer.tap(inspect);
305
310
  }
306
311
  return {
@@ -2507,10 +2512,11 @@ var init_build = __esm({
2507
2512
  bundlerConfigs = webpackConfigs;
2508
2513
  }
2509
2514
  let isFirstCompile = true;
2510
- await context.hooks.onBeforeBuild.call({
2515
+ const beforeBuild = async () => await context.hooks.onBeforeBuild.call({
2511
2516
  bundlerConfigs,
2512
2517
  environments: context.environments,
2513
- isWatch: Boolean(watch)
2518
+ isWatch: Boolean(watch),
2519
+ isFirstCompile
2514
2520
  });
2515
2521
  const onDone = async (stats) => {
2516
2522
  const p = context.hooks.onAfterBuild.call({
@@ -2522,14 +2528,19 @@ var init_build = __esm({
2522
2528
  isFirstCompile = false;
2523
2529
  await p;
2524
2530
  };
2531
+ onBeforeBuild(compiler, beforeBuild, watch);
2525
2532
  onCompileDone(compiler, onDone, WebpackMultiStats2);
2526
2533
  if (watch) {
2527
- compiler.watch({}, (err) => {
2534
+ const watching = compiler.watch({}, (err) => {
2528
2535
  if (err) {
2529
2536
  logger6.error(err);
2530
2537
  }
2531
2538
  });
2532
- return;
2539
+ return {
2540
+ close: () => new Promise((resolve) => {
2541
+ watching.close(resolve);
2542
+ })
2543
+ };
2533
2544
  }
2534
2545
  await new Promise(
2535
2546
  (resolve, reject) => {
@@ -1,3 +1,5 @@
1
1
  import type { BuildOptions } from '@rsbuild/core';
2
2
  import { type InitConfigsOptions } from './initConfigs';
3
- export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions) => Promise<void>;
3
+ export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions) => Promise<void | {
4
+ close: () => Promise<void>;
5
+ }>;
@@ -11,7 +11,7 @@ declare const getChainUtils: typeof __internalHelper.getChainUtils, initRsbuildC
11
11
  content: string;
12
12
  }>;
13
13
  environmentConfigs: import("@rsbuild/core").InspectConfigResult["origin"]["environmentConfigs"];
14
- }, chainToConfig: typeof __internalHelper.chainToConfig, modifyBundlerChain: typeof __internalHelper.modifyBundlerChain, onCompileDone: (compiler: import("@rspack/core").Compiler | import("@rspack/core").MultiCompiler, onDone: (stats: import("@rspack/core").Stats | import("@rspack/core").MultiStats) => Promise<void>, MultiStatsCtor: new (stats: import("@rspack/core").Stats[]) => import("@rspack/core").MultiStats) => void, prettyTime: (seconds: number) => string;
15
- export { getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, chainToConfig, modifyBundlerChain, onCompileDone, prettyTime, getRsbuildInspectConfig, };
14
+ }, chainToConfig: typeof __internalHelper.chainToConfig, modifyBundlerChain: typeof __internalHelper.modifyBundlerChain, onBeforeBuild: (compiler: import("@rspack/core").Compiler | import("@rspack/core").MultiCompiler, onBefore: () => Promise<any>, isWatch?: boolean) => void, onCompileDone: (compiler: import("@rspack/core").Compiler | import("@rspack/core").MultiCompiler, onDone: (stats: import("@rspack/core").Stats | import("@rspack/core").MultiStats) => Promise<void>, MultiStatsCtor: new (stats: import("@rspack/core").Stats[]) => import("@rspack/core").MultiStats) => void, prettyTime: (seconds: number) => string;
15
+ export { getChainUtils, initRsbuildConfig, createDevServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles, chainToConfig, modifyBundlerChain, onCompileDone, onBeforeBuild, prettyTime, getRsbuildInspectConfig, };
16
16
  export type InternalContext = __internalHelper.InternalContext;
17
17
  export declare const castArray: <T>(arr?: T | T[]) => T[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "1.0.1-beta.8",
3
+ "version": "1.0.1-beta.9",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "reduce-configs": "^1.0.0",
31
31
  "tsconfig-paths-webpack-plugin": "4.1.0",
32
32
  "webpack": "^5.93.0",
33
- "@rsbuild/core": "1.0.1-beta.8"
33
+ "@rsbuild/core": "1.0.1-beta.9"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "18.x",
@@ -38,7 +38,7 @@
38
38
  "cli-truncate": "2.1.0",
39
39
  "patch-console": "1.0.0",
40
40
  "typescript": "^5.5.2",
41
- "@scripts/test-helper": "1.0.1-beta.8"
41
+ "@scripts/test-helper": "1.0.1-beta.9"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public",