@rushstack/heft-webpack4-plugin 0.8.0 → 0.9.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/lib/Webpack4Plugin.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export default class Webpack4Plugin implements IHeftTaskPlugin<IWebpackPluginOpt
|
|
|
23
23
|
private _getWebpackConfigurationAsync;
|
|
24
24
|
private _loadWebpackAsync;
|
|
25
25
|
private _getWebpackCompilerAsync;
|
|
26
|
-
private _warnAboutNodeJsIncompatibility;
|
|
27
26
|
private _runWebpackAsync;
|
|
28
27
|
private _runWebpackWatchAsync;
|
|
29
28
|
private _validateEnvironmentVariable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Webpack4Plugin.d.ts","sourceRoot":"","sources":["../src/Webpack4Plugin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EACjC,MAAM,UAAU,CAAC;AAoClB,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAQD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,eAAe,CAAC,qBAAqB,CAAC;IACnF,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,gBAAgB,CAAuD;IAC/E,OAAO,CAAC,qBAAqB,CAAoD;IACjF,OAAO,CAAC,8BAA8B,CAA4B;IAClE,OAAO,CAAC,uCAAuC,CAA2B;IAC1E,OAAO,CAAC,iBAAiB,CAA2C;IAEpE,OAAO,CAAC,SAAS,CAAe;IACh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AgB;YA8ChB,qBAAqB;IA0LnC,OAAO,CAAC,4BAA4B;IAYpC,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;CAwBtB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,2BAA2B,CAOlE"}
|
package/lib/Webpack4Plugin.js
CHANGED
|
@@ -114,29 +114,7 @@ class Webpack4Plugin {
|
|
|
114
114
|
}
|
|
115
115
|
return this._webpackCompiler;
|
|
116
116
|
}
|
|
117
|
-
_warnAboutNodeJsIncompatibility(taskSession) {
|
|
118
|
-
var _a;
|
|
119
|
-
const versionMatch = /^([0-9]+)\./.exec(process.versions.node); // parse the SemVer MAJOR part
|
|
120
|
-
if (versionMatch) {
|
|
121
|
-
const nodejsMajorVersion = parseInt(versionMatch[1]);
|
|
122
|
-
if (nodejsMajorVersion > 16) {
|
|
123
|
-
// Match strings like this:
|
|
124
|
-
// "--max-old-space-size=4096 --openssl-legacy-provider"
|
|
125
|
-
// "--openssl-legacy-provider=true"
|
|
126
|
-
// Do not accidentally match strings like this:
|
|
127
|
-
// "--openssl-legacy-provider-unrelated"
|
|
128
|
-
// "---openssl-legacy-provider"
|
|
129
|
-
if (!/(^|[^a-z\-])--openssl-legacy-provider($|[^a-z\-])/.test((_a = process.env.NODE_OPTIONS) !== null && _a !== void 0 ? _a : '')) {
|
|
130
|
-
taskSession.logger.emitWarning(new Error(`Node.js ${nodejsMajorVersion} is incompatible with Webpack 4. To work around this problem, use the environment variable NODE_OPTIONS="--openssl-legacy-provider"`));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
taskSession.logger.emitWarning(new Error(`Unable to parse Node.js version "${process.versions.node}"`));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
117
|
async _runWebpackAsync(taskSession, heftConfiguration, options) {
|
|
139
|
-
this._warnAboutNodeJsIncompatibility(taskSession);
|
|
140
118
|
this._validateEnvironmentVariable(taskSession);
|
|
141
119
|
if (taskSession.parameters.watch || this._isServeMode) {
|
|
142
120
|
// Should never happen, but just in case
|
|
@@ -168,7 +146,6 @@ class Webpack4Plugin {
|
|
|
168
146
|
}
|
|
169
147
|
async _runWebpackWatchAsync(taskSession, heftConfiguration, options, requestRun) {
|
|
170
148
|
var _a;
|
|
171
|
-
this._warnAboutNodeJsIncompatibility(taskSession);
|
|
172
149
|
// Save a handle to the original promise, since the this-scoped promise will be replaced whenever
|
|
173
150
|
// the compilation completes.
|
|
174
151
|
let webpackCompilationDonePromise = this._webpackCompilationDonePromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Webpack4Plugin.js","sourceRoot":"","sources":["../src/Webpack4Plugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAK3D,qCAAqG;AACrG,oFAA6F;AAC7F,oEAA6E;AAU7E,qCAKkB;AAClB,6EAAgF;AAChF,uEAImC;AAmCnC,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;IAuZhC,CAAC;IArZC,IAAW,QAAQ;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG;gBACf,KAAK,EAAE,oBAAoB,EAAE;gBAC7B,UAAU,EAAE;oBACV,WAAW,EAAE,IAAI,CAAC,YAAY;iBAC/B;aACF,CAAC;SACH;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,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EAAE;oBACjE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;iBACtE;gBAED,IAAI,gBAAgB,CAAC,QAAQ,EAAE;oBAC7B,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,QAAQ,EAAE;wBAC7C,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;qBAC7B;iBACF;aACF;SACF;IACH,CAAC;CACF;AAlaD,iCAkaC;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;KACrD,CAAC;AACJ,CAAC;AAPD,oDAOC","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';\nimport type * as TWebpack from 'webpack';\nimport type TWebpackDevServer from 'webpack-dev-server';\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, type SyncBailHook } from 'tapable';\nimport { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager';\nimport { 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 PLUGIN_NAME,\n type IWebpackConfiguration,\n type IWebpackPluginAccessor,\n type IWebpackPluginAccessorHooks\n} from './shared';\nimport { tryLoadWebpackConfigurationAsync } from './WebpackConfigurationLoader';\nimport {\n DeferredWatchFileSystem,\n type IWatchFileSystem,\n OverrideNodeWatchFSPlugin\n} from './DeferredWatchFileSystem';\n\ntype ExtendedWatching = TWebpack.Watching & {\n resume: () => void;\n suspend: () => void;\n};\n\ntype ExtendedMultiWatching = TWebpack.MultiWatching & {\n resume: () => void;\n suspend: () => void;\n};\n\ntype ExtendedCompiler = TWebpack.Compiler & {\n hooks: TWebpack.Compiler['hooks'] & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n infrastructureLog: SyncBailHook<string, string, any[]>;\n };\n watching: ExtendedWatching;\n watchFileSystem: IWatchFileSystem;\n};\n\ntype ExtendedMultiCompiler = TWebpack.MultiCompiler & {\n compilers: ExtendedCompiler[];\n hooks: TWebpack.MultiCompiler['hooks'] & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n infrastructureLog: SyncBailHook<string, string, any[]>;\n };\n watching: ExtendedMultiWatching;\n};\n\nexport interface IWebpackPluginOptions {\n devConfigurationPath?: string | undefined;\n configurationPath?: string | undefined;\n}\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 Webpack4Plugin implements IHeftTaskPlugin<IWebpackPluginOptions> {\n private _accessor: IWebpackPluginAccessor | undefined;\n private _isServeMode: boolean = false;\n private _webpack: typeof TWebpack | undefined;\n private _webpackCompiler: ExtendedCompiler | ExtendedMultiCompiler | 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 (!taskSession.parameters.watch && this._isServeMode) {\n throw new Error(\n `The ${JSON.stringify(\n SERVE_PARAMETER_LONG_NAME\n )} parameter is only available when running in watch mode.`\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<ExtendedCompiler | ExtendedMultiCompiler> {\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(\n webpackConfiguration\n ) as ExtendedMultiCompiler) /* (webpack.Compilation[]) => MultiCompiler */\n : (webpack.default(webpackConfiguration) as ExtendedCompiler); /* (webpack.Compilation) => Compiler */\n }\n return this._webpackCompiler;\n }\n\n private _warnAboutNodeJsIncompatibility(taskSession: IHeftTaskSession): void {\n const versionMatch: RegExpExecArray | null = /^([0-9]+)\\./.exec(process.versions.node); // parse the SemVer MAJOR part\n if (versionMatch) {\n const nodejsMajorVersion: number = parseInt(versionMatch[1]);\n if (nodejsMajorVersion > 16) {\n // Match strings like this:\n // \"--max-old-space-size=4096 --openssl-legacy-provider\"\n // \"--openssl-legacy-provider=true\"\n // Do not accidentally match strings like this:\n // \"--openssl-legacy-provider-unrelated\"\n // \"---openssl-legacy-provider\"\n if (!/(^|[^a-z\\-])--openssl-legacy-provider($|[^a-z\\-])/.test(process.env.NODE_OPTIONS ?? '')) {\n taskSession.logger.emitWarning(\n new Error(\n `Node.js ${nodejsMajorVersion} is incompatible with Webpack 4. To work around this problem, use the environment variable NODE_OPTIONS=\"--openssl-legacy-provider\"`\n )\n );\n }\n }\n } else {\n taskSession.logger.emitWarning(new Error(`Unable to parse Node.js version \"${process.versions.node}\"`));\n }\n }\n\n private async _runWebpackAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions\n ): Promise<void> {\n this._warnAboutNodeJsIncompatibility(taskSession);\n\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: ExtendedCompiler | ExtendedMultiCompiler = 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 } 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);\n if (this.accessor.hooks.onEmitStats.isUsed()) {\n await this.accessor.hooks.onEmitStats.promise(stats);\n }\n this._emitErrors(taskSession.logger);\n }\n }\n\n private async _runWebpackWatchAsync(\n taskSession: IHeftTaskSession,\n heftConfiguration: HeftConfiguration,\n options: IWebpackPluginOptions,\n requestRun: () => void\n ): Promise<void> {\n this._warnAboutNodeJsIncompatibility(taskSession);\n\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: ExtendedCompiler | ExtendedMultiCompiler = 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 if (stats) {\n this._recordErrors(stats);\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n compiler.hooks.infrastructureLog.tap(PLUGIN_NAME, (name: string, type: string, args: any[]) => {\n if (name === WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME && type === 'error') {\n const error: Error | undefined = args[0];\n if (error) {\n taskSession.logger.emitError(error);\n }\n }\n return true;\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 compiler.watch({}, (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.compilation.MultiStats): void {\n this._errors.length = 0;\n this._warnings.length = 0;\n\n if (stats.hasErrors() || stats.hasWarnings()) {\n const serializedStats: TWebpack.Stats.ToJsonOutput[] = [stats.toJson('errors-warnings')];\n\n for (const compilationStats of serializedStats) {\n for (const warning of compilationStats.warnings as (string | Error)[]) {\n this._warnings.push(warning instanceof Error ? warning : new Error(warning));\n }\n\n for (const error of compilationStats.errors as (string | Error)[]) {\n this._errors.push(error instanceof Error ? error : new Error(error));\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\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 };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Webpack4Plugin.js","sourceRoot":"","sources":["../src/Webpack4Plugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAK3D,qCAAqG;AACrG,oFAA6F;AAC7F,oEAA6E;AAU7E,qCAKkB;AAClB,6EAAgF;AAChF,uEAImC;AAmCnC,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;IA2XhC,CAAC;IAzXC,IAAW,QAAQ;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC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C","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';\nimport type * as TWebpack from 'webpack';\nimport type TWebpackDevServer from 'webpack-dev-server';\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, type SyncBailHook } from 'tapable';\nimport { CertificateManager, type ICertificate } from '@rushstack/debug-certificate-manager';\nimport { 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 PLUGIN_NAME,\n type IWebpackConfiguration,\n type IWebpackPluginAccessor,\n type IWebpackPluginAccessorHooks\n} from './shared';\nimport { tryLoadWebpackConfigurationAsync } from './WebpackConfigurationLoader';\nimport {\n DeferredWatchFileSystem,\n type IWatchFileSystem,\n OverrideNodeWatchFSPlugin\n} from './DeferredWatchFileSystem';\n\ntype ExtendedWatching = TWebpack.Watching & {\n resume: () => void;\n suspend: () => void;\n};\n\ntype ExtendedMultiWatching = TWebpack.MultiWatching & {\n resume: () => void;\n suspend: () => void;\n};\n\ntype ExtendedCompiler = TWebpack.Compiler & {\n hooks: TWebpack.Compiler['hooks'] & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n infrastructureLog: SyncBailHook<string, string, any[]>;\n };\n watching: ExtendedWatching;\n watchFileSystem: IWatchFileSystem;\n};\n\ntype ExtendedMultiCompiler = TWebpack.MultiCompiler & {\n compilers: ExtendedCompiler[];\n hooks: TWebpack.MultiCompiler['hooks'] & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n infrastructureLog: SyncBailHook<string, string, any[]>;\n };\n watching: ExtendedMultiWatching;\n};\n\nexport interface IWebpackPluginOptions {\n devConfigurationPath?: string | undefined;\n configurationPath?: string | undefined;\n}\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 Webpack4Plugin implements IHeftTaskPlugin<IWebpackPluginOptions> {\n private _accessor: IWebpackPluginAccessor | undefined;\n private _isServeMode: boolean = false;\n private _webpack: typeof TWebpack | undefined;\n private _webpackCompiler: ExtendedCompiler | ExtendedMultiCompiler | 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 (!taskSession.parameters.watch && this._isServeMode) {\n throw new Error(\n `The ${JSON.stringify(\n SERVE_PARAMETER_LONG_NAME\n )} parameter is only available when running in watch mode.`\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<ExtendedCompiler | ExtendedMultiCompiler> {\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(\n webpackConfiguration\n ) as ExtendedMultiCompiler) /* (webpack.Compilation[]) => MultiCompiler */\n : (webpack.default(webpackConfiguration) as ExtendedCompiler); /* (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: ExtendedCompiler | ExtendedMultiCompiler = 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 } 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);\n if (this.accessor.hooks.onEmitStats.isUsed()) {\n await this.accessor.hooks.onEmitStats.promise(stats);\n }\n this._emitErrors(taskSession.logger);\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: ExtendedCompiler | ExtendedMultiCompiler = 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 if (stats) {\n this._recordErrors(stats);\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n compiler.hooks.infrastructureLog.tap(PLUGIN_NAME, (name: string, type: string, args: any[]) => {\n if (name === WEBPACK_DEV_MIDDLEWARE_PACKAGE_NAME && type === 'error') {\n const error: Error | undefined = args[0];\n if (error) {\n taskSession.logger.emitError(error);\n }\n }\n return true;\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 compiler.watch({}, (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.compilation.MultiStats): void {\n this._errors.length = 0;\n this._warnings.length = 0;\n\n if (stats.hasErrors() || stats.hasWarnings()) {\n const serializedStats: TWebpack.Stats.ToJsonOutput[] = [stats.toJson('errors-warnings')];\n\n for (const compilationStats of serializedStats) {\n for (const warning of compilationStats.warnings as (string | Error)[]) {\n this._warnings.push(warning instanceof Error ? warning : new Error(warning));\n }\n\n for (const error of compilationStats.errors as (string | Error)[]) {\n this._errors.push(error instanceof Error ? error : new Error(error));\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\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 };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-webpack4-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Heft plugin for Webpack 4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@rushstack/heft": "^0.58.2",
|
|
21
21
|
"@types/webpack": "^4",
|
|
22
|
-
"webpack": "~4.
|
|
22
|
+
"webpack": "~4.47.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@types/tapable": "1.0.6",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/node": "14.18.36",
|
|
34
34
|
"@types/watchpack": "2.4.0",
|
|
35
35
|
"@types/webpack": "4.41.32",
|
|
36
|
-
"webpack": "~4.
|
|
36
|
+
"webpack": "~4.47.0",
|
|
37
37
|
"@rushstack/eslint-config": "3.3.3",
|
|
38
38
|
"@rushstack/heft-node-rig": "2.2.22",
|
|
39
39
|
"@rushstack/heft": "0.58.2"
|