webpack-assets-manifest 6.0.1 → 6.0.2
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/cjs/helpers.js +1 -1
- package/dist/cjs/plugin.js +13 -5
- package/dist/mjs/helpers.js +1 -1
- package/dist/mjs/plugin.js +13 -5
- package/dist/types/helpers.d.ts +2 -1
- package/package.json +9 -8
package/dist/cjs/helpers.js
CHANGED
|
@@ -17,7 +17,7 @@ function asArray(data) {
|
|
|
17
17
|
return Array.isArray(data) ? data : [data];
|
|
18
18
|
}
|
|
19
19
|
function getSRIHash(algorithm, content) {
|
|
20
|
-
return `${algorithm}-${(0, node_crypto_1.createHash)(algorithm).update(content
|
|
20
|
+
return `${algorithm}-${(0, node_crypto_1.createHash)(algorithm).update(content).digest('base64')}`;
|
|
21
21
|
}
|
|
22
22
|
function getSortedObject(object, compareFunction) {
|
|
23
23
|
return Object.fromEntries(Object.entries(object).sort(compareFunction ? (left, right) => compareFunction(left[0], right[0]) : undefined));
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -257,19 +257,26 @@ class WebpackAssetsManifest {
|
|
|
257
257
|
const modules = chunkGraph.getChunkModulesIterableBySourceType(chunk, 'asset');
|
|
258
258
|
if (modules) {
|
|
259
259
|
const { NormalModule } = compilation.compiler.webpack;
|
|
260
|
+
const infraLogger = compilation.compiler.getInfrastructureLogger(PLUGIN_NAME);
|
|
260
261
|
for (const module of modules) {
|
|
261
262
|
if (module instanceof NormalModule) {
|
|
262
263
|
const codeGenData = codeGenerationResults.get(module, chunk.runtime).data;
|
|
263
|
-
const
|
|
264
|
-
|
|
264
|
+
const filename = module.buildInfo?.['filename'] ?? codeGenData?.get('filename');
|
|
265
|
+
if (!filename) {
|
|
266
|
+
infraLogger.warn(`Unable to get filename from module: "${module.rawRequest}"`);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const assetInfo = module.buildInfo?.['assetInfo'] ?? codeGenData?.get('assetInfo');
|
|
270
|
+
const info = {
|
|
265
271
|
rawRequest: module.rawRequest,
|
|
266
272
|
sourceFilename: (0, node_path_1.relative)(compiler.context, module.userRequest),
|
|
267
|
-
|
|
273
|
+
...assetInfo,
|
|
274
|
+
};
|
|
268
275
|
assetsInfo.set(filename, info);
|
|
269
276
|
this.assetNames.set(contextRelativeKeys ? info.sourceFilename : (0, node_path_1.join)((0, node_path_1.dirname)(filename), (0, node_path_1.basename)(module.userRequest)), filename);
|
|
270
277
|
}
|
|
271
278
|
else {
|
|
272
|
-
|
|
279
|
+
infraLogger.warn(`Unhandled module: ${module.constructor.name}`);
|
|
273
280
|
}
|
|
274
281
|
}
|
|
275
282
|
}
|
|
@@ -433,10 +440,11 @@ class WebpackAssetsManifest {
|
|
|
433
440
|
const sriHashes = new Map(integrityHashes.map((algorithm) => [algorithm, undefined]));
|
|
434
441
|
if (asset.info.contenthash) {
|
|
435
442
|
(0, helpers_js_1.asArray)(asset.info.contenthash)
|
|
443
|
+
.flatMap((contentHash) => contentHash.split(' '))
|
|
436
444
|
.filter((contentHash) => integrityHashes.some((algorithm) => contentHash.startsWith(`${algorithm}-`)))
|
|
437
445
|
.forEach((sriHash) => sriHashes.set(sriHash.substring(0, sriHash.indexOf('-')), sriHash));
|
|
438
446
|
}
|
|
439
|
-
const assetContent = asset.source.source()
|
|
447
|
+
const assetContent = asset.source.source();
|
|
440
448
|
sriHashes.forEach((value, key, map) => {
|
|
441
449
|
if (typeof value === 'undefined') {
|
|
442
450
|
map.set(key, (0, helpers_js_1.getSRIHash)(key, assetContent));
|
package/dist/mjs/helpers.js
CHANGED
|
@@ -7,7 +7,7 @@ export function asArray(data) {
|
|
|
7
7
|
return Array.isArray(data) ? data : [data];
|
|
8
8
|
}
|
|
9
9
|
export function getSRIHash(algorithm, content) {
|
|
10
|
-
return `${algorithm}-${createHash(algorithm).update(content
|
|
10
|
+
return `${algorithm}-${createHash(algorithm).update(content).digest('base64')}`;
|
|
11
11
|
}
|
|
12
12
|
export function getSortedObject(object, compareFunction) {
|
|
13
13
|
return Object.fromEntries(Object.entries(object).sort(compareFunction ? (left, right) => compareFunction(left[0], right[0]) : undefined));
|
package/dist/mjs/plugin.js
CHANGED
|
@@ -221,19 +221,26 @@ export class WebpackAssetsManifest {
|
|
|
221
221
|
const modules = chunkGraph.getChunkModulesIterableBySourceType(chunk, 'asset');
|
|
222
222
|
if (modules) {
|
|
223
223
|
const { NormalModule } = compilation.compiler.webpack;
|
|
224
|
+
const infraLogger = compilation.compiler.getInfrastructureLogger(PLUGIN_NAME);
|
|
224
225
|
for (const module of modules) {
|
|
225
226
|
if (module instanceof NormalModule) {
|
|
226
227
|
const codeGenData = codeGenerationResults.get(module, chunk.runtime).data;
|
|
227
|
-
const
|
|
228
|
-
|
|
228
|
+
const filename = module.buildInfo?.['filename'] ?? codeGenData?.get('filename');
|
|
229
|
+
if (!filename) {
|
|
230
|
+
infraLogger.warn(`Unable to get filename from module: "${module.rawRequest}"`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const assetInfo = module.buildInfo?.['assetInfo'] ?? codeGenData?.get('assetInfo');
|
|
234
|
+
const info = {
|
|
229
235
|
rawRequest: module.rawRequest,
|
|
230
236
|
sourceFilename: relative(compiler.context, module.userRequest),
|
|
231
|
-
|
|
237
|
+
...assetInfo,
|
|
238
|
+
};
|
|
232
239
|
assetsInfo.set(filename, info);
|
|
233
240
|
this.assetNames.set(contextRelativeKeys ? info.sourceFilename : join(dirname(filename), basename(module.userRequest)), filename);
|
|
234
241
|
}
|
|
235
242
|
else {
|
|
236
|
-
|
|
243
|
+
infraLogger.warn(`Unhandled module: ${module.constructor.name}`);
|
|
237
244
|
}
|
|
238
245
|
}
|
|
239
246
|
}
|
|
@@ -397,10 +404,11 @@ export class WebpackAssetsManifest {
|
|
|
397
404
|
const sriHashes = new Map(integrityHashes.map((algorithm) => [algorithm, undefined]));
|
|
398
405
|
if (asset.info.contenthash) {
|
|
399
406
|
asArray(asset.info.contenthash)
|
|
407
|
+
.flatMap((contentHash) => contentHash.split(' '))
|
|
400
408
|
.filter((contentHash) => integrityHashes.some((algorithm) => contentHash.startsWith(`${algorithm}-`)))
|
|
401
409
|
.forEach((sriHash) => sriHashes.set(sriHash.substring(0, sriHash.indexOf('-')), sriHash));
|
|
402
410
|
}
|
|
403
|
-
const assetContent = asset.source.source()
|
|
411
|
+
const assetContent = asset.source.source();
|
|
404
412
|
sriHashes.forEach((value, key, map) => {
|
|
405
413
|
if (typeof value === 'undefined') {
|
|
406
414
|
map.set(key, getSRIHash(key, assetContent));
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type BinaryLike } from 'node:crypto';
|
|
1
2
|
export declare function asArray<T>(data: T | T[]): T[];
|
|
2
|
-
export declare function getSRIHash(algorithm: string, content: string): string;
|
|
3
|
+
export declare function getSRIHash(algorithm: string, content: string | BinaryLike): string;
|
|
3
4
|
export declare function getSortedObject(object: Record<string, unknown>, compareFunction?: (left: string, right: string) => number): typeof object;
|
|
4
5
|
export declare function findMapKeysByValue<K = string, V = string>(map: Map<K, V>): (searchValue: V) => K[];
|
|
5
6
|
export declare function group<T>(data: readonly T[], getGroup: (item: T) => PropertyKey | undefined, mapper?: (item: T, group: PropertyKey) => T): Record<PropertyKey, T[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-assets-manifest",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"dist"
|
|
67
67
|
],
|
|
68
|
-
"packageManager": "pnpm@10.
|
|
68
|
+
"packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677",
|
|
69
69
|
"scripts": {
|
|
70
70
|
"clean": "rimraf ./coverage/ ./dist/ ./cache/",
|
|
71
71
|
"prebuild": "pnpm clean",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"postbuild": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && echo '{\"type\":\"module\"}' > ./dist/mjs/package.json && pnpm validate",
|
|
75
75
|
"lint": "eslint ./*{js,cjs,mjs,mts} ./src ./test ./examples",
|
|
76
76
|
"typecheck": "tsc --build --verbose",
|
|
77
|
-
"spellcheck": "cspell --no-progress './{.github,src,test}/**/*.{ts,js,json}' './*.{md,js}' './package.json'",
|
|
77
|
+
"spellcheck": "cspell --no-progress './{.github,src,examples,test}/**/*.{ts,js,json}' './*.{md,js,mjs,mts}' './package.json'",
|
|
78
78
|
"format": "prettier --write ./*.{mts,mjs,json,md} ./src/ ./test/ --no-error-on-unmatched-pattern",
|
|
79
79
|
"test": "vitest",
|
|
80
80
|
"coverage": "vitest run --coverage",
|
|
@@ -107,25 +107,26 @@
|
|
|
107
107
|
"compression-webpack-plugin": "^11.1.0",
|
|
108
108
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
109
109
|
"copy-webpack-plugin": "^13.0.0",
|
|
110
|
-
"cspell": "^8.
|
|
110
|
+
"cspell": "^8.19.0",
|
|
111
111
|
"css-loader": "^7.1.2",
|
|
112
112
|
"eslint": "^8.57.1",
|
|
113
|
-
"eslint-config-prettier": "^10.1.
|
|
114
|
-
"eslint-import-resolver-typescript": "^4.3.
|
|
113
|
+
"eslint-config-prettier": "^10.1.2",
|
|
114
|
+
"eslint-import-resolver-typescript": "^4.3.2",
|
|
115
115
|
"eslint-plugin-import": "^2.31.0",
|
|
116
116
|
"file-loader": "^6.2.0",
|
|
117
117
|
"fs-extra": "^11.3.0",
|
|
118
118
|
"husky": "^9.1.7",
|
|
119
|
-
"lint-staged": "^15.5.
|
|
119
|
+
"lint-staged": "^15.5.1",
|
|
120
120
|
"memfs": "^4.17.0",
|
|
121
121
|
"mini-css-extract-plugin": "^2.9.2",
|
|
122
122
|
"prettier": "^3.5.3",
|
|
123
123
|
"rimraf": "^6.0.1",
|
|
124
|
+
"sass-loader": "^16.0.5",
|
|
124
125
|
"semantic-release": "^24.2.3",
|
|
125
126
|
"typescript": "^5.8.3",
|
|
126
127
|
"validate-package-exports": "^0.9.0",
|
|
127
128
|
"vitest": "^3.1.1",
|
|
128
|
-
"webpack": "^5.
|
|
129
|
+
"webpack": "^5.99.5",
|
|
129
130
|
"webpack-dev-server": "^5.2.1",
|
|
130
131
|
"webpack-subresource-integrity": "^5.1.0"
|
|
131
132
|
},
|