@rushstack/webpack5-localization-plugin 0.7.3 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+
1
3
  import type { Chunk } from 'webpack';
2
4
  import type { Compiler } from 'webpack';
3
5
  import { ILocalizationFile } from '@rushstack/localization-utilities';
@@ -238,6 +240,20 @@ export declare interface _IStringPlaceholder {
238
240
  stringName: string;
239
241
  }
240
242
 
243
+ /**
244
+ * @public
245
+ */
246
+ export declare interface ITrueHashPluginOptions {
247
+ /**
248
+ * A function that takes the contents of a file and returns a hash.
249
+ */
250
+ hashFunction?: (contents: string | Buffer) => string;
251
+ /**
252
+ * Optionally override the process assets stage for this plugin.
253
+ */
254
+ stageOverride?: number;
255
+ }
256
+
241
257
  /**
242
258
  * This plugin facilitates localization in webpack.
243
259
  *
@@ -288,4 +304,13 @@ export declare class LocalizationPlugin implements WebpackPluginInstance {
288
304
  private _initializeAndValidateOptions;
289
305
  }
290
306
 
307
+ /**
308
+ * @public
309
+ */
310
+ export declare class TrueHashPlugin implements WebpackPluginInstance {
311
+ private readonly _options;
312
+ constructor(options?: ITrueHashPluginOptions);
313
+ apply(compiler: Compiler): void;
314
+ }
315
+
291
316
  export { }
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
3
+ /**
4
+ * @public
5
+ */
6
+ export interface ITrueHashPluginOptions {
7
+ /**
8
+ * A function that takes the contents of a file and returns a hash.
9
+ */
10
+ hashFunction?: (contents: string | Buffer) => string;
11
+ /**
12
+ * Optionally override the process assets stage for this plugin.
13
+ */
14
+ stageOverride?: number;
15
+ }
16
+ /**
17
+ * @public
18
+ */
19
+ export declare class TrueHashPlugin implements WebpackPluginInstance {
20
+ private readonly _options;
21
+ constructor(options?: ITrueHashPluginOptions);
22
+ apply(compiler: Compiler): void;
23
+ }
24
+ //# sourceMappingURL=TrueHashPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrueHashPlugin.d.ts","sourceRoot":"","sources":["../src/TrueHashPlugin.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAe,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAM5E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAErD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAE/B,OAAO,GAAE,sBAA2B;IAIhD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAqBvC"}
@@ -0,0 +1,31 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.TrueHashPlugin = void 0;
6
+ const trueHashes_1 = require("./trueHashes");
7
+ const PLUGIN_NAME = 'true-hash';
8
+ /**
9
+ * @public
10
+ */
11
+ class TrueHashPlugin {
12
+ constructor(options = {}) {
13
+ this._options = options;
14
+ }
15
+ apply(compiler) {
16
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
17
+ const { webpack: thisWebpack } = compiler;
18
+ const { hashFunction, stageOverride = thisWebpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE } = this._options;
19
+ const hashFn = hashFunction !== null && hashFunction !== void 0 ? hashFunction : (0, trueHashes_1.getHashFunction)({
20
+ thisWebpack,
21
+ compilation
22
+ });
23
+ compilation.hooks.processAssets.tap({
24
+ name: PLUGIN_NAME,
25
+ stage: stageOverride
26
+ }, () => (0, trueHashes_1.updateAssetHashes)({ thisWebpack, compilation, hashFn }));
27
+ });
28
+ }
29
+ }
30
+ exports.TrueHashPlugin = TrueHashPlugin;
31
+ //# sourceMappingURL=TrueHashPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrueHashPlugin.js","sourceRoot":"","sources":["../src/TrueHashPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,6CAA+E;AAE/E,MAAM,WAAW,GAAgB,WAAW,CAAC;AAiB7C;;GAEG;AACH,MAAa,cAAc;IAGzB,YAAmB,UAAkC,EAAE;QACrD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,QAAkB;QAC7B,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,WAAwB,EAAE,EAAE;YAC3E,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;YAC1C,MAAM,EAAE,YAAY,EAAE,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,8BAA8B,EAAE,GAC5F,IAAI,CAAC,QAAQ,CAAC;YAChB,MAAM,MAAM,GACV,YAAY,aAAZ,YAAY,cAAZ,YAAY,GACZ,IAAA,4BAAe,EAAC;gBACd,WAAW;gBACX,WAAW;aACZ,CAAC,CAAC;YAEL,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;gBACE,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,aAAa;aACrB,EACD,GAAG,EAAE,CAAC,IAAA,8BAAiB,EAAC,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAC9D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,wCA4BC","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 { Compilation, Compiler, WebpackPluginInstance } from 'webpack';\n\nimport { type HashFn, getHashFunction, updateAssetHashes } from './trueHashes';\n\nconst PLUGIN_NAME: 'true-hash' = 'true-hash';\n\n/**\n * @public\n */\nexport interface ITrueHashPluginOptions {\n /**\n * A function that takes the contents of a file and returns a hash.\n */\n hashFunction?: (contents: string | Buffer) => string;\n\n /**\n * Optionally override the process assets stage for this plugin.\n */\n stageOverride?: number;\n}\n\n/**\n * @public\n */\nexport class TrueHashPlugin implements WebpackPluginInstance {\n private readonly _options: ITrueHashPluginOptions;\n\n public constructor(options: ITrueHashPluginOptions = {}) {\n this._options = options;\n }\n\n public apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n const { webpack: thisWebpack } = compiler;\n const { hashFunction, stageOverride = thisWebpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE } =\n this._options;\n const hashFn: HashFn =\n hashFunction ??\n getHashFunction({\n thisWebpack,\n compilation\n });\n\n compilation.hooks.processAssets.tap(\n {\n name: PLUGIN_NAME,\n stage: stageOverride\n },\n () => updateAssetHashes({ thisWebpack, compilation, hashFn })\n );\n });\n }\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';
2
+ export { TrueHashPlugin, type ITrueHashPluginOptions } from './TrueHashPlugin';
2
3
  export { IDefaultLocaleOptions, ILocaleData, ILocaleElementMap, ILocaleFileData, ILocaleFileObject, ILocalizationPluginOptions, ILocalizationStats, ILocalizationStatsChunkGroup, ILocalizationStatsEntrypoint, ILocalizationStatsOptions, ILocalizedData, ILocalizedStrings, IPassthroughLocaleOptions, IPseudolocalesOptions, IResolvedMissingTranslations } from './interfaces';
3
4
  export { ILocalizedWebpackChunk } from './webpackInterfaces';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE1G,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
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
- exports.LocalizationPlugin = void 0;
5
+ exports.TrueHashPlugin = exports.LocalizationPlugin = void 0;
6
6
  var LocalizationPlugin_1 = require("./LocalizationPlugin");
7
7
  Object.defineProperty(exports, "LocalizationPlugin", { enumerable: true, get: function () { return LocalizationPlugin_1.LocalizationPlugin; } });
8
+ var TrueHashPlugin_1 = require("./TrueHashPlugin");
9
+ Object.defineProperty(exports, "TrueHashPlugin", { enumerable: true, get: function () { return TrueHashPlugin_1.TrueHashPlugin; } });
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;;;AAE3D,2DAA0G;AAAjG,wHAAA,kBAAkB,OAAA","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 { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\n\nexport {\n IDefaultLocaleOptions,\n ILocaleData,\n ILocaleElementMap,\n ILocaleFileData,\n ILocaleFileObject,\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations\n} from './interfaces';\n\nexport { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAA0G;AAAjG,wHAAA,kBAAkB,OAAA;AAC3B,mDAA+E;AAAtE,gHAAA,cAAc,OAAA","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 { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\nexport { TrueHashPlugin, type ITrueHashPluginOptions } from './TrueHashPlugin';\n\nexport {\n IDefaultLocaleOptions,\n ILocaleData,\n ILocaleElementMap,\n ILocaleFileData,\n ILocaleFileObject,\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations\n} from './interfaces';\nexport { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
- "version": "0.7.3",
3
+ "version": "0.8.1",
4
4
  "description": "This plugin facilitates localization with Webpack.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack5-localization-plugin.d.ts",
@@ -15,14 +15,14 @@
15
15
  "@types/node": "*"
16
16
  },
17
17
  "dependencies": {
18
- "@rushstack/localization-utilities": "0.9.23",
19
- "@rushstack/node-core-library": "3.66.0"
18
+ "@rushstack/localization-utilities": "0.9.24",
19
+ "@rushstack/node-core-library": "3.66.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "memfs": "3.4.3",
23
23
  "webpack": "~5.82.1",
24
- "local-node-rig": "1.0.0",
25
- "@rushstack/heft": "0.64.6"
24
+ "@rushstack/heft": "0.64.7",
25
+ "local-node-rig": "1.0.0"
26
26
  },
27
27
  "peerDependenciesMeta": {
28
28
  "@types/node": {