@rushstack/webpack-plugin-utilities 0.5.14 → 0.6.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 +17 -0
- package/CHANGELOG.md +8 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-esm/DetectWebpackVersion.js +33 -0
- package/lib-esm/DetectWebpackVersion.js.map +1 -0
- package/lib-esm/Testing.js +122 -0
- package/lib-esm/Testing.js.map +1 -0
- package/lib-esm/index.js +11 -0
- package/lib-esm/index.js.map +1 -0
- package/package.json +28 -6
- /package/{lib → lib-commonjs}/DetectWebpackVersion.js +0 -0
- /package/{lib → lib-commonjs}/DetectWebpackVersion.js.map +0 -0
- /package/{lib → lib-commonjs}/Testing.js +0 -0
- /package/{lib → lib-commonjs}/Testing.js.map +0 -0
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-dts}/DetectWebpackVersion.d.ts +0 -0
- /package/{lib → lib-dts}/DetectWebpackVersion.d.ts.map +0 -0
- /package/{lib → lib-dts}/Testing.d.ts +0 -0
- /package/{lib → lib-dts}/Testing.d.ts.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/webpack-plugin-utilities",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.6.0",
|
|
6
|
+
"tag": "@rushstack/webpack-plugin-utilities_v0.6.0",
|
|
7
|
+
"date": "Thu, 19 Feb 2026 00:04:53 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
4
21
|
{
|
|
5
22
|
"version": "0.5.14",
|
|
6
23
|
"tag": "@rushstack/webpack-plugin-utilities_v0.5.14",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @rushstack/webpack-plugin-utilities
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 19 Feb 2026 00:04:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.6.0
|
|
6
|
+
Thu, 19 Feb 2026 00:04:53 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
|
|
4
11
|
|
|
5
12
|
## 0.5.14
|
|
6
13
|
Sat, 07 Feb 2026 01:13:26 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/**
|
|
4
|
+
* We do not have quality API detection between webpack major versions 1-3.
|
|
5
|
+
* We can detect the absence of hooks which was a version 3 feature.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
function isWebpack3OrEarlier(compiler) {
|
|
10
|
+
return !compiler.hooks;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Detects whether or not we are using webpack 4
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
function isWebpack4(compiler) {
|
|
18
|
+
var _a;
|
|
19
|
+
const webpackVersion = (_a = compiler === null || compiler === void 0 ? void 0 : compiler.webpack) === null || _a === void 0 ? void 0 : _a.version;
|
|
20
|
+
return !webpackVersion;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Detects whether or not we are using webpack 5
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
function isWebpack5(compiler) {
|
|
28
|
+
var _a;
|
|
29
|
+
const webpackVersion = (_a = compiler === null || compiler === void 0 ? void 0 : compiler.webpack) === null || _a === void 0 ? void 0 : _a.version;
|
|
30
|
+
return !!webpackVersion;
|
|
31
|
+
}
|
|
32
|
+
export { isWebpack3OrEarlier, isWebpack4, isWebpack5 };
|
|
33
|
+
//# sourceMappingURL=DetectWebpackVersion.js.map
|
|
@@ -0,0 +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;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;AAED,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,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"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createFsFromVolume, Volume } from 'memfs';
|
|
5
|
+
import webpackMerge from 'webpack-merge';
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
* This function generates a webpack compiler with default configuration and the output filesystem mapped to
|
|
9
|
+
* a memory filesystem. This is useful for testing webpack plugins/loaders where we do not need to write to disk (which can be costly).
|
|
10
|
+
* @param entry - The entry point for the webpack compiler
|
|
11
|
+
* @param additionalConfig - Any additional configuration that should be merged with the default configuration
|
|
12
|
+
* @param memFs - The memory filesystem to use for the output filesystem. Use this option if you want to _inspect_, analyze, or read the output
|
|
13
|
+
* files generated by the webpack compiler. If you do not need to do this, you can omit this parameter and the output files.
|
|
14
|
+
*
|
|
15
|
+
* @returns - A webpack compiler with the output filesystem mapped to a memory filesystem
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import Testing from '@rushstack/webpack-plugin-utilities';
|
|
20
|
+
*
|
|
21
|
+
* describe('MyPlugin', () => {
|
|
22
|
+
* it('should run', async () => {
|
|
23
|
+
* const stats = await Testing.getTestingWebpackCompiler(
|
|
24
|
+
* `./src/index.ts`,
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* expect(stats).toBeDefined();
|
|
28
|
+
* });
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* If you want to be able to read, analyze, access the files written to the memory filesystem,
|
|
34
|
+
* you can pass in a memory filesystem instance to the `memFs` parameter.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import Testing from '@rushstack/webpack-plugin-utilities';
|
|
39
|
+
* import { createFsFromVolume, Volume, IFs } from 'memfs';
|
|
40
|
+
* import path from 'path';
|
|
41
|
+
*
|
|
42
|
+
* describe('MyPlugin', () => {
|
|
43
|
+
* it('should run', async () => {
|
|
44
|
+
* const virtualFileSystem: IFs = createFsFromVolume(new Volume());
|
|
45
|
+
* const stats = await Testing.getTestingWebpackCompiler(
|
|
46
|
+
* `./src/index.ts`,
|
|
47
|
+
* {},
|
|
48
|
+
* virtualFileSystem
|
|
49
|
+
* );
|
|
50
|
+
*
|
|
51
|
+
* expect(stats).toBeDefined();
|
|
52
|
+
* expect(virtualFileSystem.existsSync(path.join(__dirname, 'dist', 'index.js'))).toBe(true);
|
|
53
|
+
* });
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export async function getTestingWebpackCompilerAsync(entry, additionalConfig = {}, memFs = createFsFromVolume(new Volume())) {
|
|
58
|
+
let webpackModule;
|
|
59
|
+
try {
|
|
60
|
+
webpackModule = (await import('webpack')).default;
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
throw new Error('Unable to load module "webpack". The @rushstack/webpack-plugin-utilities package declares "webpack" as ' +
|
|
64
|
+
'an optional peer dependency, but a function was invoked on it that requires webpack. Make sure ' +
|
|
65
|
+
`the peer dependency on "webpack" is fulfilled. Inner error: ${e}`);
|
|
66
|
+
}
|
|
67
|
+
const compilerOptions = webpackMerge(_defaultWebpackConfig(entry), additionalConfig);
|
|
68
|
+
const compiler = webpackModule(compilerOptions);
|
|
69
|
+
// The memFs Volume satisfies the interface contract, but the types aren't happy due to strict null checks
|
|
70
|
+
const outputFileSystem = memFs;
|
|
71
|
+
outputFileSystem.join = path.join.bind(path);
|
|
72
|
+
compiler.outputFileSystem = outputFileSystem;
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
compiler.run((err, stats) => {
|
|
75
|
+
compiler.close(() => {
|
|
76
|
+
if (err) {
|
|
77
|
+
return reject(err);
|
|
78
|
+
}
|
|
79
|
+
_processAndHandleStatsErrorsAndWarnings(stats, reject);
|
|
80
|
+
resolve(stats);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function _processAndHandleStatsErrorsAndWarnings(stats, reject) {
|
|
86
|
+
if ((stats === null || stats === void 0 ? void 0 : stats.hasErrors()) || (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
|
|
87
|
+
const serializedStats = [stats === null || stats === void 0 ? void 0 : stats.toJson('errors-warnings')];
|
|
88
|
+
const errors = [];
|
|
89
|
+
const warnings = [];
|
|
90
|
+
for (const compilationStats of serializedStats) {
|
|
91
|
+
if (compilationStats.warnings) {
|
|
92
|
+
for (const warning of compilationStats.warnings) {
|
|
93
|
+
warnings.push(warning);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (compilationStats.errors) {
|
|
97
|
+
for (const error of compilationStats.errors) {
|
|
98
|
+
errors.push(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (compilationStats.children) {
|
|
102
|
+
for (const child of compilationStats.children) {
|
|
103
|
+
serializedStats.push(child);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
reject([...errors, ...warnings]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function _defaultWebpackConfig(entry = './src') {
|
|
111
|
+
return {
|
|
112
|
+
// We don't want to have eval source maps, nor minification
|
|
113
|
+
// so we set mode to 'none' to disable both. Default is 'production'
|
|
114
|
+
mode: 'none',
|
|
115
|
+
context: __dirname,
|
|
116
|
+
entry,
|
|
117
|
+
output: {
|
|
118
|
+
filename: 'test-bundle.js'
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=Testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Testing.js","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAY,MAAM,OAAO,CAAC;AAU7D,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,KAAa,EACb,mBAAkC,EAAE,EACpC,QAAa,kBAAkB,CAAC,IAAI,MAAM,EAAE,CAAC;IAE7C,IAAI,aAAuC,CAAC;IAC5C,IAAI,CAAC;QACH,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IACpD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,yGAAyG;YACvG,iGAAiG;YACjG,+DAA+D,CAAC,EAAE,CACrE,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAkB,YAAY,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACpG,MAAM,QAAQ,GAAa,aAAa,CAAC,eAAe,CAAC,CAAC;IAE1D,0GAA0G;IAC1G,MAAM,gBAAgB,GAAqB,KAAoC,CAAC;IAChF,gBAAgB,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7C,QAAQ,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAE7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC1B,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE;gBAClB,IAAI,GAAG,EAAE,CAAC;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;gBAED,uCAAuC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAEvD,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,uCAAuC,CAC9C,KAAqC,EACrC,MAAiC;IAEjC,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,EAAE,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,EAAE,CAAA,EAAE,CAAC;QAC/C,MAAM,eAAe,GAA8B,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAEtF,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAiB,EAAE,CAAC;QAElC,KAAK,MAAM,gBAAgB,IAAI,eAAe,EAAE,CAAC;YAC/C,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;gBAC9B,KAAK,MAAM,OAAO,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;oBAChD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;YAED,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBAC5B,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;oBAC5C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;YAED,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;gBAC9B,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;oBAC9C,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,QAAQ,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 path from 'node:path';\n\nimport { createFsFromVolume, Volume, type IFs } from 'memfs';\nimport type {\n StatsCompilation as WebpackStatsCompilation,\n MultiStats,\n Stats,\n Configuration,\n Compiler,\n StatsError,\n OutputFileSystem\n} from 'webpack';\nimport webpackMerge from 'webpack-merge';\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-esm/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/**
|
|
4
|
+
* Utility package which provides a set of tools for working in
|
|
5
|
+
* webpack plugins, loaders, and other integrations.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import * as VersionDetection from './DetectWebpackVersion';
|
|
9
|
+
import * as Testing from './Testing';
|
|
10
|
+
export { VersionDetection, Testing };
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;GAIG;AAEH,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,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 * 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,9 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/webpack-plugin-utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "This plugin sets the webpack public path at runtime.",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "./lib-commonjs/index.js",
|
|
6
|
+
"module": "./lib-esm/index.js",
|
|
7
|
+
"types": "./dist/webpack-plugin-utilities.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/webpack-plugin-utilities.d.ts",
|
|
11
|
+
"import": "./lib-esm/index.js",
|
|
12
|
+
"require": "./lib-commonjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./lib/*": {
|
|
15
|
+
"types": "./lib-dts/*.d.ts",
|
|
16
|
+
"import": "./lib-esm/*.js",
|
|
17
|
+
"require": "./lib-commonjs/*.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
"lib/*": [
|
|
24
|
+
"lib-dts/*"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
7
28
|
"license": "MIT",
|
|
8
29
|
"repository": {
|
|
9
30
|
"type": "git",
|
|
@@ -29,10 +50,11 @@
|
|
|
29
50
|
"devDependencies": {
|
|
30
51
|
"eslint": "~9.37.0",
|
|
31
52
|
"@types/tapable": "1.0.6",
|
|
32
|
-
"webpack": "~5.105.
|
|
33
|
-
"
|
|
34
|
-
"
|
|
53
|
+
"webpack": "~5.105.2",
|
|
54
|
+
"local-node-rig": "1.0.0",
|
|
55
|
+
"@rushstack/heft": "1.2.0"
|
|
35
56
|
},
|
|
57
|
+
"sideEffects": false,
|
|
36
58
|
"scripts": {
|
|
37
59
|
"build": "heft build --clean",
|
|
38
60
|
"_phase:build": "heft run --only build -- --clean"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|