@rushstack/heft-webpack5-plugin 1.0.0 → 1.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/CHANGELOG.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@rushstack/heft-webpack5-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "1.2.0",
6
+ "tag": "@rushstack/heft-webpack5-plugin_v1.2.0",
7
+ "date": "Wed, 08 Oct 2025 00:13:28 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "Allow infrastructure logs to be printed."
12
+ },
13
+ {
14
+ "comment": "Use project-level webpack dependency when it's installed."
15
+ }
16
+ ],
17
+ "dependency": [
18
+ {
19
+ "comment": "Updating dependency \"@rushstack/debug-certificate-manager\" to `1.6.1`"
20
+ },
21
+ {
22
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.17.0`"
23
+ },
24
+ {
25
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.1.1`"
26
+ },
27
+ {
28
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.19.1`"
29
+ },
30
+ {
31
+ "comment": "Updating dependency \"@rushstack/heft\" from `^1.1.0` to `1.1.1`"
32
+ }
33
+ ]
34
+ }
35
+ },
36
+ {
37
+ "version": "1.1.0",
38
+ "tag": "@rushstack/heft-webpack5-plugin_v1.1.0",
39
+ "date": "Fri, 03 Oct 2025 20:09:59 GMT",
40
+ "comments": {
41
+ "minor": [
42
+ {
43
+ "comment": "Normalize import of builtin modules to use the `node:` protocol."
44
+ }
45
+ ],
46
+ "dependency": [
47
+ {
48
+ "comment": "Updating dependency \"@rushstack/debug-certificate-manager\" to `1.6.0`"
49
+ },
50
+ {
51
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.16.0`"
52
+ },
53
+ {
54
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.1.0`"
55
+ },
56
+ {
57
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.19.0`"
58
+ },
59
+ {
60
+ "comment": "Updating dependency \"@rushstack/heft\" from `^1.0.0` to `1.1.0`"
61
+ }
62
+ ]
63
+ }
64
+ },
4
65
  {
5
66
  "version": "1.0.0",
6
67
  "tag": "@rushstack/heft-webpack5-plugin_v1.0.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Change Log - @rushstack/heft-webpack5-plugin
2
2
 
3
- This log was last generated on Tue, 30 Sep 2025 23:57:45 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 08 Oct 2025 00:13:28 GMT and should not be manually modified.
4
+
5
+ ## 1.2.0
6
+ Wed, 08 Oct 2025 00:13:28 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Allow infrastructure logs to be printed.
11
+ - Use project-level webpack dependency when it's installed.
12
+
13
+ ## 1.1.0
14
+ Fri, 03 Oct 2025 20:09:59 GMT
15
+
16
+ ### Minor changes
17
+
18
+ - Normalize import of builtin modules to use the `node:` protocol.
4
19
 
5
20
  ## 1.0.0
6
21
  Tue, 30 Sep 2025 23:57:45 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.14"
8
+ "packageVersion": "7.53.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Webpack5Plugin.d.ts","sourceRoot":"","sources":["../src/Webpack5Plugin.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,sBAAsB,EAE3B,KAAK,2BAA2B,EACjC,MAAM,UAAU,CAAC;AAIlB,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAOD;;GAEG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W,eAAe,CAAC,qBAAqB,CAAC;IACnF,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,gBAAgB,CAAyD;IACjF,OAAO,CAAC,qBAAqB,CAAoD;IACjF,OAAO,CAAC,8BAA8B,CAA4B;IAClE,OAAO,CAAC,uCAAuC,CAA2B;IAC1E,OAAO,CAAC,iBAAiB,CAA2C;IAEpE,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,OAAO,CAAe;IAE9B,IAAW,QAAQ,IAAI,sBAAsB,CAU5C;IAEM,KAAK,CACV,WAAW,EAAE,gBAAgB,EAC7B,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,GAAE,qBAA0B,GAClC,IAAI;YAwBO,6BAA6B;YAsC7B,iBAAiB;YAoBjB,wBAAwB;YAexB,gBAAgB;YAgDhB,qBAAqB;IAoMnC,OAAO,CAAC,4BAA4B;IAYpC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,eAAe;CAmCxB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,2BAA2B,CAQlE"}
@@ -90,7 +90,7 @@ class Webpack5Plugin {
90
90
  heftConfiguration,
91
91
  hooks: this.accessor.hooks,
92
92
  serveMode: this._isServeMode,
93
- loadWebpackAsyncFn: this._loadWebpackAsync.bind(this)
93
+ loadWebpackAsyncFn: this._loadWebpackAsync.bind(this, taskSession, heftConfiguration)
94
94
  }, options);
95
95
  if (webpackConfiguration && requestRun) {
96
96
  const overrideWatchFSPlugin = new DeferredWatchFileSystem_1.OverrideNodeWatchFSPlugin(requestRun);
@@ -110,16 +110,23 @@ class Webpack5Plugin {
110
110
  }
111
111
  return this._webpackConfiguration;
112
112
  }
113
- async _loadWebpackAsync() {
113
+ async _loadWebpackAsync(taskSession, heftConfiguration) {
114
114
  if (!this._webpack) {
115
- // Allow this to fail if webpack is not installed
116
- this._webpack = await Promise.resolve(`${WEBPACK_PACKAGE_NAME}`).then(s => __importStar(require(s)));
115
+ try {
116
+ const webpackPackagePath = await heftConfiguration.rigPackageResolver.resolvePackageAsync(WEBPACK_PACKAGE_NAME, taskSession.logger.terminal);
117
+ this._webpack = await Promise.resolve(`${webpackPackagePath}`).then(s => __importStar(require(s)));
118
+ }
119
+ catch (e) {
120
+ // Fallback to bundled version if not found in rig.
121
+ this._webpack = await Promise.resolve(`${WEBPACK_PACKAGE_NAME}`).then(s => __importStar(require(s)));
122
+ taskSession.logger.terminal.writeDebugLine(`Using Webpack from built-in "${WEBPACK_PACKAGE_NAME}"`);
123
+ }
117
124
  }
118
125
  return this._webpack;
119
126
  }
120
- async _getWebpackCompilerAsync(taskSession, webpackConfiguration) {
127
+ async _getWebpackCompilerAsync(taskSession, heftConfiguration, webpackConfiguration) {
121
128
  if (!this._webpackCompiler) {
122
- const webpack = await this._loadWebpackAsync();
129
+ const webpack = await this._loadWebpackAsync(taskSession, heftConfiguration);
123
130
  taskSession.logger.terminal.writeLine(`Using Webpack version ${webpack.version}`);
124
131
  this._webpackCompiler = Array.isArray(webpackConfiguration)
125
132
  ? webpack.default(webpackConfiguration) /* (webpack.Compilation[]) => MultiCompiler */
@@ -138,7 +145,7 @@ class Webpack5Plugin {
138
145
  if (!webpackConfiguration) {
139
146
  return;
140
147
  }
141
- const compiler = await this._getWebpackCompilerAsync(taskSession, webpackConfiguration);
148
+ const compiler = await this._getWebpackCompilerAsync(taskSession, heftConfiguration, webpackConfiguration);
142
149
  taskSession.logger.terminal.writeLine('Running Webpack compilation');
143
150
  // Run the webpack compiler
144
151
  let stats;
@@ -177,7 +184,7 @@ class Webpack5Plugin {
177
184
  return;
178
185
  }
179
186
  // Get the compiler which will be used for both serve and watch mode
180
- const compiler = await this._getWebpackCompilerAsync(taskSession, webpackConfiguration);
187
+ const compiler = await this._getWebpackCompilerAsync(taskSession, heftConfiguration, webpackConfiguration);
181
188
  // Set up the hook to detect when the watcher completes the watcher compilation. We will also log out
182
189
  // errors from the compilation if present from the output stats object.
183
190
  this._webpackCompilationDonePromise = new Promise((resolve) => {
@@ -274,7 +281,6 @@ class Webpack5Plugin {
274
281
  taskSession.logger.emitError(error);
275
282
  }
276
283
  }
277
- return true;
278
284
  });
279
285
  // The webpack-dev-server package has a design flaw, where merely loading its package will set the
280
286
  // WEBPACK_DEV_SERVER environment variable -- even if no APIs are accessed. This environment variable
@@ -1 +1 @@
1
- {"version":3,"file":"Webpack5Plugin.js","sourceRoot":"","sources":["../src/Webpack5Plugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0e3D,oDAQC;AA5eD,qCAA4G;AAE5G,oFAA6F;AAC7F,oEAAwF;AAUxF,qCAKkB;AAClB,6EAAgF;AAChF,uEAAoG;AAMpG,MAAM,yBAAyB,GAAc,SAAS,CAAC;AACvD,MAAM,oBAAoB,GAAc,SAAS,CAAC;AAClD,MAAM,+BAA+B,GAAyB,oBAAoB,CAAC;AACnF,MAAM,+BAA+B,GAAyB,oBAAoB,CAAC;AACnF,MAAM,mCAAmC,GAA6B,wBAAwB,CAAC;AAE/F;;GAEG;AACH,MAAqB,cAAc;IAAnC;QAEU,iBAAY,GAAY,KAAK,CAAC;QAG9B,0BAAqB,GAA8C,KAAK,CAAC;QAKzE,cAAS,GAAY,EAAE,CAAC;QACxB,YAAO,GAAY,EAAE,CAAC;IAibhC,CAAC;IA/aC,IAAW,QAAQ;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG;gBACf,KAAK,EAAE,oBAAoB,EAAE;gBAC7B,UAAU,EAAE;oBACV,WAAW,EAAE,IAAI,CAAC,YAAY;iBAC/B;aACF,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,KAAK,CACV,WAA6B,EAC7B,i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AE,CAAC,CAAC;oBACzC,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;wBACtB,UAAU,GAAG,SAAS,CAAC;oBACzB,CAAC;gBACH,CAAC;gBACD,IAAI,cAAc,EAAE,CAAC;oBACnB,YAAY,GAAG,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;oBAC5C,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;wBACxB,YAAY,GAAG,SAAS,CAAC;oBAC3B,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,IAAI,6BAAS,CAAC,KAAK,CAAC,OAAO,EAAE;gBAClC,YAAY,EAAE,KAAK,CAAC,gBAAgB;gBACpC,aAAa,EAAE,eAAe;gBAC9B,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AA5bD,iCA4bC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO;QACL,mBAAmB,EAAE,IAAI,6BAAmB,EAAE;QAC9C,WAAW,EAAE,IAAI,yBAAe,CAAC,CAAC,sBAAsB,CAAC,CAAC;QAC1D,gBAAgB,EAAE,IAAI,2BAAiB,CAAC,CAAC,sBAAsB,CAAC,CAAC;QACjE,WAAW,EAAE,IAAI,2BAAiB,CAAC,CAAC,cAAc,CAAC,CAAC;QACpD,iBAAiB,EAAE,IAAI,kCAAwB,CAAC,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;KAC1F,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { AddressInfo } from 'net';\n\nimport type * as TWebpack from 'webpack';\nimport type TWebpackDevServer from 'webpack-dev-server';\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';\n\nimport { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager';\nimport { FileError, InternalError, LegacyAdapters } from '@rushstack/node-core-library';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IScopedLogger,\n IHeftTaskRunIncrementalHookOptions\n} from '@rushstack/heft';\n\nimport {\n type IWebpackConfiguration,\n type IWebpackPluginAccessor,\n PLUGIN_NAME,\n type IWebpackPluginAccessorHooks\n} from './shared';\nimport { tryLoadWebpackConfigurationAsync } from './WebpackConfigurationLoader';\nimport { type DeferredWatchFileSystem, OverrideNodeWatchFSPlugin } from './DeferredWatchFileSystem';\n\nexport interface IWebpackPluginOptions {\n devConfigurationPath?: string | undefined;\n configurationPath?: string | undefined;\n}\nconst SERVE_PARAMETER_LONG_NAME: '--serve' = '--serve';\nconst WEBPACK_PACKAGE_NAME: 'webpack' = 'webpack';\nconst WEBPACK_DEV_SERVER_PACKAGE_NAME: 'webpack-dev-server' = 'webpack-dev-server';\nconst WEBPACK_DEV_SERVER_ENV_VAR_NAME: 'WEBPACK_DEV_SERVER' = 'WEBPACK_DEV_SERVER';\nconst WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME: 'webpack-dev-middleware' = 'webpack-dev-middleware';\n\n/**\n * @internal\n */\nexport default class Webpack5Plugin implements IHeftTaskPlugin<IWebpackPluginOptions> {\n private _accessor: IWebpackPluginAccessor | undefined;\n private _isServeMode: boolean = false;\n private _webpack: typeof TWebpack | undefined;\n private _webpackCompiler: TWebpack.Compiler | TWebpack.MultiCompiler | undefined;\n private _webpackConfiguration: IWebpackConfiguration | undefined | false = false;\n private _webpackCompilationDonePromise: Promise<void> | undefined;\n private _webpackCompilationDonePromiseResolveFn: (() => void) | undefined;\n private _watchFileSystems: Set<DeferredWatchFileSystem> | undefined;\n\n private _warnings: Error[] = [];\n private _errors: Error[] = [];\n\n public get accessor(): IWebpackPluginAccessor {\n if (!this._accessor) {\n this._accessor = {\n hooks: _createAccessorHooks(),\n parameters: {\n isServeMode: this._isServeMode\n }\n };\n }\n return this._accessor;\n }\n\n public apply(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions = {}\n ): void {\n this._isServeMode = taskSession.parameters.getFlagParameter(SERVE_PARAMETER_LONG_NAME).value;\n if (this._isServeMode && !taskSession.parameters.watch) {\n throw new Error(\n `The ${JSON.stringify(\n SERVE_PARAMETER_LONG_NAME\n )} parameter is only available when running in watch mode.` +\n ` Try replacing \"${taskSession.parsedCommandLine?.unaliasedCommandName}\" with` +\n ` \"${taskSession.parsedCommandLine?.unaliasedCommandName}-watch\" in your Heft command line.`\n );\n }\n\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n await this._runWebpackAsync(taskSession, heftConfiguration, options);\n });\n\n taskSession.hooks.runIncremental.tapPromise(\n PLUGIN_NAME,\n async (runOptions: IHeftTaskRunIncrementalHookOptions) => {\n await this._runWebpackWatchAsync(taskSession, heftConfiguration, options, runOptions.requestRun);\n }\n );\n }\n\n private async _getWebpackConfigurationAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions,\n requestRun?: () => void\n ): Promise<IWebpackConfiguration | undefined> {\n if (this._webpackConfiguration === false) {\n const webpackConfiguration: IWebpackConfiguration | undefined = await tryLoadWebpackConfigurationAsync(\n {\n taskSession,\n heftConfiguration,\n hooks: this.accessor.hooks,\n serveMode: this._isServeMode,\n loadWebpackAsyncFn: this._loadWebpackAsync.bind(this)\n },\n options\n );\n\n if (webpackConfiguration && requestRun) {\n const overrideWatchFSPlugin: OverrideNodeWatchFSPlugin = new OverrideNodeWatchFSPlugin(requestRun);\n this._watchFileSystems = overrideWatchFSPlugin.fileSystems;\n for (const config of Array.isArray(webpackConfiguration)\n ? webpackConfiguration\n : [webpackConfiguration]) {\n if (!config.plugins) {\n config.plugins = [overrideWatchFSPlugin];\n } else {\n config.plugins.unshift(overrideWatchFSPlugin);\n }\n }\n }\n\n this._webpackConfiguration = webpackConfiguration;\n }\n\n return this._webpackConfiguration;\n }\n\n private async _loadWebpackAsync(): Promise<typeof TWebpack> {\n if (!this._webpack) {\n // Allow this to fail if webpack is not installed\n this._webpack = await import(WEBPACK_PACKAGE_NAME);\n }\n return this._webpack!;\n }\n\n private async _getWebpackCompilerAsync(\n taskSession: IHeftTaskSession,\n webpackConfiguration: IWebpackConfiguration\n ): Promise<TWebpack.Compiler | TWebpack.MultiCompiler> {\n if (!this._webpackCompiler) {\n const webpack: typeof TWebpack = await this._loadWebpackAsync();\n taskSession.logger.terminal.writeLine(`Using Webpack version ${webpack.version}`);\n this._webpackCompiler = Array.isArray(webpackConfiguration)\n ? webpack.default(webpackConfiguration) /* (webpack.Compilation[]) => MultiCompiler */\n : webpack.default(webpackConfiguration); /* (webpack.Compilation) => Compiler */\n }\n return this._webpackCompiler;\n }\n\n private async _runWebpackAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions\n ): Promise<void> {\n this._validateEnvironmentVariable(taskSession);\n if (taskSession.parameters.watch || this._isServeMode) {\n // Should never happen, but just in case\n throw new InternalError('Cannot run Webpack in compilation mode when watch mode is enabled');\n }\n\n // Load the config and compiler, and return if there is no config found\n const webpackConfiguration: IWebpackConfiguration | undefined = await this._getWebpackConfigurationAsync(\n taskSession,\n heftConfiguration,\n options\n );\n if (!webpackConfiguration) {\n return;\n }\n const compiler: TWebpack.Compiler | TWebpack.MultiCompiler = await this._getWebpackCompilerAsync(\n taskSession,\n webpackConfiguration\n );\n taskSession.logger.terminal.writeLine('Running Webpack compilation');\n\n // Run the webpack compiler\n let stats: TWebpack.Stats | TWebpack.MultiStats | undefined;\n try {\n stats = await LegacyAdapters.convertCallbackToPromise(\n (compiler as TWebpack.Compiler).run.bind(compiler)\n );\n await LegacyAdapters.convertCallbackToPromise(compiler.close.bind(compiler));\n } catch (e) {\n taskSession.logger.emitError(e as Error);\n }\n\n // Emit the errors from the stats object, if present\n if (stats) {\n this._recordErrors(stats, heftConfiguration.buildFolderPath);\n this._emitErrors(taskSession.logger);\n if (this.accessor.hooks.onEmitStats.isUsed()) {\n await this.accessor.hooks.onEmitStats.promise(stats);\n }\n }\n }\n\n private async _runWebpackWatchAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions,\n requestRun: () => void\n ): Promise<void> {\n // Save a handle to the original promise, since the this-scoped promise will be replaced whenever\n // the compilation completes.\n let webpackCompilationDonePromise: Promise<void> | undefined = this._webpackCompilationDonePromise;\n\n let isInitial: boolean = false;\n\n if (!this._webpackCompiler) {\n isInitial = true;\n this._validateEnvironmentVariable(taskSession);\n if (!taskSession.parameters.watch) {\n // Should never happen, but just in case\n throw new InternalError('Cannot run Webpack in watch mode when compilation mode is enabled');\n }\n\n // Load the config and compiler, and return if there is no config found\n const webpackConfiguration: IWebpackConfiguration | undefined =\n await this._getWebpackConfigurationAsync(taskSession, heftConfiguration, options, requestRun);\n if (!webpackConfiguration) {\n return;\n }\n\n // Get the compiler which will be used for both serve and watch mode\n const compiler: TWebpack.Compiler | TWebpack.MultiCompiler = await this._getWebpackCompilerAsync(\n taskSession,\n webpackConfiguration\n );\n\n // Set up the hook to detect when the watcher completes the watcher compilation. We will also log out\n // errors from the compilation if present from the output stats object.\n this._webpackCompilationDonePromise = new Promise((resolve: () => void) => {\n this._webpackCompilationDonePromiseResolveFn = resolve;\n });\n webpackCompilationDonePromise = this._webpackCompilationDonePromise;\n compiler.hooks.done.tap(PLUGIN_NAME, (stats?: TWebpack.Stats | TWebpack.MultiStats) => {\n this._webpackCompilationDonePromiseResolveFn!();\n this._webpackCompilationDonePromise = new Promise((resolve: () => void) => {\n this._webpackCompilationDonePromiseResolveFn = resolve;\n });\n\n if (stats) {\n this._recordErrors(stats, heftConfiguration.buildFolderPath);\n }\n });\n\n // Determine how we will run the compiler. When serving, we will run the compiler\n // via the webpack-dev-server. Otherwise, we will run the compiler directly.\n if (this._isServeMode) {\n const defaultDevServerOptions: TWebpackDevServer.Configuration = {\n host: 'localhost',\n devMiddleware: {\n publicPath: '/',\n stats: {\n cached: false,\n cachedAssets: false,\n colors: heftConfiguration.terminalProvider.supportsColor\n }\n },\n client: {\n logging: 'info',\n webSocketURL: {\n port: 8080\n }\n },\n port: 8080,\n onListening: (server: TWebpackDevServer) => {\n const addressInfo: AddressInfo | string | undefined = server.server?.address() as AddressInfo;\n if (addressInfo) {\n const address: string =\n typeof addressInfo === 'string' ? addressInfo : `${addressInfo.address}:${addressInfo.port}`;\n taskSession.logger.terminal.writeLine(`Started Webpack Dev Server at https://${address}`);\n }\n }\n };\n\n // Obtain the devServerOptions from the webpack configuration, and combine with the default options\n let devServerOptions: TWebpackDevServer.Configuration;\n if (Array.isArray(webpackConfiguration)) {\n const filteredDevServerOptions: TWebpackDevServer.Configuration[] = webpackConfiguration\n .map((configuration) => configuration.devServer)\n .filter((devServer): devServer is TWebpackDevServer.Configuration => !!devServer);\n if (filteredDevServerOptions.length > 1) {\n taskSession.logger.emitWarning(\n new Error(`Detected multiple webpack devServer configurations, using the first one.`)\n );\n }\n devServerOptions = { ...defaultDevServerOptions, ...filteredDevServerOptions[0] };\n } else {\n devServerOptions = { ...defaultDevServerOptions, ...webpackConfiguration.devServer };\n }\n\n // Add the certificate and key to the devServerOptions if these fields don't already have values\n if (!devServerOptions.server) {\n const certificateManager: CertificateManager = new CertificateManager();\n const certificate: ICertificate = await certificateManager.ensureCertificateAsync(\n true,\n taskSession.logger.terminal\n );\n\n // Update the web socket URL to use the hostname provided by the certificate\n const clientConfiguration: TWebpackDevServer.Configuration['client'] = devServerOptions.client;\n const hostname: string | undefined = certificate.subjectAltNames?.[0];\n if (hostname && typeof clientConfiguration === 'object') {\n const { webSocketURL } = clientConfiguration;\n if (typeof webSocketURL === 'object') {\n clientConfiguration.webSocketURL = {\n ...webSocketURL,\n hostname\n };\n }\n }\n\n devServerOptions = {\n ...devServerOptions,\n server: {\n type: 'https',\n options: {\n minVersion: 'TLSv1.3',\n key: certificate.pemKey,\n cert: certificate.pemCertificate,\n ca: certificate.pemCaCertificate\n }\n }\n };\n }\n\n // Since the webpack-dev-server does not return infrastructure errors via a callback like\n // compiler.watch(...), we will need to intercept them and log them ourselves.\n compiler.hooks.infrastructureLog.tap(\n PLUGIN_NAME,\n (name: string, type: string, args: unknown[] | undefined) => {\n if (name === WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME && type === 'error') {\n const error: Error | undefined = args?.[0] as Error | undefined;\n if (error) {\n taskSession.logger.emitError(error);\n }\n }\n return true;\n }\n );\n\n // The webpack-dev-server package has a design flaw, where merely loading its package will set the\n // WEBPACK_DEV_SERVER environment variable -- even if no APIs are accessed. This environment variable\n // causes incorrect behavior if Heft is not running in serve mode. Thus, we need to be careful to call\n // require() only if Heft is in serve mode.\n taskSession.logger.terminal.writeLine('Starting webpack-dev-server');\n const WebpackDevServer: typeof TWebpackDevServer = (await import(WEBPACK_DEV_SERVER_PACKAGE_NAME))\n .default;\n const webpackDevServer: TWebpackDevServer = new WebpackDevServer(devServerOptions, compiler);\n await webpackDevServer.start();\n } else {\n // Create the watcher. Compilation will start immediately after invoking watch().\n taskSession.logger.terminal.writeLine('Starting Webpack watcher');\n\n const { onGetWatchOptions } = this.accessor.hooks;\n\n const watchOptions: Parameters<TWebpack.Compiler['watch']>[0] = onGetWatchOptions.isUsed()\n ? await onGetWatchOptions.promise({}, webpackConfiguration)\n : {};\n\n compiler.watch(watchOptions, (error?: Error | null) => {\n if (error) {\n taskSession.logger.emitError(error);\n }\n });\n }\n }\n\n let hasChanges: boolean = true;\n if (!isInitial && this._watchFileSystems) {\n hasChanges = false;\n for (const watchFileSystem of this._watchFileSystems) {\n hasChanges = watchFileSystem.flush() || hasChanges;\n }\n }\n\n // Resume the compilation, wait for the compilation to complete, then suspend the watchers until the\n // next iteration. Even if there are no changes, the promise should resolve since resuming from a\n // suspended state invalidates the state of the watcher.\n if (hasChanges) {\n taskSession.logger.terminal.writeLine('Running incremental Webpack compilation');\n await webpackCompilationDonePromise;\n } else {\n taskSession.logger.terminal.writeLine(\n 'Webpack has not detected changes. Listing previous diagnostics.'\n );\n }\n\n this._emitErrors(taskSession.logger);\n }\n\n private _validateEnvironmentVariable(taskSession: IHeftTaskSession): void {\n if (!this._isServeMode && process.env[WEBPACK_DEV_SERVER_ENV_VAR_NAME]) {\n taskSession.logger.emitWarning(\n new Error(\n `The \"${WEBPACK_DEV_SERVER_ENV_VAR_NAME}\" environment variable is set, ` +\n 'which will cause problems when webpack is not running in serve mode. ' +\n `(Did a dependency inadvertently load the \"${WEBPACK_DEV_SERVER_PACKAGE_NAME}\" package?)`\n )\n );\n }\n }\n\n private _emitErrors(logger: IScopedLogger): void {\n for (const warning of this._warnings) {\n logger.emitWarning(warning);\n }\n for (const error of this._errors) {\n logger.emitError(error);\n }\n }\n\n private _recordErrors(stats: TWebpack.Stats | TWebpack.MultiStats, buildFolderPath: string): void {\n const errors: Error[] = this._errors;\n const warnings: Error[] = this._warnings;\n\n errors.length = 0;\n warnings.length = 0;\n\n if (stats.hasErrors() || stats.hasWarnings()) {\n const serializedStats: TWebpack.StatsCompilation[] = [stats.toJson('errors-warnings')];\n\n for (const compilationStats of serializedStats) {\n if (compilationStats.warnings) {\n for (const warning of compilationStats.warnings) {\n warnings.push(this._normalizeError(buildFolderPath, warning));\n }\n }\n\n if (compilationStats.errors) {\n for (const error of compilationStats.errors) {\n errors.push(this._normalizeError(buildFolderPath, error));\n }\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\n }\n }\n\n private _normalizeError(buildFolderPath: string, error: TWebpack.StatsError): Error {\n if (error instanceof Error) {\n return error;\n } else if (error.moduleIdentifier) {\n let lineNumber: number | undefined;\n let columnNumber: number | undefined;\n if (error.loc) {\n // Format of \"<line>:<columnStart>-<columnEnd>\"\n // https://webpack.js.org/api/stats/#errors-and-warnings\n const [lineNumberRaw, columnRangeRaw] = error.loc.split(':');\n const [startColumnRaw] = columnRangeRaw.split('-');\n if (lineNumberRaw) {\n lineNumber = parseInt(lineNumberRaw, 10);\n if (isNaN(lineNumber)) {\n lineNumber = undefined;\n }\n }\n if (startColumnRaw) {\n columnNumber = parseInt(startColumnRaw, 10);\n if (isNaN(columnNumber)) {\n columnNumber = undefined;\n }\n }\n }\n\n return new FileError(error.message, {\n absolutePath: error.moduleIdentifier,\n projectFolder: buildFolderPath,\n line: lineNumber,\n column: columnNumber\n });\n } else {\n return new Error(error.message);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function _createAccessorHooks(): IWebpackPluginAccessorHooks {\n return {\n onLoadConfiguration: new AsyncSeriesBailHook(),\n onConfigure: new AsyncSeriesHook(['webpackConfiguration']),\n onAfterConfigure: new AsyncParallelHook(['webpackConfiguration']),\n onEmitStats: new AsyncParallelHook(['webpackStats']),\n onGetWatchOptions: new AsyncSeriesWaterfallHook(['watchOptions', 'webpackConfiguration'])\n };\n}\n"]}
1
+ {"version":3,"file":"Webpack5Plugin.js","sourceRoot":"","sources":["../src/Webpack5Plugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwf3D,oDAQC;AA1fD,qCAA4G;AAE5G,oFAA6F;AAC7F,oEAAwF;AAUxF,qCAKkB;AAClB,6EAAgF;AAChF,uEAAoG;AAMpG,MAAM,yBAAyB,GAAc,SAAS,CAAC;AACvD,MAAM,oBAAoB,GAAc,SAAS,CAAC;AAClD,MAAM,+BAA+B,GAAyB,oBAAoB,CAAC;AACnF,MAAM,+BAA+B,GAAyB,oBAAoB,CAAC;AACnF,MAAM,mCAAmC,GAA6B,wBAAwB,CAAC;AAE/F;;GAEG;AACH,MAAqB,cAAc;IAAnC;QAEU,iBAAY,GAAY,KAAK,CAAC;QAG9B,0BAAq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C,OAAO,EAAE;gBAClC,YAAY,EAAE,KAAK,CAAC,gBAAgB;gBACpC,aAAa,EAAE,eAAe;gBAC9B,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AA1cD,iCA0cC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO;QACL,mBAAmB,EAAE,IAAI,6BAAmB,EAAE;QAC9C,WAAW,EAAE,IAAI,yBAAe,CAAC,CAAC,sBAAsB,CAAC,CAAC;QAC1D,gBAAgB,EAAE,IAAI,2BAAiB,CAAC,CAAC,sBAAsB,CAAC,CAAC;QACjE,WAAW,EAAE,IAAI,2BAAiB,CAAC,CAAC,cAAc,CAAC,CAAC;QACpD,iBAAiB,EAAE,IAAI,kCAAwB,CAAC,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;KAC1F,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { AddressInfo } from 'node:net';\n\nimport type * as TWebpack from 'webpack';\nimport type TWebpackDevServer from 'webpack-dev-server';\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';\n\nimport { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager';\nimport { FileError, InternalError, LegacyAdapters } from '@rushstack/node-core-library';\nimport type {\n HeftConfiguration,\n IHeftTaskSession,\n IHeftTaskPlugin,\n IHeftTaskRunHookOptions,\n IScopedLogger,\n IHeftTaskRunIncrementalHookOptions\n} from '@rushstack/heft';\n\nimport {\n type IWebpackConfiguration,\n type IWebpackPluginAccessor,\n PLUGIN_NAME,\n type IWebpackPluginAccessorHooks\n} from './shared';\nimport { tryLoadWebpackConfigurationAsync } from './WebpackConfigurationLoader';\nimport { type DeferredWatchFileSystem, OverrideNodeWatchFSPlugin } from './DeferredWatchFileSystem';\n\nexport interface IWebpackPluginOptions {\n devConfigurationPath?: string | undefined;\n configurationPath?: string | undefined;\n}\nconst SERVE_PARAMETER_LONG_NAME: '--serve' = '--serve';\nconst WEBPACK_PACKAGE_NAME: 'webpack' = 'webpack';\nconst WEBPACK_DEV_SERVER_PACKAGE_NAME: 'webpack-dev-server' = 'webpack-dev-server';\nconst WEBPACK_DEV_SERVER_ENV_VAR_NAME: 'WEBPACK_DEV_SERVER' = 'WEBPACK_DEV_SERVER';\nconst WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME: 'webpack-dev-middleware' = 'webpack-dev-middleware';\n\n/**\n * @internal\n */\nexport default class Webpack5Plugin implements IHeftTaskPlugin<IWebpackPluginOptions> {\n private _accessor: IWebpackPluginAccessor | undefined;\n private _isServeMode: boolean = false;\n private _webpack: typeof TWebpack | undefined;\n private _webpackCompiler: TWebpack.Compiler | TWebpack.MultiCompiler | undefined;\n private _webpackConfiguration: IWebpackConfiguration | undefined | false = false;\n private _webpackCompilationDonePromise: Promise<void> | undefined;\n private _webpackCompilationDonePromiseResolveFn: (() => void) | undefined;\n private _watchFileSystems: Set<DeferredWatchFileSystem> | undefined;\n\n private _warnings: Error[] = [];\n private _errors: Error[] = [];\n\n public get accessor(): IWebpackPluginAccessor {\n if (!this._accessor) {\n this._accessor = {\n hooks: _createAccessorHooks(),\n parameters: {\n isServeMode: this._isServeMode\n }\n };\n }\n return this._accessor;\n }\n\n public apply(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions = {}\n ): void {\n this._isServeMode = taskSession.parameters.getFlagParameter(SERVE_PARAMETER_LONG_NAME).value;\n if (this._isServeMode && !taskSession.parameters.watch) {\n throw new Error(\n `The ${JSON.stringify(\n SERVE_PARAMETER_LONG_NAME\n )} parameter is only available when running in watch mode.` +\n ` Try replacing \"${taskSession.parsedCommandLine?.unaliasedCommandName}\" with` +\n ` \"${taskSession.parsedCommandLine?.unaliasedCommandName}-watch\" in your Heft command line.`\n );\n }\n\n taskSession.hooks.run.tapPromise(PLUGIN_NAME, async (runOptions: IHeftTaskRunHookOptions) => {\n await this._runWebpackAsync(taskSession, heftConfiguration, options);\n });\n\n taskSession.hooks.runIncremental.tapPromise(\n PLUGIN_NAME,\n async (runOptions: IHeftTaskRunIncrementalHookOptions) => {\n await this._runWebpackWatchAsync(taskSession, heftConfiguration, options, runOptions.requestRun);\n }\n );\n }\n\n private async _getWebpackConfigurationAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions,\n requestRun?: () => void\n ): Promise<IWebpackConfiguration | undefined> {\n if (this._webpackConfiguration === false) {\n const webpackConfiguration: IWebpackConfiguration | undefined = await tryLoadWebpackConfigurationAsync(\n {\n taskSession,\n heftConfiguration,\n hooks: this.accessor.hooks,\n serveMode: this._isServeMode,\n loadWebpackAsyncFn: this._loadWebpackAsync.bind(this, taskSession, heftConfiguration)\n },\n options\n );\n\n if (webpackConfiguration && requestRun) {\n const overrideWatchFSPlugin: OverrideNodeWatchFSPlugin = new OverrideNodeWatchFSPlugin(requestRun);\n this._watchFileSystems = overrideWatchFSPlugin.fileSystems;\n for (const config of Array.isArray(webpackConfiguration)\n ? webpackConfiguration\n : [webpackConfiguration]) {\n if (!config.plugins) {\n config.plugins = [overrideWatchFSPlugin];\n } else {\n config.plugins.unshift(overrideWatchFSPlugin);\n }\n }\n }\n\n this._webpackConfiguration = webpackConfiguration;\n }\n\n return this._webpackConfiguration;\n }\n\n private async _loadWebpackAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration\n ): Promise<typeof TWebpack> {\n if (!this._webpack) {\n try {\n const webpackPackagePath: string = await heftConfiguration.rigPackageResolver.resolvePackageAsync(\n WEBPACK_PACKAGE_NAME,\n taskSession.logger.terminal\n );\n this._webpack = await import(webpackPackagePath);\n } catch (e) {\n // Fallback to bundled version if not found in rig.\n this._webpack = await import(WEBPACK_PACKAGE_NAME);\n taskSession.logger.terminal.writeDebugLine(`Using Webpack from built-in \"${WEBPACK_PACKAGE_NAME}\"`);\n }\n }\n return this._webpack!;\n }\n\n private async _getWebpackCompilerAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n webpackConfiguration: IWebpackConfiguration\n ): Promise<TWebpack.Compiler | TWebpack.MultiCompiler> {\n if (!this._webpackCompiler) {\n const webpack: typeof TWebpack = await this._loadWebpackAsync(taskSession, heftConfiguration);\n taskSession.logger.terminal.writeLine(`Using Webpack version ${webpack.version}`);\n this._webpackCompiler = Array.isArray(webpackConfiguration)\n ? webpack.default(webpackConfiguration) /* (webpack.Compilation[]) => MultiCompiler */\n : webpack.default(webpackConfiguration); /* (webpack.Compilation) => Compiler */\n }\n return this._webpackCompiler;\n }\n\n private async _runWebpackAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions\n ): Promise<void> {\n this._validateEnvironmentVariable(taskSession);\n if (taskSession.parameters.watch || this._isServeMode) {\n // Should never happen, but just in case\n throw new InternalError('Cannot run Webpack in compilation mode when watch mode is enabled');\n }\n\n // Load the config and compiler, and return if there is no config found\n const webpackConfiguration: IWebpackConfiguration | undefined = await this._getWebpackConfigurationAsync(\n taskSession,\n heftConfiguration,\n options\n );\n if (!webpackConfiguration) {\n return;\n }\n const compiler: TWebpack.Compiler | TWebpack.MultiCompiler = await this._getWebpackCompilerAsync(\n taskSession,\n heftConfiguration,\n webpackConfiguration\n );\n taskSession.logger.terminal.writeLine('Running Webpack compilation');\n\n // Run the webpack compiler\n let stats: TWebpack.Stats | TWebpack.MultiStats | undefined;\n try {\n stats = await LegacyAdapters.convertCallbackToPromise(\n (compiler as TWebpack.Compiler).run.bind(compiler)\n );\n await LegacyAdapters.convertCallbackToPromise(compiler.close.bind(compiler));\n } catch (e) {\n taskSession.logger.emitError(e as Error);\n }\n\n // Emit the errors from the stats object, if present\n if (stats) {\n this._recordErrors(stats, heftConfiguration.buildFolderPath);\n this._emitErrors(taskSession.logger);\n if (this.accessor.hooks.onEmitStats.isUsed()) {\n await this.accessor.hooks.onEmitStats.promise(stats);\n }\n }\n }\n\n private async _runWebpackWatchAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions,\n requestRun: () => void\n ): Promise<void> {\n // Save a handle to the original promise, since the this-scoped promise will be replaced whenever\n // the compilation completes.\n let webpackCompilationDonePromise: Promise<void> | undefined = this._webpackCompilationDonePromise;\n\n let isInitial: boolean = false;\n\n if (!this._webpackCompiler) {\n isInitial = true;\n this._validateEnvironmentVariable(taskSession);\n if (!taskSession.parameters.watch) {\n // Should never happen, but just in case\n throw new InternalError('Cannot run Webpack in watch mode when compilation mode is enabled');\n }\n\n // Load the config and compiler, and return if there is no config found\n const webpackConfiguration: IWebpackConfiguration | undefined =\n await this._getWebpackConfigurationAsync(taskSession, heftConfiguration, options, requestRun);\n if (!webpackConfiguration) {\n return;\n }\n\n // Get the compiler which will be used for both serve and watch mode\n const compiler: TWebpack.Compiler | TWebpack.MultiCompiler = await this._getWebpackCompilerAsync(\n taskSession,\n heftConfiguration,\n webpackConfiguration\n );\n\n // Set up the hook to detect when the watcher completes the watcher compilation. We will also log out\n // errors from the compilation if present from the output stats object.\n this._webpackCompilationDonePromise = new Promise((resolve: () => void) => {\n this._webpackCompilationDonePromiseResolveFn = resolve;\n });\n webpackCompilationDonePromise = this._webpackCompilationDonePromise;\n compiler.hooks.done.tap(PLUGIN_NAME, (stats?: TWebpack.Stats | TWebpack.MultiStats) => {\n this._webpackCompilationDonePromiseResolveFn!();\n this._webpackCompilationDonePromise = new Promise((resolve: () => void) => {\n this._webpackCompilationDonePromiseResolveFn = resolve;\n });\n\n if (stats) {\n this._recordErrors(stats, heftConfiguration.buildFolderPath);\n }\n });\n\n // Determine how we will run the compiler. When serving, we will run the compiler\n // via the webpack-dev-server. Otherwise, we will run the compiler directly.\n if (this._isServeMode) {\n const defaultDevServerOptions: TWebpackDevServer.Configuration = {\n host: 'localhost',\n devMiddleware: {\n publicPath: '/',\n stats: {\n cached: false,\n cachedAssets: false,\n colors: heftConfiguration.terminalProvider.supportsColor\n }\n },\n client: {\n logging: 'info',\n webSocketURL: {\n port: 8080\n }\n },\n port: 8080,\n onListening: (server: TWebpackDevServer) => {\n const addressInfo: AddressInfo | string | undefined = server.server?.address() as AddressInfo;\n if (addressInfo) {\n const address: string =\n typeof addressInfo === 'string' ? addressInfo : `${addressInfo.address}:${addressInfo.port}`;\n taskSession.logger.terminal.writeLine(`Started Webpack Dev Server at https://${address}`);\n }\n }\n };\n\n // Obtain the devServerOptions from the webpack configuration, and combine with the default options\n let devServerOptions: TWebpackDevServer.Configuration;\n if (Array.isArray(webpackConfiguration)) {\n const filteredDevServerOptions: TWebpackDevServer.Configuration[] = webpackConfiguration\n .map((configuration) => configuration.devServer)\n .filter((devServer): devServer is TWebpackDevServer.Configuration => !!devServer);\n if (filteredDevServerOptions.length > 1) {\n taskSession.logger.emitWarning(\n new Error(`Detected multiple webpack devServer configurations, using the first one.`)\n );\n }\n devServerOptions = { ...defaultDevServerOptions, ...filteredDevServerOptions[0] };\n } else {\n devServerOptions = { ...defaultDevServerOptions, ...webpackConfiguration.devServer };\n }\n\n // Add the certificate and key to the devServerOptions if these fields don't already have values\n if (!devServerOptions.server) {\n const certificateManager: CertificateManager = new CertificateManager();\n const certificate: ICertificate = await certificateManager.ensureCertificateAsync(\n true,\n taskSession.logger.terminal\n );\n\n // Update the web socket URL to use the hostname provided by the certificate\n const clientConfiguration: TWebpackDevServer.Configuration['client'] = devServerOptions.client;\n const hostname: string | undefined = certificate.subjectAltNames?.[0];\n if (hostname && typeof clientConfiguration === 'object') {\n const { webSocketURL } = clientConfiguration;\n if (typeof webSocketURL === 'object') {\n clientConfiguration.webSocketURL = {\n ...webSocketURL,\n hostname\n };\n }\n }\n\n devServerOptions = {\n ...devServerOptions,\n server: {\n type: 'https',\n options: {\n minVersion: 'TLSv1.3',\n key: certificate.pemKey,\n cert: certificate.pemCertificate,\n ca: certificate.pemCaCertificate\n }\n }\n };\n }\n\n // Since the webpack-dev-server does not return infrastructure errors via a callback like\n // compiler.watch(...), we will need to intercept them and log them ourselves.\n compiler.hooks.infrastructureLog.tap(\n PLUGIN_NAME,\n (name: string, type: string, args: unknown[] | undefined) => {\n if (name === WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME && type === 'error') {\n const error: Error | undefined = args?.[0] as Error | undefined;\n if (error) {\n taskSession.logger.emitError(error);\n }\n }\n }\n );\n\n // The webpack-dev-server package has a design flaw, where merely loading its package will set the\n // WEBPACK_DEV_SERVER environment variable -- even if no APIs are accessed. This environment variable\n // causes incorrect behavior if Heft is not running in serve mode. Thus, we need to be careful to call\n // require() only if Heft is in serve mode.\n taskSession.logger.terminal.writeLine('Starting webpack-dev-server');\n const WebpackDevServer: typeof TWebpackDevServer = (await import(WEBPACK_DEV_SERVER_PACKAGE_NAME))\n .default;\n const webpackDevServer: TWebpackDevServer = new WebpackDevServer(devServerOptions, compiler);\n await webpackDevServer.start();\n } else {\n // Create the watcher. Compilation will start immediately after invoking watch().\n taskSession.logger.terminal.writeLine('Starting Webpack watcher');\n\n const { onGetWatchOptions } = this.accessor.hooks;\n\n const watchOptions: Parameters<TWebpack.Compiler['watch']>[0] = onGetWatchOptions.isUsed()\n ? await onGetWatchOptions.promise({}, webpackConfiguration)\n : {};\n\n compiler.watch(watchOptions, (error?: Error | null) => {\n if (error) {\n taskSession.logger.emitError(error);\n }\n });\n }\n }\n\n let hasChanges: boolean = true;\n if (!isInitial && this._watchFileSystems) {\n hasChanges = false;\n for (const watchFileSystem of this._watchFileSystems) {\n hasChanges = watchFileSystem.flush() || hasChanges;\n }\n }\n\n // Resume the compilation, wait for the compilation to complete, then suspend the watchers until the\n // next iteration. Even if there are no changes, the promise should resolve since resuming from a\n // suspended state invalidates the state of the watcher.\n if (hasChanges) {\n taskSession.logger.terminal.writeLine('Running incremental Webpack compilation');\n await webpackCompilationDonePromise;\n } else {\n taskSession.logger.terminal.writeLine(\n 'Webpack has not detected changes. Listing previous diagnostics.'\n );\n }\n\n this._emitErrors(taskSession.logger);\n }\n\n private _validateEnvironmentVariable(taskSession: IHeftTaskSession): void {\n if (!this._isServeMode && process.env[WEBPACK_DEV_SERVER_ENV_VAR_NAME]) {\n taskSession.logger.emitWarning(\n new Error(\n `The \"${WEBPACK_DEV_SERVER_ENV_VAR_NAME}\" environment variable is set, ` +\n 'which will cause problems when webpack is not running in serve mode. ' +\n `(Did a dependency inadvertently load the \"${WEBPACK_DEV_SERVER_PACKAGE_NAME}\" package?)`\n )\n );\n }\n }\n\n private _emitErrors(logger: IScopedLogger): void {\n for (const warning of this._warnings) {\n logger.emitWarning(warning);\n }\n for (const error of this._errors) {\n logger.emitError(error);\n }\n }\n\n private _recordErrors(stats: TWebpack.Stats | TWebpack.MultiStats, buildFolderPath: string): void {\n const errors: Error[] = this._errors;\n const warnings: Error[] = this._warnings;\n\n errors.length = 0;\n warnings.length = 0;\n\n if (stats.hasErrors() || stats.hasWarnings()) {\n const serializedStats: TWebpack.StatsCompilation[] = [stats.toJson('errors-warnings')];\n\n for (const compilationStats of serializedStats) {\n if (compilationStats.warnings) {\n for (const warning of compilationStats.warnings) {\n warnings.push(this._normalizeError(buildFolderPath, warning));\n }\n }\n\n if (compilationStats.errors) {\n for (const error of compilationStats.errors) {\n errors.push(this._normalizeError(buildFolderPath, error));\n }\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\n }\n }\n\n private _normalizeError(buildFolderPath: string, error: TWebpack.StatsError): Error {\n if (error instanceof Error) {\n return error;\n } else if (error.moduleIdentifier) {\n let lineNumber: number | undefined;\n let columnNumber: number | undefined;\n if (error.loc) {\n // Format of \"<line>:<columnStart>-<columnEnd>\"\n // https://webpack.js.org/api/stats/#errors-and-warnings\n const [lineNumberRaw, columnRangeRaw] = error.loc.split(':');\n const [startColumnRaw] = columnRangeRaw.split('-');\n if (lineNumberRaw) {\n lineNumber = parseInt(lineNumberRaw, 10);\n if (isNaN(lineNumber)) {\n lineNumber = undefined;\n }\n }\n if (startColumnRaw) {\n columnNumber = parseInt(startColumnRaw, 10);\n if (isNaN(columnNumber)) {\n columnNumber = undefined;\n }\n }\n }\n\n return new FileError(error.message, {\n absolutePath: error.moduleIdentifier,\n projectFolder: buildFolderPath,\n line: lineNumber,\n column: columnNumber\n });\n } else {\n return new Error(error.message);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function _createAccessorHooks(): IWebpackPluginAccessorHooks {\n return {\n onLoadConfiguration: new AsyncSeriesBailHook(),\n onConfigure: new AsyncSeriesHook(['webpackConfiguration']),\n onAfterConfigure: new AsyncParallelHook(['webpackConfiguration']),\n onEmitStats: new AsyncParallelHook(['webpackStats']),\n onGetWatchOptions: new AsyncSeriesWaterfallHook(['watchOptions', 'webpackConfiguration'])\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WebpackConfigurationLoader.d.ts","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,QAAQ,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,EACvC,KAAK,2BAA2B,EACjC,MAAM,UAAU,CAAC;AAElB,KAAK,sBAAsB,GACvB,QAAQ,CAAC,aAAa,GACtB,QAAQ,CAAC,aAAa,EAAE,GACxB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,GAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,GACjC,CAAC,CAAC,GAAG,EAAE,kC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AAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAuD5C;AAED;;GAEG;AACH,wBAAsB,0CAA0C,CAC9D,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAgBvC"}
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.tryLoadWebpackConfigurationAsync = tryLoadWebpackConfigurationAsync;
39
39
  exports.tryLoadWebpackConfigurationFileAsync = tryLoadWebpackConfigurationFileAsync;
40
40
  exports._tryLoadWebpackConfigurationFileInnerAsync = _tryLoadWebpackConfigurationFileInnerAsync;
41
- const path = __importStar(require("path"));
41
+ const path = __importStar(require("node:path"));
42
42
  const node_core_library_1 = require("@rushstack/node-core-library");
43
43
  const shared_1 = require("./shared");
44
44
  const DEFAULT_WEBPACK_CONFIG_PATH = './webpack.config.js';
@@ -1 +1 @@
1
- {"version":3,"file":"WebpackConfigurationLoader.js","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C3D,4EAwDC;AAKD,oFA0DC;AAKD,gGAkBC;AAxLD,2CAA6B;AAE7B,oEAA0D;AAI1D,qCAMkB;AAwBlB,MAAM,2BAA2B,GAA0B,qBAAqB,CAAC;AACjF,MAAM,+BAA+B,GAA8B,yBAAyB,CAAC;AAE7F;;GAEG;AACI,KAAK,UAAU,gCAAgC,CACpD,OAAyC,EACzC,aAAoC;IAEpC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,GAAG,oCAAoC,EAAE,GAAG,OAAO,CAAC;IACvG,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;IAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,sFAAsF;IACtF,6BAA6B;IAC7B,KAAK,CAAC,mBAAmB,CAAC,UAAU,CAClC;QACE,IA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IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;YACxC,uEAAuE;YACvE,OAAO,aAAa,CAAC;gBACnB,IAAI,EAAE,UAAU;gBAChB,UAAU;gBACV,WAAW;gBACX,iBAAiB;gBACjB,OAAO,EAAE,MAAM,kBAAkB,EAAE;aACpC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,0CAA0C,CAC9D,iBAAyB;IAEzB,MAAM,YAAY,GAAY,MAAM,8BAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAC9E,IAAI,YAAY,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,OAAO,yBAAa,iBAAiB,uCAAC,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAA0B,CAA0B,CAAC;YAChE,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;gBAC1C,4CAA4C;gBAC5C,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,iBAAiB,MAAM,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport type * as TWebpack from 'webpack';\nimport { FileSystem } from '@rushstack/node-core-library';\nimport type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\nimport type { IWebpackPluginOptions } from './Webpack5Plugin';\nimport {\n PLUGIN_NAME,\n STAGE_LOAD_LOCAL_CONFIG,\n type IWebpackConfiguration,\n type IWebpackConfigurationFnEnvironment,\n type IWebpackPluginAccessorHooks\n} from './shared';\n\ntype IWebpackConfigJsExport =\n | TWebpack.Configuration\n | TWebpack.Configuration[]\n | Promise<TWebpack.Configuration>\n | Promise<TWebpack.Configuration[]>\n | ((env: IWebpackConfigurationFnEnvironment) => TWebpack.Configuration | TWebpack.Configuration[])\n | ((env: IWebpackConfigurationFnEnvironment) => Promise<TWebpack.Configuration | TWebpack.Configuration[]>);\ntype IWebpackConfigJs = IWebpackConfigJsExport | { default: IWebpackConfigJsExport };\n\n/**\n * @internal\n */\nexport interface ILoadWebpackConfigurationOptions {\n taskSession: IHeftTaskSession;\n heftConfiguration: HeftConfiguration;\n serveMode: boolean;\n loadWebpackAsyncFn: () => Promise<typeof TWebpack>;\n hooks: Pick<IWebpackPluginAccessorHooks, 'onLoadConfiguration' | 'onConfigure' | 'onAfterConfigure'>;\n\n _tryLoadConfigFileAsync?: typeof tryLoadWebpackConfigurationFileAsync;\n}\n\nconst DEFAULT_WEBPACK_CONFIG_PATH: './webpack.config.js' = './webpack.config.js';\nconst DEFAULT_WEBPACK_DEV_CONFIG_PATH: './webpack.dev.config.js' = './webpack.dev.config.js';\n\n/**\n * @internal\n */\nexport async function tryLoadWebpackConfigurationAsync(\n options: ILoadWebpackConfigurationOptions,\n pluginOptions: IWebpackPluginOptions\n): Promise<IWebpackConfiguration | undefined> {\n const { taskSession, hooks, _tryLoadConfigFileAsync = tryLoadWebpackConfigurationFileAsync } = options;\n const { logger } = taskSession;\n const { terminal } = logger;\n\n // Apply default behavior. Due to the state of `this._webpackConfiguration`, this code\n // will execute exactly once.\n hooks.onLoadConfiguration.tapPromise(\n {\n name: PLUGIN_NAME,\n stage: STAGE_LOAD_LOCAL_CONFIG\n },\n async () => {\n terminal.writeVerboseLine(`Attempting to load Webpack configuration from local file`);\n const webpackConfiguration: IWebpackConfiguration | undefined = await _tryLoadConfigFileAsync(\n options,\n pluginOptions\n );\n\n if (webpackConfiguration) {\n terminal.writeVerboseLine(`Loaded Webpack configuration from local file.`);\n }\n\n return webpackConfiguration;\n }\n );\n\n // Obtain the webpack configuration by calling into the hook.\n // The local configuration is loaded at STAGE_LOAD_LOCAL_CONFIG\n terminal.writeVerboseLine('Attempting to load Webpack configuration');\n let webpackConfiguration: IWebpackConfiguration | false | undefined =\n await hooks.onLoadConfiguration.promise();\n\n if (webpackConfiguration === false) {\n terminal.writeLine('Webpack disabled by external plugin');\n webpackConfiguration = undefined;\n } else if (\n webpackConfiguration === undefined ||\n (Array.isArray(webpackConfiguration) && webpackConfiguration.length === 0)\n ) {\n terminal.writeLine('No Webpack configuration found');\n webpackConfiguration = undefined;\n } else {\n if (hooks.onConfigure.isUsed()) {\n // Allow for plugins to customise the configuration\n await hooks.onConfigure.promise(webpackConfiguration);\n }\n if (hooks.onAfterConfigure.isUsed()) {\n // Provide the finalized configuration\n await hooks.onAfterConfigure.promise(webpackConfiguration);\n }\n }\n return webpackConfiguration;\n}\n\n/**\n * @internal\n */\nexport async function tryLoadWebpackConfigurationFileAsync(\n options: ILoadWebpackConfigurationOptions,\n pluginOptions: IWebpackPluginOptions\n): Promise<IWebpackConfiguration | undefined> {\n // TODO: Eventually replace this custom logic with a call to this utility in in webpack-cli:\n // https://github.com/webpack/webpack-cli/blob/next/packages/webpack-cli/lib/groups/ConfigGroup.js\n\n const { taskSession, heftConfiguration, loadWebpackAsyncFn, serveMode } = options;\n const {\n logger,\n parameters: { production }\n } = taskSession;\n const { terminal } = logger;\n const { configurationPath, devConfigurationPath } = pluginOptions;\n let webpackConfigJs: IWebpackConfigJs | undefined;\n\n try {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n if (serveMode) {\n const devConfigPath: string = path.resolve(\n buildFolderPath,\n devConfigurationPath || DEFAULT_WEBPACK_DEV_CONFIG_PATH\n );\n terminal.writeVerboseLine(`Attempting to load webpack configuration from \"${devConfigPath}\".`);\n webpackConfigJs = await _tryLoadWebpackConfigurationFileInnerAsync(devConfigPath);\n }\n\n if (!webpackConfigJs) {\n const configPath: string = path.resolve(\n buildFolderPath,\n configurationPath || DEFAULT_WEBPACK_CONFIG_PATH\n );\n terminal.writeVerboseLine(`Attempting to load webpack configuration from \"${configPath}\".`);\n webpackConfigJs = await _tryLoadWebpackConfigurationFileInnerAsync(configPath);\n }\n } catch (error) {\n logger.emitError(error as Error);\n }\n\n if (webpackConfigJs) {\n const webpackConfig: IWebpackConfigJsExport =\n (webpackConfigJs as { default: IWebpackConfigJsExport }).default || webpackConfigJs;\n\n if (typeof webpackConfig === 'function') {\n // Defer loading of webpack until we know for sure that we will need it\n return webpackConfig({\n prod: production,\n production,\n taskSession,\n heftConfiguration,\n webpack: await loadWebpackAsyncFn()\n });\n } else {\n return webpackConfig;\n }\n } else {\n return undefined;\n }\n}\n\n/**\n * @internal\n */\nexport async function _tryLoadWebpackConfigurationFileInnerAsync(\n configurationPath: string\n): Promise<IWebpackConfigJs | undefined> {\n const configExists: boolean = await FileSystem.existsAsync(configurationPath);\n if (configExists) {\n try {\n return await import(configurationPath);\n } catch (e) {\n const error: NodeJS.ErrnoException = e as NodeJS.ErrnoException;\n if (error.code === 'ERR_MODULE_NOT_FOUND') {\n // No configuration found, return undefined.\n return undefined;\n }\n throw new Error(`Error loading webpack configuration at \"${configurationPath}\": ${e}`);\n }\n } else {\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"WebpackConfigurationLoader.js","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8C3D,4EAwDC;AAKD,oFA0DC;AAKD,gGAkBC;AA1LD,gDAAkC;AAIlC,oEAA0D;AAI1D,qCAMkB;AAwBlB,MAAM,2BAA2B,GAA0B,qBAAqB,CAAC;AACjF,MAAM,+BAA+B,GAA8B,yBAAyB,CAAC;AAE7F;;GAEG;AACI,KAAK,UAAU,gCAAgC,CACpD,OAAyC,EACzC,aAAoC;IAEpC,MAAM,EAAE,WAAW,EAAE,KAAK,E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CAAC,UAAU,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,SAAS,CAAC,KAAc,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,aAAa,GAChB,eAAuD,CAAC,OAAO,IAAI,eAAe,CAAC;QAEtF,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;YACxC,uEAAuE;YACvE,OAAO,aAAa,CAAC;gBACnB,IAAI,EAAE,UAAU;gBAChB,UAAU;gBACV,WAAW;gBACX,iBAAiB;gBACjB,OAAO,EAAE,MAAM,kBAAkB,EAAE;aACpC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,0CAA0C,CAC9D,iBAAyB;IAEzB,MAAM,YAAY,GAAY,MAAM,8BAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAC9E,IAAI,YAAY,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,OAAO,yBAAa,iBAAiB,uCAAC,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAA0B,CAA0B,CAAC;YAChE,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;gBAC1C,4CAA4C;gBAC5C,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,iBAAiB,MAAM,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport type * as TWebpack from 'webpack';\n\nimport { FileSystem } from '@rushstack/node-core-library';\nimport type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\nimport type { IWebpackPluginOptions } from './Webpack5Plugin';\nimport {\n PLUGIN_NAME,\n STAGE_LOAD_LOCAL_CONFIG,\n type IWebpackConfiguration,\n type IWebpackConfigurationFnEnvironment,\n type IWebpackPluginAccessorHooks\n} from './shared';\n\ntype IWebpackConfigJsExport =\n | TWebpack.Configuration\n | TWebpack.Configuration[]\n | Promise<TWebpack.Configuration>\n | Promise<TWebpack.Configuration[]>\n | ((env: IWebpackConfigurationFnEnvironment) => TWebpack.Configuration | TWebpack.Configuration[])\n | ((env: IWebpackConfigurationFnEnvironment) => Promise<TWebpack.Configuration | TWebpack.Configuration[]>);\ntype IWebpackConfigJs = IWebpackConfigJsExport | { default: IWebpackConfigJsExport };\n\n/**\n * @internal\n */\nexport interface ILoadWebpackConfigurationOptions {\n taskSession: IHeftTaskSession;\n heftConfiguration: HeftConfiguration;\n serveMode: boolean;\n loadWebpackAsyncFn: () => Promise<typeof TWebpack>;\n hooks: Pick<IWebpackPluginAccessorHooks, 'onLoadConfiguration' | 'onConfigure' | 'onAfterConfigure'>;\n\n _tryLoadConfigFileAsync?: typeof tryLoadWebpackConfigurationFileAsync;\n}\n\nconst DEFAULT_WEBPACK_CONFIG_PATH: './webpack.config.js' = './webpack.config.js';\nconst DEFAULT_WEBPACK_DEV_CONFIG_PATH: './webpack.dev.config.js' = './webpack.dev.config.js';\n\n/**\n * @internal\n */\nexport async function tryLoadWebpackConfigurationAsync(\n options: ILoadWebpackConfigurationOptions,\n pluginOptions: IWebpackPluginOptions\n): Promise<IWebpackConfiguration | undefined> {\n const { taskSession, hooks, _tryLoadConfigFileAsync = tryLoadWebpackConfigurationFileAsync } = options;\n const { logger } = taskSession;\n const { terminal } = logger;\n\n // Apply default behavior. Due to the state of `this._webpackConfiguration`, this code\n // will execute exactly once.\n hooks.onLoadConfiguration.tapPromise(\n {\n name: PLUGIN_NAME,\n stage: STAGE_LOAD_LOCAL_CONFIG\n },\n async () => {\n terminal.writeVerboseLine(`Attempting to load Webpack configuration from local file`);\n const webpackConfiguration: IWebpackConfiguration | undefined = await _tryLoadConfigFileAsync(\n options,\n pluginOptions\n );\n\n if (webpackConfiguration) {\n terminal.writeVerboseLine(`Loaded Webpack configuration from local file.`);\n }\n\n return webpackConfiguration;\n }\n );\n\n // Obtain the webpack configuration by calling into the hook.\n // The local configuration is loaded at STAGE_LOAD_LOCAL_CONFIG\n terminal.writeVerboseLine('Attempting to load Webpack configuration');\n let webpackConfiguration: IWebpackConfiguration | false | undefined =\n await hooks.onLoadConfiguration.promise();\n\n if (webpackConfiguration === false) {\n terminal.writeLine('Webpack disabled by external plugin');\n webpackConfiguration = undefined;\n } else if (\n webpackConfiguration === undefined ||\n (Array.isArray(webpackConfiguration) && webpackConfiguration.length === 0)\n ) {\n terminal.writeLine('No Webpack configuration found');\n webpackConfiguration = undefined;\n } else {\n if (hooks.onConfigure.isUsed()) {\n // Allow for plugins to customise the configuration\n await hooks.onConfigure.promise(webpackConfiguration);\n }\n if (hooks.onAfterConfigure.isUsed()) {\n // Provide the finalized configuration\n await hooks.onAfterConfigure.promise(webpackConfiguration);\n }\n }\n return webpackConfiguration;\n}\n\n/**\n * @internal\n */\nexport async function tryLoadWebpackConfigurationFileAsync(\n options: ILoadWebpackConfigurationOptions,\n pluginOptions: IWebpackPluginOptions\n): Promise<IWebpackConfiguration | undefined> {\n // TODO: Eventually replace this custom logic with a call to this utility in in webpack-cli:\n // https://github.com/webpack/webpack-cli/blob/next/packages/webpack-cli/lib/groups/ConfigGroup.js\n\n const { taskSession, heftConfiguration, loadWebpackAsyncFn, serveMode } = options;\n const {\n logger,\n parameters: { production }\n } = taskSession;\n const { terminal } = logger;\n const { configurationPath, devConfigurationPath } = pluginOptions;\n let webpackConfigJs: IWebpackConfigJs | undefined;\n\n try {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n if (serveMode) {\n const devConfigPath: string = path.resolve(\n buildFolderPath,\n devConfigurationPath || DEFAULT_WEBPACK_DEV_CONFIG_PATH\n );\n terminal.writeVerboseLine(`Attempting to load webpack configuration from \"${devConfigPath}\".`);\n webpackConfigJs = await _tryLoadWebpackConfigurationFileInnerAsync(devConfigPath);\n }\n\n if (!webpackConfigJs) {\n const configPath: string = path.resolve(\n buildFolderPath,\n configurationPath || DEFAULT_WEBPACK_CONFIG_PATH\n );\n terminal.writeVerboseLine(`Attempting to load webpack configuration from \"${configPath}\".`);\n webpackConfigJs = await _tryLoadWebpackConfigurationFileInnerAsync(configPath);\n }\n } catch (error) {\n logger.emitError(error as Error);\n }\n\n if (webpackConfigJs) {\n const webpackConfig: IWebpackConfigJsExport =\n (webpackConfigJs as { default: IWebpackConfigJsExport }).default || webpackConfigJs;\n\n if (typeof webpackConfig === 'function') {\n // Defer loading of webpack until we know for sure that we will need it\n return webpackConfig({\n prod: production,\n production,\n taskSession,\n heftConfiguration,\n webpack: await loadWebpackAsyncFn()\n });\n } else {\n return webpackConfig;\n }\n } else {\n return undefined;\n }\n}\n\n/**\n * @internal\n */\nexport async function _tryLoadWebpackConfigurationFileInnerAsync(\n configurationPath: string\n): Promise<IWebpackConfigJs | undefined> {\n const configExists: boolean = await FileSystem.existsAsync(configurationPath);\n if (configExists) {\n try {\n return await import(configurationPath);\n } catch (e) {\n const error: NodeJS.ErrnoException = e as NodeJS.ErrnoException;\n if (error.code === 'ERR_MODULE_NOT_FOUND') {\n // No configuration found, return undefined.\n return undefined;\n }\n throw new Error(`Error loading webpack configuration at \"${configurationPath}\": ${e}`);\n }\n } else {\n return undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,QAAQ,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,IAAI,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;A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
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA0H3D;;;;GAIG;AACU,QAAA,uBAAuB,GAAS,IAAI,CAAC;AAElD;;GAEG;AACU,QAAA,WAAW,GAAsB,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TWebpack from 'webpack';\nimport type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\nimport type {\n AsyncParallelHook,\n AsyncSeriesBailHook,\n AsyncSeriesHook,\n AsyncSeriesWaterfallHook\n} from 'tapable';\nimport type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\n/**\n * The environment passed into the Webpack configuration function. Loosely based\n * on the default Webpack environment options, specified here:\n * https://webpack.js.org/api/cli/#environment-options\n *\n * @public\n */\nexport interface IWebpackConfigurationFnEnvironment {\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.production.\n */\n prod: boolean;\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.prod.\n */\n production: boolean;\n\n // Non-standard environment options\n /**\n * The task session provided to the plugin.\n */\n taskSession: IHeftTaskSession;\n /**\n * The Heft configuration provided to the plugin.\n */\n heftConfiguration: HeftConfiguration;\n /**\n * The resolved Webpack package.\n */\n webpack: typeof TWebpack;\n}\n\n/**\n * @public\n */\nexport interface IWebpackConfigurationWithDevServer extends TWebpack.Configuration {\n devServer?: WebpackDevServerConfiguration;\n}\n\n/**\n * @public\n */\nexport type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[];\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessorHooks {\n /**\n * A hook that allows for loading custom configurations used by the Webpack\n * plugin. If a tap returns a value other than `undefined` before stage {@link STAGE_LOAD_LOCAL_CONFIG},\n * it will suppress loading from the webpack config file. To provide a fallback behavior in the\n * absence of a local config file, tap this hook with a `stage` value greater than {@link STAGE_LOAD_LOCAL_CONFIG}.\n *\n * @remarks\n * Tapable event handlers can return `false` instead of `undefined` to suppress\n * other handlers from creating a configuration object, and prevent webpack from running.\n */\n readonly onLoadConfiguration: AsyncSeriesBailHook<never, never, never, IWebpackConfiguration | false>;\n /**\n * A hook that allows for modification of the loaded configuration used by the Webpack\n * plugin. If no configuration was loaded, this hook will not be called.\n */\n readonly onConfigure: AsyncSeriesHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the finalized configuration that will be used by Webpack.\n * If no configuration was loaded, this hook will not be called.\n */\n readonly onAfterConfigure: AsyncParallelHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the stats output from Webpack. If no configuration is loaded,\n * this hook will not be called.\n */\n readonly onEmitStats: AsyncParallelHook<TWebpack.Stats | TWebpack.MultiStats, never, never>;\n /**\n * A hook that allows for customization of the file watcher options. If not running in watch mode, this hook will not be called.\n */\n readonly onGetWatchOptions: AsyncSeriesWaterfallHook<\n Parameters<TWebpack.Compiler['watch']>[0],\n Readonly<IWebpackConfiguration>,\n never\n >;\n}\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessorParameters {\n /**\n * Whether or not serve mode was enabled by passing the `--serve` flag.\n */\n readonly isServeMode: boolean;\n}\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessor {\n /**\n * Hooks that are called at various points in the Webpack plugin lifecycle.\n */\n readonly hooks: IWebpackPluginAccessorHooks;\n /**\n * Parameters that are provided by the Webpack plugin.\n */\n readonly parameters: IWebpackPluginAccessorParameters;\n}\n\n/**\n * The stage in the `onLoadConfiguration` hook at which the config will be loaded from the local\n * webpack config file.\n * @public\n */\nexport const STAGE_LOAD_LOCAL_CONFIG: 1000 = 1000;\n\n/**\n * @public\n */\nexport const PLUGIN_NAME: 'webpack5-plugin' = 'webpack5-plugin';\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA2H3D;;;;GAIG;AACU,QAAA,uBAAuB,GAAS,IAAI,CAAC;AAElD;;GAEG;AACU,QAAA,WAAW,GAAsB,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TWebpack from 'webpack';\nimport type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\nimport type {\n AsyncParallelHook,\n AsyncSeriesBailHook,\n AsyncSeriesHook,\n AsyncSeriesWaterfallHook\n} from 'tapable';\n\nimport type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\n/**\n * The environment passed into the Webpack configuration function. Loosely based\n * on the default Webpack environment options, specified here:\n * https://webpack.js.org/api/cli/#environment-options\n *\n * @public\n */\nexport interface IWebpackConfigurationFnEnvironment {\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.production.\n */\n prod: boolean;\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.prod.\n */\n production: boolean;\n\n // Non-standard environment options\n /**\n * The task session provided to the plugin.\n */\n taskSession: IHeftTaskSession;\n /**\n * The Heft configuration provided to the plugin.\n */\n heftConfiguration: HeftConfiguration;\n /**\n * The resolved Webpack package.\n */\n webpack: typeof TWebpack;\n}\n\n/**\n * @public\n */\nexport interface IWebpackConfigurationWithDevServer extends TWebpack.Configuration {\n devServer?: WebpackDevServerConfiguration;\n}\n\n/**\n * @public\n */\nexport type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[];\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessorHooks {\n /**\n * A hook that allows for loading custom configurations used by the Webpack\n * plugin. If a tap returns a value other than `undefined` before stage {@link STAGE_LOAD_LOCAL_CONFIG},\n * it will suppress loading from the webpack config file. To provide a fallback behavior in the\n * absence of a local config file, tap this hook with a `stage` value greater than {@link STAGE_LOAD_LOCAL_CONFIG}.\n *\n * @remarks\n * Tapable event handlers can return `false` instead of `undefined` to suppress\n * other handlers from creating a configuration object, and prevent webpack from running.\n */\n readonly onLoadConfiguration: AsyncSeriesBailHook<never, never, never, IWebpackConfiguration | false>;\n /**\n * A hook that allows for modification of the loaded configuration used by the Webpack\n * plugin. If no configuration was loaded, this hook will not be called.\n */\n readonly onConfigure: AsyncSeriesHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the finalized configuration that will be used by Webpack.\n * If no configuration was loaded, this hook will not be called.\n */\n readonly onAfterConfigure: AsyncParallelHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the stats output from Webpack. If no configuration is loaded,\n * this hook will not be called.\n */\n readonly onEmitStats: AsyncParallelHook<TWebpack.Stats | TWebpack.MultiStats, never, never>;\n /**\n * A hook that allows for customization of the file watcher options. If not running in watch mode, this hook will not be called.\n */\n readonly onGetWatchOptions: AsyncSeriesWaterfallHook<\n Parameters<TWebpack.Compiler['watch']>[0],\n Readonly<IWebpackConfiguration>,\n never\n >;\n}\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessorParameters {\n /**\n * Whether or not serve mode was enabled by passing the `--serve` flag.\n */\n readonly isServeMode: boolean;\n}\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessor {\n /**\n * Hooks that are called at various points in the Webpack plugin lifecycle.\n */\n readonly hooks: IWebpackPluginAccessorHooks;\n /**\n * Parameters that are provided by the Webpack plugin.\n */\n readonly parameters: IWebpackPluginAccessorParameters;\n}\n\n/**\n * The stage in the `onLoadConfiguration` hook at which the config will be loaded from the local\n * webpack config file.\n * @public\n */\nexport const STAGE_LOAD_LOCAL_CONFIG: 1000 = 1000;\n\n/**\n * @public\n */\nexport const PLUGIN_NAME: 'webpack5-plugin' = 'webpack5-plugin';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/heft-webpack5-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Heft plugin for Webpack 5",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "types": "dist/heft-webpack5-plugin.d.ts",
13
13
  "license": "MIT",
14
14
  "peerDependencies": {
15
- "@rushstack/heft": "^1.0.0",
15
+ "@rushstack/heft": "^1.1.1",
16
16
  "webpack": "^5.82.1"
17
17
  },
18
18
  "dependencies": {
@@ -20,16 +20,16 @@
20
20
  "tapable": "1.1.3",
21
21
  "watchpack": "2.4.0",
22
22
  "webpack-dev-server": "^5.1.0",
23
- "@rushstack/debug-certificate-manager": "1.5.9",
24
- "@rushstack/node-core-library": "5.15.1"
23
+ "@rushstack/debug-certificate-manager": "1.6.1",
24
+ "@rushstack/node-core-library": "5.17.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/watchpack": "2.4.0",
28
28
  "eslint": "~9.25.1",
29
29
  "webpack": "~5.98.0",
30
- "@rushstack/terminal": "0.18.0",
31
- "local-node-rig": "1.0.0",
32
- "@rushstack/heft": "1.0.0"
30
+ "@rushstack/heft": "1.1.1",
31
+ "@rushstack/terminal": "0.19.1",
32
+ "local-node-rig": "1.0.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "heft build --clean",