@rushstack/heft-webpack5-plugin 0.6.0-rc.4 → 0.6.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/README.md +1 -2
- package/dist/heft-webpack5-plugin.d.ts +20 -85
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/WebpackConfigurationLoader.d.ts +4 -16
- package/lib/WebpackConfigurationLoader.d.ts.map +1 -1
- package/lib/WebpackConfigurationLoader.js +47 -37
- package/lib/WebpackConfigurationLoader.js.map +1 -1
- package/lib/WebpackPlugin.d.ts +14 -0
- package/lib/WebpackPlugin.d.ts.map +1 -0
- package/lib/WebpackPlugin.js +266 -0
- package/lib/WebpackPlugin.js.map +1 -0
- package/lib/index.d.ts +7 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/lib/shared.d.ts +14 -77
- package/lib/shared.d.ts.map +1 -1
- package/lib/shared.js.map +1 -1
- package/package.json +12 -17
- package/heft-plugin.json +0 -20
- package/lib/DeferredWatchFileSystem.d.ts +0 -27
- package/lib/DeferredWatchFileSystem.d.ts.map +0 -1
- package/lib/DeferredWatchFileSystem.js +0 -151
- package/lib/DeferredWatchFileSystem.js.map +0 -1
- package/lib/Webpack5Plugin.d.ts +0 -37
- package/lib/Webpack5Plugin.d.ts.map +0 -1
- package/lib/Webpack5Plugin.js +0 -410
- package/lib/Webpack5Plugin.js.map +0 -1
- package/lib/schemas/heft-webpack5-plugin.schema.json +0 -25
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackPlugin.js","sourceRoot":"","sources":["../src/WebpackPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAUjC,oEAA6G;AAe7G,6EAA0E;AAE1E,MAAM,OAAO,GAA6B,0BAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CA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;gBAC9B,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;aAC7B;YAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACzB;SACF;IACH,CAAC;IAEO,eAAe,CAAC,WAAmB,EAAE,KAAwB;QACnE,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,OAAO,KAAK,CAAC;SACd;aAAM;YACL,IAAI,UAAU,GAAuB,KAAK,CAAC,UAAU,CAAC;YACtD,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,gBAAgB,EAAE;gBACzC,UAAU,GAAG,wBAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;aAC5F;YAED,IAAI,cAAsB,CAAC;YAC3B,IAAI,KAAK,CAAC,GAAG,IAAI,UAAU,EAAE;gBAC3B,cAAc,GAAG,GAAG,UAAU,IAAI,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;aAClE;iBAAM,IAAI,UAAU,EAAE;gBACrB,cAAc,GAAG,GAAG,UAAU,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;aACrD;iBAAM;gBACL,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC;aAChC;YAED,OAAO,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SAClC;IACH,CAAC;CACF;AAnSD,sCAmSC","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 nodePath from 'path';\nimport type {\n Compiler as WebpackCompiler,\n MultiCompiler as WebpackMultiCompiler,\n Stats as WebpackStats,\n MultiStats as WebpackMultiStats,\n StatsCompilation as WebpackStatsCompilation,\n StatsError as WebpackStatsError\n} from 'webpack';\nimport type TWebpackDevServer from 'webpack-dev-server';\nimport { LegacyAdapters, Path, Import, IPackageJson, PackageJsonLookup } from '@rushstack/node-core-library';\nimport type {\n HeftConfiguration,\n HeftSession,\n IBuildStageContext,\n IBuildStageProperties,\n IBundleSubstage,\n IHeftPlugin,\n ScopedLogger\n} from '@rushstack/heft';\nimport type {\n IWebpackConfiguration,\n IWebpackBundleSubstageProperties,\n IWebpackBuildStageProperties\n} from './shared';\nimport { WebpackConfigurationLoader } from './WebpackConfigurationLoader';\n\nconst webpack: typeof import('webpack') = Import.lazy('webpack', require);\n\nconst PLUGIN_NAME: string = 'WebpackPlugin';\nconst WEBPACK_DEV_SERVER_PACKAGE_NAME: string = 'webpack-dev-server';\nconst WEBPACK_DEV_SERVER_ENV_VAR_NAME: string = 'WEBPACK_DEV_SERVER';\n\ninterface IWebpackVersions {\n webpackVersion: string;\n webpackDevServerVersion: string;\n}\n\n/**\n * @internal\n */\nexport class WebpackPlugin implements IHeftPlugin {\n public readonly pluginName: string = PLUGIN_NAME;\n\n private static _webpackVersions: IWebpackVersions | undefined;\n private static _getWebpackVersions(): IWebpackVersions {\n if (!WebpackPlugin._webpackVersions) {\n const webpackDevServerPackageJsonPath: string = Import.resolveModule({\n modulePath: 'webpack-dev-server/package.json',\n baseFolderPath: __dirname\n });\n const webpackDevServerPackageJson: IPackageJson = PackageJsonLookup.instance.loadPackageJson(\n webpackDevServerPackageJsonPath\n );\n WebpackPlugin._webpackVersions = {\n webpackVersion: webpack.version!,\n webpackDevServerVersion: webpackDevServerPackageJson.version\n };\n }\n\n return WebpackPlugin._webpackVersions;\n }\n\n public apply(heftSession: HeftSession, heftConfiguration: HeftConfiguration): void {\n heftSession.hooks.build.tap(PLUGIN_NAME, (build: IBuildStageContext) => {\n build.hooks.bundle.tap(PLUGIN_NAME, (bundle: IBundleSubstage) => {\n bundle.hooks.configureWebpack.tap(\n { name: PLUGIN_NAME, stage: Number.MIN_SAFE_INTEGER },\n (webpackConfiguration: unknown) => {\n const webpackVersions: IWebpackVersions = WebpackPlugin._getWebpackVersions();\n bundle.properties.webpackVersion = webpack.version;\n bundle.properties.webpackDevServerVersion = webpackVersions.webpackDevServerVersion;\n\n return webpackConfiguration;\n }\n );\n\n bundle.hooks.configureWebpack.tapPromise(PLUGIN_NAME, async (existingConfiguration: unknown) => {\n const logger: ScopedLogger = heftSession.requestScopedLogger('configure-webpack');\n if (existingConfiguration) {\n logger.terminal.writeVerboseLine(\n 'Skipping loading webpack config file because the webpack config has already been set.'\n );\n return existingConfiguration;\n } else {\n return await WebpackConfigurationLoader.tryLoadWebpackConfigAsync(\n logger,\n heftConfiguration.buildFolder,\n build.properties\n );\n }\n });\n\n bundle.hooks.run.tapPromise(PLUGIN_NAME, async () => {\n await this._runWebpackAsync(\n heftSession,\n heftConfiguration,\n bundle.properties as IWebpackBundleSubstageProperties,\n build.properties,\n heftConfiguration.terminalProvider.supportsColor\n );\n });\n });\n });\n }\n\n private async _runWebpackAsync(\n heftSession: HeftSession,\n heftConfiguration: HeftConfiguration,\n bundleSubstageProperties: IWebpackBundleSubstageProperties,\n buildProperties: IBuildStageProperties,\n supportsColor: boolean\n ): Promise<void> {\n const webpackConfiguration: IWebpackConfiguration | undefined | null =\n bundleSubstageProperties.webpackConfiguration;\n if (!webpackConfiguration) {\n return;\n }\n\n const logger: ScopedLogger = heftSession.requestScopedLogger('webpack');\n const webpackVersions: IWebpackVersions = WebpackPlugin._getWebpackVersions();\n if (bundleSubstageProperties.webpackVersion !== webpackVersions.webpackVersion) {\n logger.emitError(\n new Error(\n `The Webpack plugin expected to be configured with Webpack version ${webpackVersions.webpackVersion}, ` +\n `but the configuration specifies version ${bundleSubstageProperties.webpackVersion}. ` +\n 'Are multiple versions of the Webpack plugin present?'\n )\n );\n }\n\n if (bundleSubstageProperties.webpackDevServerVersion !== webpackVersions.webpackDevServerVersion) {\n logger.emitError(\n new Error(\n `The Webpack plugin expected to be configured with webpack-dev-server version ${webpackVersions.webpackDevServerVersion}, ` +\n `but the configuration specifies version ${bundleSubstageProperties.webpackDevServerVersion}. ` +\n 'Are multiple versions of the Webpack plugin present?'\n )\n );\n }\n\n logger.terminal.writeLine(`Using Webpack version ${webpack.version}`);\n\n let compiler: WebpackCompiler | WebpackMultiCompiler;\n if (Array.isArray(webpackConfiguration)) {\n if (webpackConfiguration.length === 0) {\n logger.terminal.writeLine('The webpack configuration is an empty array - nothing to do.');\n return;\n } else {\n compiler = webpack(webpackConfiguration); /* (webpack.Compilation[]) => MultiCompiler */\n }\n } else {\n compiler = webpack(webpackConfiguration); /* (webpack.Compilation) => Compiler */\n }\n\n if (buildProperties.serveMode) {\n const defaultDevServerOptions: TWebpackDevServer.Configuration = {\n host: 'localhost',\n devMiddleware: {\n publicPath: '/',\n stats: {\n cached: false,\n cachedAssets: false,\n colors: supportsColor\n }\n },\n client: {\n logging: 'info',\n webSocketURL: {\n port: 8080\n }\n },\n port: 8080\n };\n\n let options: TWebpackDevServer.Configuration;\n if (Array.isArray(webpackConfiguration)) {\n const devServerOptions: TWebpackDevServer.Configuration[] = webpackConfiguration\n .map((configuration) => configuration.devServer)\n .filter((devServer): devServer is TWebpackDevServer.Configuration => !!devServer);\n if (devServerOptions.length > 1) {\n logger.emitWarning(\n new Error(`Detected multiple webpack devServer configurations, using the first one.`)\n );\n }\n\n if (devServerOptions.length > 0) {\n options = { ...defaultDevServerOptions, ...devServerOptions[0] };\n } else {\n options = defaultDevServerOptions;\n }\n } else {\n options = { ...defaultDevServerOptions, ...webpackConfiguration.devServer };\n }\n\n // Register a plugin to callback after webpack is done with the first compilation\n // so we can move on to post-build\n let firstCompilationDoneCallback: (() => void) | undefined;\n const originalBeforeCallback: typeof options.setupMiddlewares | undefined = options.setupMiddlewares;\n options.setupMiddlewares = (middlewares, devServer) => {\n compiler.hooks.done.tap('heft-webpack-plugin', () => {\n if (firstCompilationDoneCallback) {\n firstCompilationDoneCallback();\n firstCompilationDoneCallback = undefined;\n }\n });\n\n if (originalBeforeCallback) {\n return originalBeforeCallback(middlewares, devServer);\n }\n return middlewares;\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 require()\n // only if Heft is in serve mode.\n const WebpackDevServer: typeof TWebpackDevServer = require(WEBPACK_DEV_SERVER_PACKAGE_NAME);\n // TODO: the WebpackDevServer accepts a third parameter for a logger. We should make\n // use of that to make logging cleaner\n const webpackDevServer: TWebpackDevServer = new WebpackDevServer(options, compiler);\n\n await new Promise<void>((resolve: () => void, reject: (error: Error) => void) => {\n firstCompilationDoneCallback = resolve;\n\n // Wrap in promise.resolve due to small issue in the type declaration, return type should be\n // webpackDevServer.start(): Promise<void>;\n Promise.resolve(webpackDevServer.start()).catch(reject);\n });\n } else {\n if (process.env[WEBPACK_DEV_SERVER_ENV_VAR_NAME]) {\n 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 let stats: WebpackStats | WebpackMultiStats | undefined;\n if (buildProperties.watchMode) {\n try {\n stats = await LegacyAdapters.convertCallbackToPromise(\n (compiler as WebpackCompiler).watch.bind(compiler),\n {}\n );\n } catch (e) {\n logger.emitError(e as Error);\n }\n } else {\n try {\n stats = await LegacyAdapters.convertCallbackToPromise(\n (compiler as WebpackCompiler).run.bind(compiler)\n );\n await LegacyAdapters.convertCallbackToPromise(compiler.close.bind(compiler));\n } catch (e) {\n logger.emitError(e as Error);\n }\n }\n\n if (stats) {\n // eslint-disable-next-line require-atomic-updates\n (buildProperties as IWebpackBuildStageProperties).webpackStats = stats;\n\n this._emitErrors(logger, heftConfiguration.buildFolder, stats);\n }\n }\n }\n\n private _emitErrors(\n logger: ScopedLogger,\n buildFolder: string,\n stats: WebpackStats | WebpackMultiStats\n ): void {\n if (stats.hasErrors() || stats.hasWarnings()) {\n const serializedStats: WebpackStatsCompilation[] = [stats.toJson('errors-warnings')];\n\n const errors: Error[] = [];\n const warnings: Error[] = [];\n\n for (const compilationStats of serializedStats) {\n if (compilationStats.warnings) {\n for (const warning of compilationStats.warnings) {\n warnings.push(this._normalizeError(buildFolder, warning));\n }\n }\n\n if (compilationStats.errors) {\n for (const error of compilationStats.errors) {\n errors.push(this._normalizeError(buildFolder, error));\n }\n }\n\n if (compilationStats.children) {\n for (const child of compilationStats.children) {\n serializedStats.push(child);\n }\n }\n }\n\n for (const warning of warnings) {\n logger.emitWarning(warning);\n }\n\n for (const error of errors) {\n logger.emitError(error);\n }\n }\n }\n\n private _normalizeError(buildFolder: string, error: WebpackStatsError): Error {\n if (error instanceof Error) {\n return error;\n } else {\n let moduleName: string | undefined = error.moduleName;\n if (!moduleName && error.moduleIdentifier) {\n moduleName = Path.convertToSlashes(nodePath.relative(buildFolder, error.moduleIdentifier));\n }\n\n let formattedError: string;\n if (error.loc && moduleName) {\n formattedError = `${moduleName}:${error.loc} - ${error.message}`;\n } else if (moduleName) {\n formattedError = `${moduleName} - ${error.message}`;\n } else {\n formattedError = error.message;\n }\n\n return new Error(formattedError);\n }\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import type { IHeftPlugin } from '@rushstack/heft';
|
|
2
|
+
export { IWebpackConfigurationWithDevServer, IWebpackConfiguration, IWebpackBuildStageProperties, IWebpackBundleSubstageProperties } from './shared';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: IHeftPlugin<void>;
|
|
7
|
+
export default _default;
|
|
3
8
|
//# 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,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,EACL,kCAAkC,EAClC,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAElB;;GAEG;;AACH,wBAAkD"}
|
package/lib/index.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const WebpackPlugin_1 = require("./WebpackPlugin");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
exports.default = new WebpackPlugin_1.WebpackPlugin();
|
|
8
10
|
//# 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;;AAI3D,mDAAgD;AAShD;;GAEG;AACH,kBAAe,IAAI,6BAAa,EAAiB,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 type { IHeftPlugin } from '@rushstack/heft';\n\nimport { WebpackPlugin } from './WebpackPlugin';\n\nexport {\n IWebpackConfigurationWithDevServer,\n IWebpackConfiguration,\n IWebpackBuildStageProperties,\n IWebpackBundleSubstageProperties\n} from './shared';\n\n/**\n * @public\n */\nexport default new WebpackPlugin() as IHeftPlugin;\n"]}
|
package/lib/shared.d.ts
CHANGED
|
@@ -1,99 +1,36 @@
|
|
|
1
|
-
import type * as TWebpack from 'webpack';
|
|
2
1
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
2
|
+
import type * as webpack from 'webpack';
|
|
3
|
+
import type { IBuildStageProperties, IBundleSubstageProperties } from '@rushstack/heft';
|
|
5
4
|
/**
|
|
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
|
-
*
|
|
10
5
|
* @public
|
|
11
6
|
*/
|
|
12
|
-
export interface
|
|
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 {
|
|
7
|
+
export interface IWebpackConfigurationWithDevServer extends webpack.Configuration {
|
|
40
8
|
devServer?: WebpackDevServerConfiguration;
|
|
41
9
|
}
|
|
42
10
|
/**
|
|
43
11
|
* @public
|
|
44
12
|
*/
|
|
45
|
-
export declare type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[];
|
|
13
|
+
export declare type IWebpackConfiguration = IWebpackConfigurationWithDevServer | IWebpackConfigurationWithDevServer[] | undefined;
|
|
46
14
|
/**
|
|
47
15
|
* @public
|
|
48
16
|
*/
|
|
49
|
-
export interface
|
|
17
|
+
export interface IWebpackBundleSubstageProperties extends IBundleSubstageProperties {
|
|
50
18
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* with the exports of the
|
|
54
|
-
*
|
|
19
|
+
* The configuration used by the Webpack plugin. This must be populated
|
|
20
|
+
* for Webpack to run. If webpackConfigFilePath is specified,
|
|
21
|
+
* this will be populated automatically with the exports of the
|
|
22
|
+
* config file referenced in that property.
|
|
55
23
|
*
|
|
56
24
|
* @remarks
|
|
57
|
-
* Tapable event handlers can return `
|
|
58
|
-
* other handlers from creating a configuration object
|
|
59
|
-
*/
|
|
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.
|
|
25
|
+
* Tapable event handlers can return `null` instead of `undefined` to suppress
|
|
26
|
+
* other handlers from creating a configuration object.
|
|
74
27
|
*/
|
|
75
|
-
|
|
28
|
+
webpackConfiguration?: webpack.Configuration | webpack.Configuration[] | null;
|
|
76
29
|
}
|
|
77
30
|
/**
|
|
78
31
|
* @public
|
|
79
32
|
*/
|
|
80
|
-
export interface
|
|
81
|
-
|
|
82
|
-
* Whether or not serve mode was enabled by passing the `--serve` flag.
|
|
83
|
-
*/
|
|
84
|
-
readonly isServeMode: boolean;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
export interface IWebpackPluginAccessor {
|
|
90
|
-
/**
|
|
91
|
-
* Hooks that are called at various points in the Webpack plugin lifecycle.
|
|
92
|
-
*/
|
|
93
|
-
readonly hooks: IWebpackPluginAccessorHooks;
|
|
94
|
-
/**
|
|
95
|
-
* Parameters that are provided by the Webpack plugin.
|
|
96
|
-
*/
|
|
97
|
-
readonly parameters: IWebpackPluginAccessorParameters;
|
|
33
|
+
export interface IWebpackBuildStageProperties extends IBuildStageProperties {
|
|
34
|
+
webpackStats?: webpack.Stats | webpack.MultiStats;
|
|
98
35
|
}
|
|
99
36
|
//# 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,
|
|
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,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,OAAO,CAAC,aAAa;IAC/E,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC3C;AAED;;GAEG;AACH,oBAAY,qBAAqB,GAC7B,kCAAkC,GAClC,kCAAkC,EAAE,GACpC,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IACjF;;;;;;;;;OASG;IAGH,oBAAoB,CAAC,EAAE,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,YAAY,CAAC,EAAE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC;CACnD"}
|
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
|
|
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 * as webpack from 'webpack';\nimport type { IBuildStageProperties, IBundleSubstageProperties } from '@rushstack/heft';\n\n/**\n * @public\n */\nexport interface IWebpackConfigurationWithDevServer extends webpack.Configuration {\n devServer?: WebpackDevServerConfiguration;\n}\n\n/**\n * @public\n */\nexport type IWebpackConfiguration =\n | IWebpackConfigurationWithDevServer\n | IWebpackConfigurationWithDevServer[]\n | undefined;\n\n/**\n * @public\n */\nexport interface IWebpackBundleSubstageProperties extends IBundleSubstageProperties {\n /**\n * The configuration used by the Webpack plugin. This must be populated\n * for Webpack to run. If webpackConfigFilePath is specified,\n * this will be populated automatically with the exports of the\n * config file referenced in that property.\n *\n * @remarks\n * Tapable event handlers can return `null` instead of `undefined` to suppress\n * other handlers from creating a configuration object.\n */\n // We are inheriting this problem from Tapable's API\n // eslint-disable-next-line @rushstack/no-new-null\n webpackConfiguration?: webpack.Configuration | webpack.Configuration[] | null;\n}\n\n/**\n * @public\n */\nexport interface IWebpackBuildStageProperties extends IBuildStageProperties {\n webpackStats?: webpack.Stats | webpack.MultiStats;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-webpack5-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Heft plugin for Webpack 5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,29 +12,24 @@
|
|
|
12
12
|
"types": "dist/heft-webpack5-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.50.0
|
|
16
|
-
"webpack": "~5.
|
|
15
|
+
"@rushstack/heft": "^0.50.0",
|
|
16
|
+
"webpack": "~5.75.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"
|
|
20
|
-
"@rushstack/node-core-library": "3.
|
|
21
|
-
"@types/tapable": "1.0.6",
|
|
22
|
-
"tapable": "1.1.3",
|
|
23
|
-
"watchpack": "2.4.0",
|
|
24
|
-
"webpack-dev-server": "~4.9.3"
|
|
19
|
+
"webpack-dev-server": "~4.9.3",
|
|
20
|
+
"@rushstack/node-core-library": "3.55.2"
|
|
25
21
|
},
|
|
26
22
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"@rushstack/
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"webpack": "~5.68.0"
|
|
23
|
+
"@types/node": "14.18.36",
|
|
24
|
+
"webpack": "~5.75.0",
|
|
25
|
+
"@rushstack/eslint-config": "3.2.0",
|
|
26
|
+
"@rushstack/heft": "0.50.0",
|
|
27
|
+
"@rushstack/heft-node-rig": "1.12.5"
|
|
33
28
|
},
|
|
34
29
|
"scripts": {
|
|
35
30
|
"build": "heft build --clean",
|
|
36
31
|
"start": "heft test --clean --watch",
|
|
37
|
-
"_phase:build": "heft
|
|
38
|
-
"_phase:test": "heft
|
|
32
|
+
"_phase:build": "heft build --clean",
|
|
33
|
+
"_phase:test": "heft test --no-build"
|
|
39
34
|
}
|
|
40
35
|
}
|
package/heft-plugin.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://developer.microsoft.com/json-schemas/heft/heft-plugin.schema.json",
|
|
3
|
-
|
|
4
|
-
"taskPlugins": [
|
|
5
|
-
{
|
|
6
|
-
"pluginName": "webpack5-plugin",
|
|
7
|
-
"entryPoint": "./lib/Webpack5Plugin",
|
|
8
|
-
"optionsSchema": "./lib/schemas/heft-webpack5-plugin.schema.json",
|
|
9
|
-
|
|
10
|
-
"parameterScope": "webpack5",
|
|
11
|
-
"parameters": [
|
|
12
|
-
{
|
|
13
|
-
"longName": "--serve",
|
|
14
|
-
"parameterKind": "flag",
|
|
15
|
-
"description": "Start a local web server for testing purposes using webpack-dev-server. This parameter is only available when running in watch mode."
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Watchpack, { type WatchOptions } from 'watchpack';
|
|
2
|
-
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
|
3
|
-
export declare type InputFileSystem = Compiler['inputFileSystem'];
|
|
4
|
-
export declare type WatchFileSystem = Compiler['watchFileSystem'];
|
|
5
|
-
export declare type WatchCallback = Parameters<WatchFileSystem['watch']>[5];
|
|
6
|
-
export declare type WatchUndelayedCallback = Parameters<WatchFileSystem['watch']>[6];
|
|
7
|
-
export declare type Watcher = ReturnType<WatchFileSystem['watch']>;
|
|
8
|
-
export declare type WatcherInfo = ReturnType<Required<Watcher>['getInfo']>;
|
|
9
|
-
export declare class DeferredWatchFileSystem implements WatchFileSystem {
|
|
10
|
-
readonly inputFileSystem: InputFileSystem;
|
|
11
|
-
readonly watcherOptions: WatchOptions;
|
|
12
|
-
watcher: Watchpack | undefined;
|
|
13
|
-
private readonly _onChange;
|
|
14
|
-
private _state;
|
|
15
|
-
constructor(inputFileSystem: InputFileSystem, onChange: () => void);
|
|
16
|
-
flush(): boolean;
|
|
17
|
-
watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: WatchOptions, callback: WatchCallback, callbackUndelayed: WatchUndelayedCallback): Watcher;
|
|
18
|
-
private _fetchTimeInfo;
|
|
19
|
-
private _purge;
|
|
20
|
-
}
|
|
21
|
-
export declare class OverrideNodeWatchFSPlugin implements WebpackPluginInstance {
|
|
22
|
-
readonly fileSystems: Set<DeferredWatchFileSystem>;
|
|
23
|
-
private readonly _onChange;
|
|
24
|
-
constructor(onChange: () => void);
|
|
25
|
-
apply(compiler: Compiler): void;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=DeferredWatchFileSystem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredWatchFileSystem.d.ts","sourceRoot":"","sources":["../src/DeferredWatchFileSystem.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/D,oBAAY,eAAe,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAC1D,oBAAY,eAAe,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAC1D,oBAAY,aAAa,GAAG,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,oBAAY,sBAAsB,GAAG,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,oBAAY,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,oBAAY,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAsBnE,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,SAAgB,eAAe,EAAE,eAAe,CAAC;IACjD,SAAgB,cAAc,EAAE,YAAY,CAAC;IACtC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAEtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,MAAM,CAA0B;gBAErB,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,IAAI;IASlE,KAAK,IAAI,OAAO;IA0ChB,KAAK,CACV,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC7B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,EACzB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,aAAa,EACvB,iBAAiB,EAAE,sBAAsB,GACxC,OAAO;IAyEV,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,MAAM;CAef;AAED,qBAAa,yBAA0B,YAAW,qBAAqB;IACrE,SAAgB,WAAW,EAAE,GAAG,CAAC,uBAAuB,CAAC,CAAa;IACtE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;gBAEpB,QAAQ,EAAE,MAAM,IAAI;IAIhC,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAQvC"}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
-
// See LICENSE in the project root for license information.
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.OverrideNodeWatchFSPlugin = exports.DeferredWatchFileSystem = void 0;
|
|
9
|
-
const watchpack_1 = __importDefault(require("watchpack"));
|
|
10
|
-
class DeferredWatchFileSystem {
|
|
11
|
-
constructor(inputFileSystem, onChange) {
|
|
12
|
-
this.inputFileSystem = inputFileSystem;
|
|
13
|
-
this.watcherOptions = {
|
|
14
|
-
aggregateTimeout: 0
|
|
15
|
-
};
|
|
16
|
-
this.watcher = new watchpack_1.default(this.watcherOptions);
|
|
17
|
-
this._onChange = onChange;
|
|
18
|
-
}
|
|
19
|
-
flush() {
|
|
20
|
-
const state = this._state;
|
|
21
|
-
if (!state) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
const { changes, removals, callback } = state;
|
|
25
|
-
// Force flush the aggregation callback
|
|
26
|
-
const { changes: newChanges, removals: newRemovals } = this.watcher.getAggregated();
|
|
27
|
-
// Webpack 5 treats changes and removals as separate things
|
|
28
|
-
if (newRemovals) {
|
|
29
|
-
for (const removal of newRemovals) {
|
|
30
|
-
changes.delete(removal);
|
|
31
|
-
removals.add(removal);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (newChanges) {
|
|
35
|
-
for (const change of newChanges) {
|
|
36
|
-
removals.delete(change);
|
|
37
|
-
changes.add(change);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (changes.size > 0 || removals.size > 0) {
|
|
41
|
-
this._purge(removals, changes);
|
|
42
|
-
const { fileTimeInfoEntries, contextTimeInfoEntries } = this._fetchTimeInfo();
|
|
43
|
-
callback(undefined, fileTimeInfoEntries, contextTimeInfoEntries, changes, removals);
|
|
44
|
-
changes.clear();
|
|
45
|
-
removals.clear();
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
watch(files, directories, missing, startTime, options, callback, callbackUndelayed) {
|
|
51
|
-
const oldWatcher = this.watcher;
|
|
52
|
-
this.watcher = new watchpack_1.default(options);
|
|
53
|
-
const changes = new Set();
|
|
54
|
-
const removals = new Set();
|
|
55
|
-
this._state = {
|
|
56
|
-
changes,
|
|
57
|
-
removals,
|
|
58
|
-
callback
|
|
59
|
-
};
|
|
60
|
-
this.watcher.on('aggregated', (newChanges, newRemovals) => {
|
|
61
|
-
for (const change of newChanges) {
|
|
62
|
-
removals.delete(change);
|
|
63
|
-
changes.add(change);
|
|
64
|
-
}
|
|
65
|
-
for (const removal of newRemovals) {
|
|
66
|
-
changes.delete(removal);
|
|
67
|
-
removals.add(removal);
|
|
68
|
-
}
|
|
69
|
-
this._onChange();
|
|
70
|
-
});
|
|
71
|
-
this.watcher.watch({
|
|
72
|
-
files,
|
|
73
|
-
directories,
|
|
74
|
-
missing,
|
|
75
|
-
startTime
|
|
76
|
-
});
|
|
77
|
-
if (oldWatcher) {
|
|
78
|
-
oldWatcher.close();
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
close: () => {
|
|
82
|
-
if (this.watcher) {
|
|
83
|
-
this.watcher.close();
|
|
84
|
-
this.watcher = undefined;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
pause: () => {
|
|
88
|
-
if (this.watcher) {
|
|
89
|
-
this.watcher.pause();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
getInfo: () => {
|
|
93
|
-
var _a, _b;
|
|
94
|
-
const newRemovals = (_a = this.watcher) === null || _a === void 0 ? void 0 : _a.aggregatedRemovals;
|
|
95
|
-
const newChanges = (_b = this.watcher) === null || _b === void 0 ? void 0 : _b.aggregatedChanges;
|
|
96
|
-
this._purge(newRemovals, newChanges);
|
|
97
|
-
const { fileTimeInfoEntries, contextTimeInfoEntries } = this._fetchTimeInfo();
|
|
98
|
-
return {
|
|
99
|
-
changes: newChanges,
|
|
100
|
-
removals: newRemovals,
|
|
101
|
-
fileTimeInfoEntries,
|
|
102
|
-
contextTimeInfoEntries
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
getContextTimeInfoEntries: () => {
|
|
106
|
-
const { contextTimeInfoEntries } = this._fetchTimeInfo();
|
|
107
|
-
return contextTimeInfoEntries;
|
|
108
|
-
},
|
|
109
|
-
getFileTimeInfoEntries: () => {
|
|
110
|
-
const { fileTimeInfoEntries } = this._fetchTimeInfo();
|
|
111
|
-
return fileTimeInfoEntries;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
_fetchTimeInfo() {
|
|
116
|
-
var _a;
|
|
117
|
-
const fileTimeInfoEntries = new Map();
|
|
118
|
-
const contextTimeInfoEntries = new Map();
|
|
119
|
-
(_a = this.watcher) === null || _a === void 0 ? void 0 : _a.collectTimeInfoEntries(fileTimeInfoEntries, contextTimeInfoEntries);
|
|
120
|
-
return { fileTimeInfoEntries, contextTimeInfoEntries };
|
|
121
|
-
}
|
|
122
|
-
_purge(removals, changes) {
|
|
123
|
-
const fs = this.inputFileSystem;
|
|
124
|
-
if (fs.purge) {
|
|
125
|
-
if (removals) {
|
|
126
|
-
for (const removal of removals) {
|
|
127
|
-
fs.purge(removal);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (changes) {
|
|
131
|
-
for (const change of changes) {
|
|
132
|
-
fs.purge(change);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.DeferredWatchFileSystem = DeferredWatchFileSystem;
|
|
139
|
-
class OverrideNodeWatchFSPlugin {
|
|
140
|
-
constructor(onChange) {
|
|
141
|
-
this.fileSystems = new Set();
|
|
142
|
-
this._onChange = onChange;
|
|
143
|
-
}
|
|
144
|
-
apply(compiler) {
|
|
145
|
-
const watchFileSystem = new DeferredWatchFileSystem(compiler.inputFileSystem, this._onChange);
|
|
146
|
-
this.fileSystems.add(watchFileSystem);
|
|
147
|
-
compiler.watchFileSystem = watchFileSystem;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.OverrideNodeWatchFSPlugin = OverrideNodeWatchFSPlugin;
|
|
151
|
-
//# sourceMappingURL=DeferredWatchFileSystem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredWatchFileSystem.js","sourceRoot":"","sources":["../src/DeferredWatchFileSystem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,0DAAyD;AA8BzD,MAAa,uBAAuB;IAQlC,YAAmB,eAAgC,EAAE,QAAoB;QACvE,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG;YACpB,gBAAgB,EAAE,CAAC;SACpB,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,KAAK;QACV,MAAM,KAAK,GAA4B,IAAI,CAAC,MAAM,CAAC;QAEnD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,KAAK,CAAC;SACd;QAED,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;QAE9C,uCAAuC;QACvC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAQ,CAAC,aAAa,EAAE,CAAC;QAErF,2DAA2D;QAC3D,IAAI,WAAW,EAAE;YACf,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE;gBACjC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACxB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;aACvB;SACF;QACD,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE;gBAC/B,QAAQ,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G,eAAe,CAAC;IAC7C,CAAC;CACF;AAhBD,8DAgBC","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 Watchpack, { type WatchOptions } from 'watchpack';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\n\nexport type InputFileSystem = Compiler['inputFileSystem'];\nexport type WatchFileSystem = Compiler['watchFileSystem'];\nexport type WatchCallback = Parameters<WatchFileSystem['watch']>[5];\nexport type WatchUndelayedCallback = Parameters<WatchFileSystem['watch']>[6];\nexport type Watcher = ReturnType<WatchFileSystem['watch']>;\nexport type WatcherInfo = ReturnType<Required<Watcher>['getInfo']>;\ntype FileSystemMap = ReturnType<Watcher['getFileTimeInfoEntries']>;\n\ninterface IWatchState {\n changes: Set<string>;\n removals: Set<string>;\n\n callback: WatchCallback;\n}\n\ninterface ITimeEntry {\n timestamp: number;\n safeTime: number;\n}\n\ntype IRawFileSystemMap = Map<string, ITimeEntry>;\n\ninterface ITimeInfoEntries {\n fileTimeInfoEntries: FileSystemMap;\n contextTimeInfoEntries: FileSystemMap;\n}\n\nexport class DeferredWatchFileSystem implements WatchFileSystem {\n public readonly inputFileSystem: InputFileSystem;\n public readonly watcherOptions: WatchOptions;\n public watcher: Watchpack | undefined;\n\n private readonly _onChange: () => void;\n private _state: IWatchState | undefined;\n\n public constructor(inputFileSystem: InputFileSystem, onChange: () => void) {\n this.inputFileSystem = inputFileSystem;\n this.watcherOptions = {\n aggregateTimeout: 0\n };\n this.watcher = new Watchpack(this.watcherOptions);\n this._onChange = onChange;\n }\n\n public flush(): boolean {\n const state: IWatchState | undefined = this._state;\n\n if (!state) {\n return false;\n }\n\n const { changes, removals, callback } = state;\n\n // Force flush the aggregation callback\n const { changes: newChanges, removals: newRemovals } = this.watcher!.getAggregated();\n\n // Webpack 5 treats changes and removals as separate things\n if (newRemovals) {\n for (const removal of newRemovals) {\n changes.delete(removal);\n removals.add(removal);\n }\n }\n if (newChanges) {\n for (const change of newChanges) {\n removals.delete(change);\n changes.add(change);\n }\n }\n\n if (changes.size > 0 || removals.size > 0) {\n this._purge(removals, changes);\n\n const { fileTimeInfoEntries, contextTimeInfoEntries } = this._fetchTimeInfo();\n\n callback(undefined, fileTimeInfoEntries, contextTimeInfoEntries, changes, removals);\n\n changes.clear();\n removals.clear();\n\n return true;\n }\n\n return false;\n }\n\n public watch(\n files: Iterable<string>,\n directories: Iterable<string>,\n missing: Iterable<string>,\n startTime: number,\n options: WatchOptions,\n callback: WatchCallback,\n callbackUndelayed: WatchUndelayedCallback\n ): Watcher {\n const oldWatcher: Watchpack | undefined = this.watcher;\n this.watcher = new Watchpack(options);\n\n const changes: Set<string> = new Set();\n const removals: Set<string> = new Set();\n\n this._state = {\n changes,\n removals,\n\n callback\n };\n\n this.watcher.on('aggregated', (newChanges: Set<string>, newRemovals: Set<string>) => {\n for (const change of newChanges) {\n removals.delete(change);\n changes.add(change);\n }\n for (const removal of newRemovals) {\n changes.delete(removal);\n removals.add(removal);\n }\n\n this._onChange();\n });\n\n this.watcher.watch({\n files,\n directories,\n missing,\n startTime\n });\n\n if (oldWatcher) {\n oldWatcher.close();\n }\n\n return {\n close: () => {\n if (this.watcher) {\n this.watcher.close();\n this.watcher = undefined;\n }\n },\n pause: () => {\n if (this.watcher) {\n this.watcher.pause();\n }\n },\n getInfo: () => {\n const newRemovals: Set<string> | undefined = this.watcher?.aggregatedRemovals;\n const newChanges: Set<string> | undefined = this.watcher?.aggregatedChanges;\n this._purge(newRemovals, newChanges);\n const { fileTimeInfoEntries, contextTimeInfoEntries } = this._fetchTimeInfo();\n return {\n changes: newChanges!,\n removals: newRemovals!,\n fileTimeInfoEntries,\n contextTimeInfoEntries\n };\n },\n getContextTimeInfoEntries: () => {\n const { contextTimeInfoEntries } = this._fetchTimeInfo();\n return contextTimeInfoEntries;\n },\n getFileTimeInfoEntries: () => {\n const { fileTimeInfoEntries } = this._fetchTimeInfo();\n return fileTimeInfoEntries;\n }\n };\n }\n\n private _fetchTimeInfo(): ITimeInfoEntries {\n const fileTimeInfoEntries: IRawFileSystemMap = new Map();\n const contextTimeInfoEntries: IRawFileSystemMap = new Map();\n this.watcher?.collectTimeInfoEntries(fileTimeInfoEntries, contextTimeInfoEntries);\n return { fileTimeInfoEntries, contextTimeInfoEntries };\n }\n\n private _purge(removals: Set<string> | undefined, changes: Set<string> | undefined): void {\n const fs: InputFileSystem = this.inputFileSystem;\n if (fs.purge) {\n if (removals) {\n for (const removal of removals) {\n fs.purge(removal);\n }\n }\n if (changes) {\n for (const change of changes) {\n fs.purge(change);\n }\n }\n }\n }\n}\n\nexport class OverrideNodeWatchFSPlugin implements WebpackPluginInstance {\n public readonly fileSystems: Set<DeferredWatchFileSystem> = new Set();\n private readonly _onChange: () => void;\n\n public constructor(onChange: () => void) {\n this._onChange = onChange;\n }\n\n public apply(compiler: Compiler): void {\n const watchFileSystem: DeferredWatchFileSystem = new DeferredWatchFileSystem(\n compiler.inputFileSystem,\n this._onChange\n );\n this.fileSystems.add(watchFileSystem);\n compiler.watchFileSystem = watchFileSystem;\n }\n}\n"]}
|
package/lib/Webpack5Plugin.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { HeftConfiguration, IHeftTaskSession, IHeftTaskPlugin } from '@rushstack/heft';
|
|
2
|
-
import type { IWebpackPluginAccessor } from './shared';
|
|
3
|
-
export interface IWebpackPluginOptions {
|
|
4
|
-
devConfigurationPath: string | undefined;
|
|
5
|
-
configurationPath: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare const PLUGIN_NAME: 'webpack5-plugin';
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export default class Webpack5Plugin implements IHeftTaskPlugin<IWebpackPluginOptions> {
|
|
15
|
-
private _accessor;
|
|
16
|
-
private _isServeMode;
|
|
17
|
-
private _webpack;
|
|
18
|
-
private _webpackCompiler;
|
|
19
|
-
private _webpackConfiguration;
|
|
20
|
-
private _webpackCompilationDonePromise;
|
|
21
|
-
private _webpackCompilationDonePromiseResolveFn;
|
|
22
|
-
private _watchFileSystems;
|
|
23
|
-
private _warnings;
|
|
24
|
-
private _errors;
|
|
25
|
-
get accessor(): IWebpackPluginAccessor;
|
|
26
|
-
apply(taskSession: IHeftTaskSession, heftConfiguration: HeftConfiguration, options: IWebpackPluginOptions): void;
|
|
27
|
-
private _getWebpackConfigurationAsync;
|
|
28
|
-
private _loadWebpackAsync;
|
|
29
|
-
private _getWebpackCompilerAsync;
|
|
30
|
-
private _runWebpackAsync;
|
|
31
|
-
private _runWebpackWatchAsync;
|
|
32
|
-
private _validateEnvironmentVariable;
|
|
33
|
-
private _emitErrors;
|
|
34
|
-
private _recordErrors;
|
|
35
|
-
private _normalizeError;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=Webpack5Plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Webpack5Plugin.d.ts","sourceRoot":"","sources":["../src/Webpack5Plugin.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAyB,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAI9E,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,iBAAqC,CAAC;AAQhE;;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,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