@rushstack/webpack-plugin-utilities 0.4.72 → 0.4.73

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,18 @@
1
1
  {
2
2
  "name": "@rushstack/webpack-plugin-utilities",
3
3
  "entries": [
4
+ {
5
+ "version": "0.4.73",
6
+ "tag": "@rushstack/webpack-plugin-utilities_v0.4.73",
7
+ "date": "Tue, 11 Mar 2025 00:11:25 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.69.3`"
12
+ }
13
+ ]
14
+ }
15
+ },
4
16
  {
5
17
  "version": "0.4.72",
6
18
  "tag": "@rushstack/webpack-plugin-utilities_v0.4.72",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @rushstack/webpack-plugin-utilities
2
2
 
3
- This log was last generated on Sat, 01 Mar 2025 05:00:09 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 11 Mar 2025 00:11:25 GMT and should not be manually modified.
4
+
5
+ ## 0.4.73
6
+ Tue, 11 Mar 2025 00:11:25 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.4.72
6
11
  Sat, 01 Mar 2025 05:00:09 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.51.0"
8
+ "packageVersion": "7.51.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -2,7 +2,9 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.isWebpack5 = exports.isWebpack4 = exports.isWebpack3OrEarlier = void 0;
5
+ exports.isWebpack3OrEarlier = isWebpack3OrEarlier;
6
+ exports.isWebpack4 = isWebpack4;
7
+ exports.isWebpack5 = isWebpack5;
6
8
  /**
7
9
  * We do not have quality API detection between webpack major versions 1-3.
8
10
  * We can detect the absence of hooks which was a version 3 feature.
@@ -12,7 +14,6 @@ exports.isWebpack5 = exports.isWebpack4 = exports.isWebpack3OrEarlier = void 0;
12
14
  function isWebpack3OrEarlier(compiler) {
13
15
  return !compiler.hooks;
14
16
  }
15
- exports.isWebpack3OrEarlier = isWebpack3OrEarlier;
16
17
  /**
17
18
  * Detects whether or not we are using webpack 4
18
19
  *
@@ -23,7 +24,6 @@ function isWebpack4(compiler) {
23
24
  const webpackVersion = (_a = compiler === null || compiler === void 0 ? void 0 : compiler.webpack) === null || _a === void 0 ? void 0 : _a.version;
24
25
  return !webpackVersion;
25
26
  }
26
- exports.isWebpack4 = isWebpack4;
27
27
  /**
28
28
  * Detects whether or not we are using webpack 5
29
29
  *
@@ -34,5 +34,4 @@ function isWebpack5(compiler) {
34
34
  const webpackVersion = (_a = compiler === null || compiler === void 0 ? void 0 : compiler.webpack) === null || _a === void 0 ? void 0 : _a.version;
35
35
  return !!webpackVersion;
36
36
  }
37
- exports.isWebpack5 = isWebpack5;
38
37
  //# sourceMappingURL=DetectWebpackVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DetectWebpackVersion.js","sourceRoot":"","sources":["../src/DetectWebpackVersion.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAW3D;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,QAA0B;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;AACzB,CAAC;AAuBQ,kDAAmB;AArB5B;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAA0B;;IAC5C,MAAM,cAAc,GAAuB,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,OAAO,CAAC;IACtE,OAAO,CAAC,cAAc,CAAC;AACzB,CAAC;AAa6B,gCAAU;AAXxC;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAA0B;;IAC5C,MAAM,cAAc,GAAuB,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,OAAO,CAAC;IAEtE,OAAO,CAAC,CAAC,cAAc,CAAC;AAC1B,CAAC;AAEyC,gCAAU","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * There is no `compiler.version` API available prior to webpack 5,\n * therefore we will have to make some inferences about which major version of webpack we are on.\n * Feature Request: https://github.com/webpack/webpack/issues/15679\n * @description\n */\n\nimport type * as Webpack from 'webpack';\n\n/**\n * We do not have quality API detection between webpack major versions 1-3.\n * We can detect the absence of hooks which was a version 3 feature.\n *\n * @public\n */\nfunction isWebpack3OrEarlier(compiler: Webpack.Compiler): boolean {\n return !compiler.hooks;\n}\n\n/**\n * Detects whether or not we are using webpack 4\n *\n * @public\n */\nfunction isWebpack4(compiler: Webpack.Compiler): boolean {\n const webpackVersion: string | undefined = compiler?.webpack?.version;\n return !webpackVersion;\n}\n\n/**\n * Detects whether or not we are using webpack 5\n *\n * @public\n */\nfunction isWebpack5(compiler: Webpack.Compiler): boolean {\n const webpackVersion: string | undefined = compiler?.webpack?.version;\n\n return !!webpackVersion;\n}\n\nexport { isWebpack3OrEarlier, isWebpack4, isWebpack5 };\n"]}
1
+ {"version":3,"file":"DetectWebpackVersion.js","sourceRoot":"","sources":["../src/DetectWebpackVersion.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AA0ClD,kDAAmB;AAAE,gCAAU;AAAE,gCAAU;AA/BpD;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,QAA0B;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAA0B;;IAC5C,MAAM,cAAc,GAAuB,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,OAAO,CAAC;IACtE,OAAO,CAAC,cAAc,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,QAA0B;;IAC5C,MAAM,cAAc,GAAuB,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,OAAO,CAAC;IAEtE,OAAO,CAAC,CAAC,cAAc,CAAC;AAC1B,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\n/**\n * There is no `compiler.version` API available prior to webpack 5,\n * therefore we will have to make some inferences about which major version of webpack we are on.\n * Feature Request: https://github.com/webpack/webpack/issues/15679\n * @description\n */\n\nimport type * as Webpack from 'webpack';\n\n/**\n * We do not have quality API detection between webpack major versions 1-3.\n * We can detect the absence of hooks which was a version 3 feature.\n *\n * @public\n */\nfunction isWebpack3OrEarlier(compiler: Webpack.Compiler): boolean {\n return !compiler.hooks;\n}\n\n/**\n * Detects whether or not we are using webpack 4\n *\n * @public\n */\nfunction isWebpack4(compiler: Webpack.Compiler): boolean {\n const webpackVersion: string | undefined = compiler?.webpack?.version;\n return !webpackVersion;\n}\n\n/**\n * Detects whether or not we are using webpack 5\n *\n * @public\n */\nfunction isWebpack5(compiler: Webpack.Compiler): boolean {\n const webpackVersion: string | undefined = compiler?.webpack?.version;\n\n return !!webpackVersion;\n}\n\nexport { isWebpack3OrEarlier, isWebpack4, isWebpack5 };\n"]}
package/lib/Testing.js CHANGED
@@ -17,18 +17,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  var __importDefault = (this && this.__importDefault) || function (mod) {
28
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
39
  };
30
40
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.getTestingWebpackCompilerAsync = void 0;
41
+ exports.getTestingWebpackCompilerAsync = getTestingWebpackCompilerAsync;
32
42
  const memfs_1 = require("memfs");
33
43
  const path_1 = __importDefault(require("path"));
34
44
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
@@ -111,7 +121,6 @@ async function getTestingWebpackCompilerAsync(entry, additionalConfig = {}, memF
111
121
  });
112
122
  });
113
123
  }
114
- exports.getTestingWebpackCompilerAsync = getTestingWebpackCompilerAsync;
115
124
  function _processAndHandleStatsErrorsAndWarnings(stats, reject) {
116
125
  if ((stats === null || stats === void 0 ? void 0 : stats.hasErrors()) || (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
117
126
  const serializedStats = [stats === null || stats === void 0 ? void 0 : stats.toJson('errors-warnings')];
@@ -1 +1 @@
1
- {"version":3,"file":"Testing.js","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,iCAA6D;AAC7D,gDAAwB;AAExB,kEAAyC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACI,KA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ent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { createFsFromVolume, Volume, type IFs } from 'memfs';\nimport path from 'path';\nimport type { StatsCompilation as WebpackStatsCompilation } from 'webpack';\nimport webpackMerge from 'webpack-merge';\n\nimport type { MultiStats, Stats, Configuration, Compiler, StatsError, OutputFileSystem } from 'webpack';\n\n/**\n * @public\n * This function generates a webpack compiler with default configuration and the output filesystem mapped to\n * a memory filesystem. This is useful for testing webpack plugins/loaders where we do not need to write to disk (which can be costly).\n * @param entry - The entry point for the webpack compiler\n * @param additionalConfig - Any additional configuration that should be merged with the default configuration\n * @param memFs - The memory filesystem to use for the output filesystem. Use this option if you want to _inspect_, analyze, or read the output\n * files generated by the webpack compiler. If you do not need to do this, you can omit this parameter and the output files.\n *\n * @returns - A webpack compiler with the output filesystem mapped to a memory filesystem\n *\n * @example\n * ```typescript\n * import Testing from '@rushstack/webpack-plugin-utilities';\n *\n * describe('MyPlugin', () => {\n * it('should run', async () => {\n * const stats = await Testing.getTestingWebpackCompiler(\n * `./src/index.ts`,\n * );\n *\n * expect(stats).toBeDefined();\n * });\n * });\n * ```\n *\n * @remarks\n * If you want to be able to read, analyze, access the files written to the memory filesystem,\n * you can pass in a memory filesystem instance to the `memFs` parameter.\n *\n * @example\n * ```typescript\n * import Testing from '@rushstack/webpack-plugin-utilities';\n * import { createFsFromVolume, Volume, IFs } from 'memfs';\n * import path from 'path';\n *\n * describe('MyPlugin', () => {\n * it('should run', async () => {\n * const virtualFileSystem: IFs = createFsFromVolume(new Volume());\n * const stats = await Testing.getTestingWebpackCompiler(\n * `./src/index.ts`,\n * {},\n * virtualFileSystem\n * );\n *\n * expect(stats).toBeDefined();\n * expect(virtualFileSystem.existsSync(path.join(__dirname, 'dist', 'index.js'))).toBe(true);\n * });\n * });\n * ```\n */\nexport async function getTestingWebpackCompilerAsync(\n entry: string,\n additionalConfig: Configuration = {},\n memFs: IFs = createFsFromVolume(new Volume())\n): Promise<(Stats | MultiStats) | undefined> {\n let webpackModule: typeof import('webpack');\n try {\n webpackModule = (await import('webpack')).default;\n } catch (e) {\n throw new Error(\n 'Unable to load module \"webpack\". The @rushstack/webpack-plugin-utilities package declares \"webpack\" as ' +\n 'an optional peer dependency, but a function was invoked on it that requires webpack. Make sure ' +\n `the peer dependency on \"webpack\" is fulfilled. Inner error: ${e}`\n );\n }\n\n const compilerOptions: Configuration = webpackMerge(_defaultWebpackConfig(entry), additionalConfig);\n const compiler: Compiler = webpackModule(compilerOptions);\n\n // The memFs Volume satisfies the interface contract, but the types aren't happy due to strict null checks\n const outputFileSystem: OutputFileSystem = memFs as unknown as OutputFileSystem;\n outputFileSystem.join = path.join.bind(path);\n\n compiler.outputFileSystem = outputFileSystem;\n\n return new Promise((resolve, reject) => {\n compiler.run((err, stats) => {\n compiler.close(() => {\n if (err) {\n return reject(err);\n }\n\n _processAndHandleStatsErrorsAndWarnings(stats, reject);\n\n resolve(stats);\n });\n });\n });\n}\n\nfunction _processAndHandleStatsErrorsAndWarnings(\n stats: Stats | MultiStats | undefined,\n reject: (reason: unknown) => void\n): void {\n if (stats?.hasErrors() || stats?.hasWarnings()) {\n const serializedStats: WebpackStatsCompilation[] = [stats?.toJson('errors-warnings')];\n\n const errors: StatsError[] = [];\n const warnings: StatsError[] = [];\n\n for (const compilationStats of serializedStats) {\n if (compilationStats.warnings) {\n for (const warning of compilationStats.warnings) {\n warnings.push(warning);\n }\n }\n\n if (compilationStats.errors) {\n for (const error of compilationStats.errors) {\n errors.push(error);\n }\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\n\n reject([...errors, ...warnings]);\n }\n}\n\nfunction _defaultWebpackConfig(entry: string = './src'): Configuration {\n return {\n // We don't want to have eval source maps, nor minification\n // so we set mode to 'none' to disable both. Default is 'production'\n mode: 'none',\n context: __dirname,\n entry,\n output: {\n filename: 'test-bundle.js'\n }\n };\n}\n"]}
1
+ {"version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CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAgB,OAAO;IACpD,OAAO;QACL,2DAA2D;QAC3D,oEAAoE;QACpE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,SAAS;QAClB,KAAK;QACL,MAAM,EAAE;YACN,QAAQ,EAAE,gBAAgB;SAC3B;KACF,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 { createFsFromVolume, Volume, type IFs } from 'memfs';\nimport path from 'path';\nimport type { StatsCompilation as WebpackStatsCompilation } from 'webpack';\nimport webpackMerge from 'webpack-merge';\n\nimport type { MultiStats, Stats, Configuration, Compiler, StatsError, OutputFileSystem } from 'webpack';\n\n/**\n * @public\n * This function generates a webpack compiler with default configuration and the output filesystem mapped to\n * a memory filesystem. This is useful for testing webpack plugins/loaders where we do not need to write to disk (which can be costly).\n * @param entry - The entry point for the webpack compiler\n * @param additionalConfig - Any additional configuration that should be merged with the default configuration\n * @param memFs - The memory filesystem to use for the output filesystem. Use this option if you want to _inspect_, analyze, or read the output\n * files generated by the webpack compiler. If you do not need to do this, you can omit this parameter and the output files.\n *\n * @returns - A webpack compiler with the output filesystem mapped to a memory filesystem\n *\n * @example\n * ```typescript\n * import Testing from '@rushstack/webpack-plugin-utilities';\n *\n * describe('MyPlugin', () => {\n * it('should run', async () => {\n * const stats = await Testing.getTestingWebpackCompiler(\n * `./src/index.ts`,\n * );\n *\n * expect(stats).toBeDefined();\n * });\n * });\n * ```\n *\n * @remarks\n * If you want to be able to read, analyze, access the files written to the memory filesystem,\n * you can pass in a memory filesystem instance to the `memFs` parameter.\n *\n * @example\n * ```typescript\n * import Testing from '@rushstack/webpack-plugin-utilities';\n * import { createFsFromVolume, Volume, IFs } from 'memfs';\n * import path from 'path';\n *\n * describe('MyPlugin', () => {\n * it('should run', async () => {\n * const virtualFileSystem: IFs = createFsFromVolume(new Volume());\n * const stats = await Testing.getTestingWebpackCompiler(\n * `./src/index.ts`,\n * {},\n * virtualFileSystem\n * );\n *\n * expect(stats).toBeDefined();\n * expect(virtualFileSystem.existsSync(path.join(__dirname, 'dist', 'index.js'))).toBe(true);\n * });\n * });\n * ```\n */\nexport async function getTestingWebpackCompilerAsync(\n entry: string,\n additionalConfig: Configuration = {},\n memFs: IFs = createFsFromVolume(new Volume())\n): Promise<(Stats | MultiStats) | undefined> {\n let webpackModule: typeof import('webpack');\n try {\n webpackModule = (await import('webpack')).default;\n } catch (e) {\n throw new Error(\n 'Unable to load module \"webpack\". The @rushstack/webpack-plugin-utilities package declares \"webpack\" as ' +\n 'an optional peer dependency, but a function was invoked on it that requires webpack. Make sure ' +\n `the peer dependency on \"webpack\" is fulfilled. Inner error: ${e}`\n );\n }\n\n const compilerOptions: Configuration = webpackMerge(_defaultWebpackConfig(entry), additionalConfig);\n const compiler: Compiler = webpackModule(compilerOptions);\n\n // The memFs Volume satisfies the interface contract, but the types aren't happy due to strict null checks\n const outputFileSystem: OutputFileSystem = memFs as unknown as OutputFileSystem;\n outputFileSystem.join = path.join.bind(path);\n\n compiler.outputFileSystem = outputFileSystem;\n\n return new Promise((resolve, reject) => {\n compiler.run((err, stats) => {\n compiler.close(() => {\n if (err) {\n return reject(err);\n }\n\n _processAndHandleStatsErrorsAndWarnings(stats, reject);\n\n resolve(stats);\n });\n });\n });\n}\n\nfunction _processAndHandleStatsErrorsAndWarnings(\n stats: Stats | MultiStats | undefined,\n reject: (reason: unknown) => void\n): void {\n if (stats?.hasErrors() || stats?.hasWarnings()) {\n const serializedStats: WebpackStatsCompilation[] = [stats?.toJson('errors-warnings')];\n\n const errors: StatsError[] = [];\n const warnings: StatsError[] = [];\n\n for (const compilationStats of serializedStats) {\n if (compilationStats.warnings) {\n for (const warning of compilationStats.warnings) {\n warnings.push(warning);\n }\n }\n\n if (compilationStats.errors) {\n for (const error of compilationStats.errors) {\n errors.push(error);\n }\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\n\n reject([...errors, ...warnings]);\n }\n}\n\nfunction _defaultWebpackConfig(entry: string = './src'): Configuration {\n return {\n // We don't want to have eval source maps, nor minification\n // so we set mode to 'none' to disable both. Default is 'production'\n mode: 'none',\n context: __dirname,\n entry,\n output: {\n filename: 'test-bundle.js'\n }\n };\n}\n"]}
package/lib/index.js CHANGED
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.Testing = exports.VersionDetection = void 0;
29
39
  /**
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D;;;;GAIG;AAEH,yEAA2D;AAElD,4CAAgB;AADzB,mDAAqC;AACV,0BAAO","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Utility package which provides a set of tools for working in\n * webpack plugins, loaders, and other integrations.\n * @packageDocumentation\n */\n\nimport * as VersionDetection from './DetectWebpackVersion';\nimport * as Testing from './Testing';\nexport { VersionDetection, Testing };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D;;;;GAIG;AAEH,yEAA2D;AAElD,4CAAgB;AADzB,mDAAqC;AACV,0BAAO","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Utility package which provides a set of tools for working in\n * webpack plugins, loaders, and other integrations.\n * @packageDocumentation\n */\n\nimport * as VersionDetection from './DetectWebpackVersion';\nimport * as Testing from './Testing';\nexport { VersionDetection, Testing };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack-plugin-utilities",
3
- "version": "0.4.72",
3
+ "version": "0.4.73",
4
4
  "description": "This plugin sets the webpack public path at runtime.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack-plugin-utilities.d.ts",
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/tapable": "1.0.6",
31
- "webpack": "~5.95.0",
32
- "local-node-rig": "1.0.0",
33
- "@rushstack/heft": "0.69.2"
31
+ "webpack": "~5.98.0",
32
+ "@rushstack/heft": "0.69.3",
33
+ "local-node-rig": "1.0.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "heft build --clean",