@rushstack/heft-webpack5-plugin 0.5.50 → 0.6.0-dev.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/README.md +2 -1
- package/dist/heft-webpack5-plugin.d.ts +73 -22
- package/dist/tsdoc-metadata.json +1 -1
- package/heft-plugin.json +20 -0
- package/lib/Webpack5Plugin.d.ts +33 -0
- package/lib/Webpack5Plugin.d.ts.map +1 -0
- package/lib/Webpack5Plugin.js +362 -0
- package/lib/Webpack5Plugin.js.map +1 -0
- package/lib/WebpackConfigurationLoader.d.ts +16 -4
- package/lib/WebpackConfigurationLoader.d.ts.map +1 -1
- package/lib/WebpackConfigurationLoader.js +36 -15
- package/lib/WebpackConfigurationLoader.js.map +1 -1
- package/lib/index.d.ts +2 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -5
- package/lib/index.js.map +1 -1
- package/lib/schemas/heft-webpack5-plugin.schema.json +25 -0
- package/lib/shared.d.ts +64 -14
- package/lib/shared.d.ts.map +1 -1
- package/lib/shared.js.map +1 -1
- package/package.json +9 -6
- package/lib/WebpackPlugin.d.ts +0 -14
- package/lib/WebpackPlugin.d.ts.map +0 -1
- package/lib/WebpackPlugin.js +0 -248
- package/lib/WebpackPlugin.js.map +0 -1
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import type * as TWebpack from 'webpack';
|
|
2
|
+
import type { IScopedLogger, IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';
|
|
3
|
+
import type { IWebpackPluginOptions } from './Webpack5Plugin';
|
|
4
|
+
import type { IWebpackConfiguration } from './shared';
|
|
5
|
+
interface ILoadWebpackConfigurationOptions extends IWebpackPluginOptions {
|
|
6
|
+
taskSession: IHeftTaskSession;
|
|
7
|
+
heftConfiguration: HeftConfiguration;
|
|
8
|
+
loadWebpackAsyncFn: () => Promise<typeof TWebpack>;
|
|
9
|
+
}
|
|
3
10
|
export declare class WebpackConfigurationLoader {
|
|
4
|
-
|
|
5
|
-
private
|
|
11
|
+
private readonly _logger;
|
|
12
|
+
private readonly _production;
|
|
13
|
+
private readonly _serveMode;
|
|
14
|
+
constructor(logger: IScopedLogger, production: boolean, serveMode: boolean);
|
|
15
|
+
tryLoadWebpackConfigurationAsync(options: ILoadWebpackConfigurationOptions): Promise<IWebpackConfiguration | undefined>;
|
|
16
|
+
private _tryLoadWebpackConfigurationInnerAsync;
|
|
6
17
|
}
|
|
18
|
+
export {};
|
|
7
19
|
//# sourceMappingURL=WebpackConfigurationLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebpackConfigurationLoader.d.ts","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebpackConfigurationLoader.d.ts","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,QAAQ,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAsC,MAAM,UAAU,CAAC;AAW1F,UAAU,gCAAiC,SAAQ,qBAAqB;IACtE,WAAW,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,kBAAkB,EAAE,MAAM,OAAO,CAAC,OAAO,QAAQ,CAAC,CAAC;CACpD;AAKD,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;gBAElB,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO;IAMpE,gCAAgC,CAC3C,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;YAwD/B,sCAAsC;CAmBrD"}
|
|
@@ -28,30 +28,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
exports.WebpackConfigurationLoader = void 0;
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
31
|
+
const DEFAULT_WEBPACK_CONFIG_PATH = './webpack.config.js';
|
|
32
|
+
const DEFAULT_WEBPACK_DEV_CONFIG_PATH = './webpack.dev.config.js';
|
|
33
33
|
class WebpackConfigurationLoader {
|
|
34
|
-
|
|
34
|
+
constructor(logger, production, serveMode) {
|
|
35
|
+
this._logger = logger;
|
|
36
|
+
this._production = production;
|
|
37
|
+
this._serveMode = serveMode;
|
|
38
|
+
}
|
|
39
|
+
async tryLoadWebpackConfigurationAsync(options) {
|
|
35
40
|
// TODO: Eventually replace this custom logic with a call to this utility in in webpack-cli:
|
|
36
41
|
// https://github.com/webpack/webpack-cli/blob/next/packages/webpack-cli/lib/groups/ConfigGroup.js
|
|
42
|
+
const { taskSession, heftConfiguration, configurationPath, devConfigurationPath, loadWebpackAsyncFn } = options;
|
|
37
43
|
let webpackConfigJs;
|
|
38
44
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const buildFolderPath = heftConfiguration.buildFolderPath;
|
|
46
|
+
if (this._serveMode) {
|
|
47
|
+
const devConfigPath = path.resolve(buildFolderPath, devConfigurationPath || DEFAULT_WEBPACK_DEV_CONFIG_PATH);
|
|
48
|
+
this._logger.terminal.writeVerboseLine(`Attempting to load webpack configuration from "${devConfigPath}".`);
|
|
49
|
+
webpackConfigJs = await this._tryLoadWebpackConfigurationInnerAsync(devConfigPath);
|
|
42
50
|
}
|
|
43
51
|
if (!webpackConfigJs) {
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
const configPath = path.resolve(buildFolderPath, configurationPath || DEFAULT_WEBPACK_CONFIG_PATH);
|
|
53
|
+
this._logger.terminal.writeVerboseLine(`Attempting to load webpack configuration from "${configPath}".`);
|
|
54
|
+
webpackConfigJs = await this._tryLoadWebpackConfigurationInnerAsync(configPath);
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
catch (error) {
|
|
49
|
-
|
|
58
|
+
this._logger.emitError(error);
|
|
50
59
|
}
|
|
51
60
|
if (webpackConfigJs) {
|
|
52
61
|
const webpackConfig = webpackConfigJs.default || webpackConfigJs;
|
|
53
62
|
if (typeof webpackConfig === 'function') {
|
|
54
|
-
|
|
63
|
+
// Defer loading of webpack until we know for sure that we will need it
|
|
64
|
+
return webpackConfig({
|
|
65
|
+
prod: this._production,
|
|
66
|
+
production: this._production,
|
|
67
|
+
taskSession,
|
|
68
|
+
heftConfiguration,
|
|
69
|
+
webpack: await loadWebpackAsyncFn()
|
|
70
|
+
});
|
|
55
71
|
}
|
|
56
72
|
else {
|
|
57
73
|
return webpackConfig;
|
|
@@ -61,14 +77,19 @@ class WebpackConfigurationLoader {
|
|
|
61
77
|
return undefined;
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
80
|
+
async _tryLoadWebpackConfigurationInnerAsync(configurationPath) {
|
|
81
|
+
const configExists = await node_core_library_1.FileSystem.existsAsync(configurationPath);
|
|
82
|
+
if (configExists) {
|
|
67
83
|
try {
|
|
68
|
-
return require(
|
|
84
|
+
return await Promise.resolve().then(() => __importStar(require(configurationPath)));
|
|
69
85
|
}
|
|
70
86
|
catch (e) {
|
|
71
|
-
|
|
87
|
+
const error = e;
|
|
88
|
+
if (error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
89
|
+
// No configuration found, return undefined.
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Error loading webpack configuration at "${configurationPath}": ${e}`);
|
|
72
93
|
}
|
|
73
94
|
}
|
|
74
95
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebpackConfigurationLoader.js","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;
|
|
1
|
+
{"version":3,"file":"WebpackConfigurationLoader.js","sourceRoot":"","sources":["../src/WebpackConfigurationLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAE7B,oEAA0D;AAqB1D,MAAM,2BAA2B,GAA0B,qBAAqB,CAAC;AACjF,MAAM,+BAA+B,GAA8B,yBAAyB,CAAC;AAE7F,MAAa,0BAA0B;IAKrC,YAAmB,MAAqB,EAAE,UAAmB,EAAE,SAAkB;QAC/E,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,gCAAgC,CAC3C,OAAyC;QAEzC,4FAA4F;QAC5F,kGAAkG;QAElG,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,GACnG,OAAO,CAAC;QACV,IAAI,eAA6C,CAAC;QAElD,IAAI;YACF,MAAM,eAAe,GAAW,iBAAiB,CAAC,eAAe,CAAC;YAClE,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,MAAM,aAAa,GAAW,IAAI,CAAC,OAAO,CACxC,eAAe,EACf,oBAAoB,IAAI,+BAA+B,CACxD,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CACpC,kDAAkD,aAAa,IAAI,CACpE,CAAC;gBACF,eAAe,GAAG,MAAM,IAAI,CAAC,sCAAsC,CAAC,aAAa,CAAC,CAAC;aACpF;YAED,IAAI,CAAC,eAAe,EAAE;gBACpB,MAAM,UAAU,GAAW,IAAI,CAAC,OAAO,CACrC,eAAe,EACf,iBAAiB,IAAI,2BAA2B,CACjD,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CACpC,kDAAkD,UAAU,IAAI,CACjE,CAAC;gBACF,eAAe,GAAG,MAAM,IAAI,CAAC,sCAAsC,CAAC,UAAU,CAAC,CAAC;aACjF;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAc,CAAC,CAAC;SACxC;QAED,IAAI,eAAe,EAAE;YACnB,MAAM,aAAa,GAChB,eAAuD,CAAC,OAAO,IAAI,eAAe,CAAC;YAEtF,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;gBACvC,uEAAuE;gBACvE,OAAO,aAAa,CAAC;oBACnB,IAAI,EAAE,IAAI,CAAC,WAAW;oBACtB,UAAU,EAAE,IAAI,CAAC,WAAW;oBAC5B,WAAW;oBACX,iBAAiB;oBACjB,OAAO,EAAE,MAAM,kBAAkB,EAAE;iBACpC,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,aAAa,CAAC;aACtB;SACF;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;IAEO,KAAK,CAAC,sCAAsC,CAClD,iBAAyB;QAEzB,MAAM,YAAY,GAAY,MAAM,8BAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAC9E,IAAI,YAAY,EAAE;YAChB,IAAI;gBACF,OAAO,wDAAa,iBAAiB,GAAC,CAAC;aACxC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,KAAK,GAA0B,CAA0B,CAAC;gBAChE,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE;oBACzC,4CAA4C;oBAC5C,OAAO,SAAS,CAAC;iBAClB;gBACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,iBAAiB,MAAM,CAAC,EAAE,CAAC,CAAC;aACxF;SACF;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AAxFD,gEAwFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\nimport type * as TWebpack from 'webpack';\nimport { FileSystem } from '@rushstack/node-core-library';\nimport type { IScopedLogger, IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\nimport type { IWebpackPluginOptions } from './Webpack5Plugin';\nimport type { IWebpackConfiguration, IWebpackConfigurationFnEnvironment } from './shared';\n\ntype IWebpackConfigJsExport =\n | TWebpack.Configuration\n | TWebpack.Configuration[]\n | Promise<TWebpack.Configuration>\n | Promise<TWebpack.Configuration[]>\n | ((env: IWebpackConfigurationFnEnvironment) => TWebpack.Configuration | TWebpack.Configuration[])\n | ((env: IWebpackConfigurationFnEnvironment) => Promise<TWebpack.Configuration | TWebpack.Configuration[]>);\ntype IWebpackConfigJs = IWebpackConfigJsExport | { default: IWebpackConfigJsExport };\n\ninterface ILoadWebpackConfigurationOptions extends IWebpackPluginOptions {\n taskSession: IHeftTaskSession;\n heftConfiguration: HeftConfiguration;\n loadWebpackAsyncFn: () => Promise<typeof TWebpack>;\n}\n\nconst DEFAULT_WEBPACK_CONFIG_PATH: './webpack.config.js' = './webpack.config.js';\nconst DEFAULT_WEBPACK_DEV_CONFIG_PATH: './webpack.dev.config.js' = './webpack.dev.config.js';\n\nexport class WebpackConfigurationLoader {\n private readonly _logger: IScopedLogger;\n private readonly _production: boolean;\n private readonly _serveMode: boolean;\n\n public constructor(logger: IScopedLogger, production: boolean, serveMode: boolean) {\n this._logger = logger;\n this._production = production;\n this._serveMode = serveMode;\n }\n\n public async tryLoadWebpackConfigurationAsync(\n options: ILoadWebpackConfigurationOptions\n ): Promise<IWebpackConfiguration | undefined> {\n // TODO: Eventually replace this custom logic with a call to this utility in in webpack-cli:\n // https://github.com/webpack/webpack-cli/blob/next/packages/webpack-cli/lib/groups/ConfigGroup.js\n\n const { taskSession, heftConfiguration, configurationPath, devConfigurationPath, loadWebpackAsyncFn } =\n options;\n let webpackConfigJs: IWebpackConfigJs | undefined;\n\n try {\n const buildFolderPath: string = heftConfiguration.buildFolderPath;\n if (this._serveMode) {\n const devConfigPath: string = path.resolve(\n buildFolderPath,\n devConfigurationPath || DEFAULT_WEBPACK_DEV_CONFIG_PATH\n );\n this._logger.terminal.writeVerboseLine(\n `Attempting to load webpack configuration from \"${devConfigPath}\".`\n );\n webpackConfigJs = await this._tryLoadWebpackConfigurationInnerAsync(devConfigPath);\n }\n\n if (!webpackConfigJs) {\n const configPath: string = path.resolve(\n buildFolderPath,\n configurationPath || DEFAULT_WEBPACK_CONFIG_PATH\n );\n this._logger.terminal.writeVerboseLine(\n `Attempting to load webpack configuration from \"${configPath}\".`\n );\n webpackConfigJs = await this._tryLoadWebpackConfigurationInnerAsync(configPath);\n }\n } catch (error) {\n this._logger.emitError(error as Error);\n }\n\n if (webpackConfigJs) {\n const webpackConfig: IWebpackConfigJsExport =\n (webpackConfigJs as { default: IWebpackConfigJsExport }).default || webpackConfigJs;\n\n if (typeof webpackConfig === 'function') {\n // Defer loading of webpack until we know for sure that we will need it\n return webpackConfig({\n prod: this._production,\n production: this._production,\n taskSession,\n heftConfiguration,\n webpack: await loadWebpackAsyncFn()\n });\n } else {\n return webpackConfig;\n }\n } else {\n return undefined;\n }\n }\n\n private async _tryLoadWebpackConfigurationInnerAsync(\n configurationPath: string\n ): Promise<IWebpackConfigJs | undefined> {\n const configExists: boolean = await FileSystem.existsAsync(configurationPath);\n if (configExists) {\n try {\n return await import(configurationPath);\n } catch (e) {\n const error: NodeJS.ErrnoException = e as NodeJS.ErrnoException;\n if (error.code === 'ERR_MODULE_NOT_FOUND') {\n // No configuration found, return undefined.\n return undefined;\n }\n throw new Error(`Error loading webpack configuration at \"${configurationPath}\": ${e}`);\n }\n } else {\n return undefined;\n }\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export { IWebpackConfigurationWithDevServer, IWebpackConfiguration,
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
declare const _default: IHeftPlugin<void>;
|
|
7
|
-
export default _default;
|
|
1
|
+
export { PLUGIN_NAME as PluginName } from './Webpack5Plugin';
|
|
2
|
+
export type { IWebpackConfigurationWithDevServer, IWebpackConfiguration, IWebpackConfigurationFnEnvironment, IWebpackPluginAccessor, IWebpackPluginAccessorHooks } from './shared';
|
|
8
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE7D,YAAY,EACV,kCAAkC,EAClC,qBAAqB,EACrB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,UAAU,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
exports.default = new WebpackPlugin_1.WebpackPlugin();
|
|
5
|
+
exports.PluginName = void 0;
|
|
6
|
+
var Webpack5Plugin_1 = require("./Webpack5Plugin");
|
|
7
|
+
Object.defineProperty(exports, "PluginName", { enumerable: true, get: function () { return Webpack5Plugin_1.PLUGIN_NAME; } });
|
|
10
8
|
//# sourceMappingURL=index.js.map
|
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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mDAA6D;AAApD,4GAAA,WAAW,OAAc","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { PLUGIN_NAME as PluginName } from './Webpack5Plugin';\n\nexport type {\n IWebpackConfigurationWithDevServer,\n IWebpackConfiguration,\n IWebpackConfigurationFnEnvironment,\n IWebpackPluginAccessor,\n IWebpackPluginAccessorHooks\n} from './shared';\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"title": "Webpack 5 Plugin Configuration",
|
|
4
|
+
"description": "Defines options for Webpack 5 plugin execution.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": {
|
|
11
|
+
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"devConfigurationPath": {
|
|
16
|
+
"description": "Specifies a relative path to the Webpack dev configuration, which is used in \"serve\" mode. The default value is \"./webpack.dev.config.js\".",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
"configurationPath": {
|
|
21
|
+
"description": "Specifies a relative path to the Webpack configuration. The default value is \"./webpack.config.js\".",
|
|
22
|
+
"type": "string"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/lib/shared.d.ts
CHANGED
|
@@ -1,36 +1,86 @@
|
|
|
1
|
+
import type * as TWebpack from 'webpack';
|
|
1
2
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
3
|
+
import type { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook } from 'tapable';
|
|
4
|
+
import type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';
|
|
4
5
|
/**
|
|
6
|
+
* The environment passed into the Webpack configuration function. Loosely based
|
|
7
|
+
* on the default Webpack environment options, specified here:
|
|
8
|
+
* https://webpack.js.org/api/cli/#environment-options
|
|
9
|
+
*
|
|
5
10
|
* @public
|
|
6
11
|
*/
|
|
7
|
-
export interface
|
|
12
|
+
export interface IWebpackConfigurationFnEnvironment {
|
|
13
|
+
/**
|
|
14
|
+
* Whether or not the run is in production mode. Synonym of
|
|
15
|
+
* IWebpackConfigurationFnEnvironment.production.
|
|
16
|
+
*/
|
|
17
|
+
prod: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether or not the run is in production mode. Synonym of
|
|
20
|
+
* IWebpackConfigurationFnEnvironment.prod.
|
|
21
|
+
*/
|
|
22
|
+
production: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The task session provided to the plugin.
|
|
25
|
+
*/
|
|
26
|
+
taskSession: IHeftTaskSession;
|
|
27
|
+
/**
|
|
28
|
+
* The Heft configuration provided to the plugin.
|
|
29
|
+
*/
|
|
30
|
+
heftConfiguration: HeftConfiguration;
|
|
31
|
+
/**
|
|
32
|
+
* The resolved Webpack package.
|
|
33
|
+
*/
|
|
34
|
+
webpack: typeof TWebpack;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export interface IWebpackConfigurationWithDevServer extends TWebpack.Configuration {
|
|
8
40
|
devServer?: WebpackDevServerConfiguration;
|
|
9
41
|
}
|
|
10
42
|
/**
|
|
11
43
|
* @public
|
|
12
44
|
*/
|
|
13
|
-
export declare type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[]
|
|
45
|
+
export declare type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[];
|
|
14
46
|
/**
|
|
15
47
|
* @public
|
|
16
48
|
*/
|
|
17
|
-
export interface
|
|
49
|
+
export interface IWebpackPluginAccessorHooks {
|
|
18
50
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
51
|
+
* A hook that allows for loading custom configurations used by the Webpack
|
|
52
|
+
* plugin. If a webpack configuration is provided, this will be populated automatically
|
|
53
|
+
* with the exports of the config file. If a webpack configuration is not provided,
|
|
54
|
+
* one will be loaded by the Webpack plugin.
|
|
23
55
|
*
|
|
24
56
|
* @remarks
|
|
25
|
-
* Tapable event handlers can return `
|
|
26
|
-
* other handlers from creating a configuration object.
|
|
57
|
+
* Tapable event handlers can return `false` instead of `undefined` to suppress
|
|
58
|
+
* other handlers from creating a configuration object, and prevent webpack from running.
|
|
27
59
|
*/
|
|
28
|
-
|
|
60
|
+
readonly onLoadConfiguration: AsyncSeriesBailHook<never, never, never, IWebpackConfiguration | false>;
|
|
61
|
+
/**
|
|
62
|
+
* A hook that allows for modification of the loaded configuration used by the Webpack
|
|
63
|
+
* plugin. If no configuration was loaded, this hook will not be called.
|
|
64
|
+
*/
|
|
65
|
+
readonly onConfigure: AsyncSeriesHook<IWebpackConfiguration, never, never>;
|
|
66
|
+
/**
|
|
67
|
+
* A hook that provides the finalized configuration that will be used by Webpack.
|
|
68
|
+
* If no configuration was loaded, this hook will not be called.
|
|
69
|
+
*/
|
|
70
|
+
readonly onAfterConfigure: AsyncParallelHook<IWebpackConfiguration, never, never>;
|
|
71
|
+
/**
|
|
72
|
+
* A hook that provides the stats output from Webpack. If no configuration is loaded,
|
|
73
|
+
* this hook will not be called.
|
|
74
|
+
*/
|
|
75
|
+
readonly onEmitStats: AsyncParallelHook<TWebpack.Stats | TWebpack.MultiStats, never, never>;
|
|
29
76
|
}
|
|
30
77
|
/**
|
|
31
78
|
* @public
|
|
32
79
|
*/
|
|
33
|
-
export interface
|
|
34
|
-
|
|
80
|
+
export interface IWebpackPluginAccessor {
|
|
81
|
+
/**
|
|
82
|
+
* Hooks that are called at various points in the Webpack plugin lifecycle.
|
|
83
|
+
*/
|
|
84
|
+
hooks: IWebpackPluginAccessorHooks;
|
|
35
85
|
}
|
|
36
86
|
//# sourceMappingURL=shared.d.ts.map
|
package/lib/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,QAAQ,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,IAAI,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,WAAW,kCAAkC;IACjD;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IAGpB;;OAEG;IACH,WAAW,EAAE,gBAAgB,CAAC;IAC9B;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;OAEG;IACH,OAAO,EAAE,OAAO,QAAQ,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,QAAQ,CAAC,aAAa;IAChF,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC3C;AAED;;GAEG;AACH,oBAAY,qBAAqB,GAAG,kCAAkC,GAAG,kCAAkC,EAAE,CAAC;AAE9G;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;;OASG;IACH,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,GAAG,KAAK,CAAC,CAAC;IACtG;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3E;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClF;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAC7F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,2BAA2B,CAAC;CACpC"}
|
package/lib/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","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 { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\nimport type
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as TWebpack from 'webpack';\nimport type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\nimport type { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook } from 'tapable';\nimport type { IHeftTaskSession, HeftConfiguration } from '@rushstack/heft';\n\n/**\n * The environment passed into the Webpack configuration function. Loosely based\n * on the default Webpack environment options, specified here:\n * https://webpack.js.org/api/cli/#environment-options\n *\n * @public\n */\nexport interface IWebpackConfigurationFnEnvironment {\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.production.\n */\n prod: boolean;\n /**\n * Whether or not the run is in production mode. Synonym of\n * IWebpackConfigurationFnEnvironment.prod.\n */\n production: boolean;\n\n // Non-standard environment options\n /**\n * The task session provided to the plugin.\n */\n taskSession: IHeftTaskSession;\n /**\n * The Heft configuration provided to the plugin.\n */\n heftConfiguration: HeftConfiguration;\n /**\n * The resolved Webpack package.\n */\n webpack: typeof TWebpack;\n}\n\n/**\n * @public\n */\nexport interface IWebpackConfigurationWithDevServer extends TWebpack.Configuration {\n devServer?: WebpackDevServerConfiguration;\n}\n\n/**\n * @public\n */\nexport type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[];\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessorHooks {\n /**\n * A hook that allows for loading custom configurations used by the Webpack\n * plugin. If a webpack configuration is provided, this will be populated automatically\n * with the exports of the config file. If a webpack configuration is not provided,\n * one will be loaded by the Webpack plugin.\n *\n * @remarks\n * Tapable event handlers can return `false` instead of `undefined` to suppress\n * other handlers from creating a configuration object, and prevent webpack from running.\n */\n readonly onLoadConfiguration: AsyncSeriesBailHook<never, never, never, IWebpackConfiguration | false>;\n /**\n * A hook that allows for modification of the loaded configuration used by the Webpack\n * plugin. If no configuration was loaded, this hook will not be called.\n */\n readonly onConfigure: AsyncSeriesHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the finalized configuration that will be used by Webpack.\n * If no configuration was loaded, this hook will not be called.\n */\n readonly onAfterConfigure: AsyncParallelHook<IWebpackConfiguration, never, never>;\n /**\n * A hook that provides the stats output from Webpack. If no configuration is loaded,\n * this hook will not be called.\n */\n readonly onEmitStats: AsyncParallelHook<TWebpack.Stats | TWebpack.MultiStats, never, never>;\n}\n\n/**\n * @public\n */\nexport interface IWebpackPluginAccessor {\n /**\n * Hooks that are called at various points in the Webpack plugin lifecycle.\n */\n hooks: IWebpackPluginAccessorHooks;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-webpack5-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-dev.0",
|
|
4
4
|
"description": "Heft plugin for Webpack 5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,24 +12,27 @@
|
|
|
12
12
|
"types": "dist/heft-webpack5-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "^0.
|
|
15
|
+
"@rushstack/heft": "^0.48.0-dev.0",
|
|
16
16
|
"webpack": "~5.68.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@rushstack/debug-certificate-manager": "1.1.76",
|
|
19
20
|
"@rushstack/node-core-library": "3.52.0",
|
|
21
|
+
"@types/tapable": "1.0.6",
|
|
22
|
+
"tapable": "1.1.3",
|
|
20
23
|
"webpack-dev-server": "~4.9.3"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@rushstack/eslint-config": "3.0.1",
|
|
24
|
-
"@rushstack/heft": "0.
|
|
25
|
-
"@rushstack/heft-node-rig": "1.
|
|
27
|
+
"@rushstack/heft": "0.48.0-dev.0",
|
|
28
|
+
"@rushstack/heft-node-rig": "1.11.0-dev.0",
|
|
26
29
|
"@types/node": "12.20.24",
|
|
27
30
|
"webpack": "~5.68.0"
|
|
28
31
|
},
|
|
29
32
|
"scripts": {
|
|
30
33
|
"build": "heft build --clean",
|
|
31
34
|
"start": "heft test --clean --watch",
|
|
32
|
-
"_phase:build": "heft build --clean",
|
|
33
|
-
"_phase:test": "heft test --
|
|
35
|
+
"_phase:build": "heft run --only build -- --clean",
|
|
36
|
+
"_phase:test": "heft run --only test -- --clean"
|
|
34
37
|
}
|
|
35
38
|
}
|
package/lib/WebpackPlugin.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { HeftConfiguration, HeftSession, IHeftPlugin } from '@rushstack/heft';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare class WebpackPlugin implements IHeftPlugin {
|
|
6
|
-
readonly pluginName: string;
|
|
7
|
-
private static _webpackVersions;
|
|
8
|
-
private static _getWebpackVersions;
|
|
9
|
-
apply(heftSession: HeftSession, heftConfiguration: HeftConfiguration): void;
|
|
10
|
-
private _runWebpackAsync;
|
|
11
|
-
private _emitErrors;
|
|
12
|
-
private _normalizeError;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=WebpackPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebpackPlugin.d.ts","sourceRoot":"","sources":["../src/WebpackPlugin.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EAIX,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AAmBzB;;GAEG;AACH,qBAAa,aAAc,YAAW,WAAW;IAC/C,SAAgB,UAAU,EAAE,MAAM,CAAe;IAEjD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA+B;IAC9D,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAkB3B,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,IAAI;YA2CpE,gBAAgB;IAiK9B,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,eAAe;CAqBxB"}
|