@rushstack/webpack-plugin-utilities 0.3.16 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/Testing.js.map +1 -1
- package/package.json +3 -3
package/dist/tsdoc-metadata.json
CHANGED
package/lib/Testing.js.map
CHANGED
|
@@ -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,KAAK,UAAU,8BAA8B,CAClD,KAAa,EACb,mBAAkC,EAAE,EACpC,QAAa,IAAA,0BAAkB,EAAC,IAAI,cAAM,EAAE,CAAC;IAE7C,IAAI,aAAuC,CAAC;IAC5C,IAAI;
|
|
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,KAAK,UAAU,8BAA8B,CAClD,KAAa,EACb,mBAAkC,EAAE,EACpC,QAAa,IAAA,0BAAkB,EAAC,IAAI,cAAM,EAAE,CAAC;IAE7C,IAAI,aAAuC,CAAC;IAC5C,IAAI,CAAC;QACH,aAAa,GAAG,CAAC,wDAAa,SAAS,GAAC,CAAC,CAAC,OAAO,CAAC;IACpD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,yGAAyG;YACvG,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;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 { 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 } 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 compiler.outputFileSystem = memFs;\n compiler.outputFileSystem.join = path.join.bind(path);\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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/webpack-plugin-utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@types/webpack": "^4.39.8",
|
|
19
|
-
"webpack": "^5.35.1"
|
|
19
|
+
"webpack": "^5.35.1 || ^4.31.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"@types/webpack": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/tapable": "1.0.6",
|
|
31
31
|
"webpack": "~5.82.1",
|
|
32
|
-
"@rushstack/heft": "0.
|
|
32
|
+
"@rushstack/heft": "0.64.0",
|
|
33
33
|
"local-node-rig": "1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|