webpack-assets-manifest 6.3.0 → 6.5.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/dist/cjs/helpers.js +0 -37
- package/dist/cjs/plugin.js +27 -15
- package/dist/mjs/helpers.js +0 -34
- package/dist/mjs/plugin.js +28 -16
- package/dist/types/helpers.d.ts +0 -3
- package/package.json +22 -22
package/dist/cjs/helpers.js
CHANGED
|
@@ -5,13 +5,7 @@ exports.getSRIHash = getSRIHash;
|
|
|
5
5
|
exports.getSortedObject = getSortedObject;
|
|
6
6
|
exports.findMapKeysByValue = findMapKeysByValue;
|
|
7
7
|
exports.group = group;
|
|
8
|
-
exports.getLockFilename = getLockFilename;
|
|
9
|
-
exports.lock = lock;
|
|
10
|
-
exports.unlock = unlock;
|
|
11
8
|
const node_crypto_1 = require("node:crypto");
|
|
12
|
-
const node_os_1 = require("node:os");
|
|
13
|
-
const node_path_1 = require("node:path");
|
|
14
|
-
const lockfile_1 = require("lockfile");
|
|
15
9
|
const type_predicate_js_1 = require("./type-predicate.js");
|
|
16
10
|
function asArray(data) {
|
|
17
11
|
return Array.isArray(data) ? data : [data];
|
|
@@ -35,34 +29,3 @@ function group(data, getGroup, mapper) {
|
|
|
35
29
|
return obj;
|
|
36
30
|
}, Object.create(null));
|
|
37
31
|
}
|
|
38
|
-
function getLockFilename(filename) {
|
|
39
|
-
const name = filename.replace(/[^\w]+/g, '-');
|
|
40
|
-
return (0, node_path_1.join)((0, node_os_1.tmpdir)(), `${name}.lock`);
|
|
41
|
-
}
|
|
42
|
-
function lock(filename) {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
(0, lockfile_1.lock)(getLockFilename(filename), {
|
|
45
|
-
wait: 10000,
|
|
46
|
-
stale: 20000,
|
|
47
|
-
retries: 100,
|
|
48
|
-
retryWait: 100,
|
|
49
|
-
}, (error) => {
|
|
50
|
-
if (error) {
|
|
51
|
-
reject(error);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
resolve();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function unlock(filename) {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
(0, lockfile_1.unlock)(getLockFilename(filename), (error) => {
|
|
61
|
-
if (error) {
|
|
62
|
-
reject(error);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
resolve();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.WebpackAssetsManifest = void 0;
|
|
37
37
|
const promises_1 = require("node:fs/promises");
|
|
38
38
|
const node_path_1 = require("node:path");
|
|
39
|
+
const proper_lockfile_1 = require("proper-lockfile");
|
|
39
40
|
const schema_utils_1 = require("schema-utils");
|
|
40
41
|
const tapable_1 = require("tapable");
|
|
41
42
|
const helpers_js_1 = require("./helpers.js");
|
|
@@ -243,17 +244,22 @@ class WebpackAssetsManifest {
|
|
|
243
244
|
async emitAssetsManifest(compilation) {
|
|
244
245
|
const outputPath = this.getOutputPath();
|
|
245
246
|
const output = this.getManifestPath(compilation, this.inDevServer() ? (0, node_path_1.basename)(this.options.output) : (0, node_path_1.relative)(compilation.compiler.outputPath, outputPath));
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
let release;
|
|
248
|
+
try {
|
|
249
|
+
if (this.options.merge) {
|
|
250
|
+
const outputDir = (0, node_path_1.dirname)(outputPath);
|
|
251
|
+
await (0, promises_1.mkdir)(outputDir, { recursive: true });
|
|
252
|
+
release = await (0, proper_lockfile_1.lock)(outputDir, { lockfilePath: (0, node_path_1.join)(outputDir, `${PLUGIN_NAME}.lock`) });
|
|
253
|
+
}
|
|
254
|
+
await this.maybeMerge();
|
|
255
|
+
compilation.emitAsset(output, new compilation.compiler.webpack.sources.RawSource(this.toString(), false), {
|
|
256
|
+
assetsManifest: true,
|
|
257
|
+
generated: true,
|
|
258
|
+
generatedBy: [PLUGIN_NAME],
|
|
259
|
+
});
|
|
248
260
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
assetsManifest: true,
|
|
252
|
-
generated: true,
|
|
253
|
-
generatedBy: [PLUGIN_NAME],
|
|
254
|
-
});
|
|
255
|
-
if (this.options.merge) {
|
|
256
|
-
await (0, helpers_js_1.unlock)(outputPath);
|
|
261
|
+
finally {
|
|
262
|
+
await release?.();
|
|
257
263
|
}
|
|
258
264
|
}
|
|
259
265
|
handleProcessAssetsAnalyse(compilation) {
|
|
@@ -266,7 +272,7 @@ class WebpackAssetsManifest {
|
|
|
266
272
|
const infraLogger = compilation.compiler.getInfrastructureLogger(PLUGIN_NAME);
|
|
267
273
|
for (const module of modules) {
|
|
268
274
|
if (module instanceof NormalModule) {
|
|
269
|
-
const codeGenData = codeGenerationResults
|
|
275
|
+
const codeGenData = codeGenerationResults?.get(module, chunk.runtime).data;
|
|
270
276
|
const filename = module.buildInfo?.['filename'] ?? codeGenData?.get('filename');
|
|
271
277
|
if (!filename) {
|
|
272
278
|
infraLogger.warn(`Unable to get filename from module: "${module.rawRequest}"`);
|
|
@@ -387,10 +393,16 @@ class WebpackAssetsManifest {
|
|
|
387
393
|
});
|
|
388
394
|
}
|
|
389
395
|
async writeTo(destination) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
396
|
+
const destinationDir = (0, node_path_1.dirname)(destination);
|
|
397
|
+
let release;
|
|
398
|
+
try {
|
|
399
|
+
await (0, promises_1.mkdir)(destinationDir, { recursive: true });
|
|
400
|
+
release = await (0, proper_lockfile_1.lock)(destinationDir, { lockfilePath: (0, node_path_1.join)(destinationDir, `${PLUGIN_NAME}.lock`) });
|
|
401
|
+
await (0, promises_1.writeFile)(destination, this.toString());
|
|
402
|
+
}
|
|
403
|
+
finally {
|
|
404
|
+
await release?.();
|
|
405
|
+
}
|
|
394
406
|
}
|
|
395
407
|
clear() {
|
|
396
408
|
Object.keys(this.assets).forEach((key) => {
|
package/dist/mjs/helpers.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { tmpdir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { lock as lockfileLock, unlock as lockfileUnlock } from 'lockfile';
|
|
5
2
|
import { isPropertyKey } from './type-predicate.js';
|
|
6
3
|
export function asArray(data) {
|
|
7
4
|
return Array.isArray(data) ? data : [data];
|
|
@@ -25,34 +22,3 @@ export function group(data, getGroup, mapper) {
|
|
|
25
22
|
return obj;
|
|
26
23
|
}, Object.create(null));
|
|
27
24
|
}
|
|
28
|
-
export function getLockFilename(filename) {
|
|
29
|
-
const name = filename.replace(/[^\w]+/g, '-');
|
|
30
|
-
return join(tmpdir(), `${name}.lock`);
|
|
31
|
-
}
|
|
32
|
-
export function lock(filename) {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
lockfileLock(getLockFilename(filename), {
|
|
35
|
-
wait: 10000,
|
|
36
|
-
stale: 20000,
|
|
37
|
-
retries: 100,
|
|
38
|
-
retryWait: 100,
|
|
39
|
-
}, (error) => {
|
|
40
|
-
if (error) {
|
|
41
|
-
reject(error);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
resolve();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
export function unlock(filename) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
lockfileUnlock(getLockFilename(filename), (error) => {
|
|
51
|
-
if (error) {
|
|
52
|
-
reject(error);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
resolve();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
package/dist/mjs/plugin.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
|
|
3
|
+
import { lock } from 'proper-lockfile';
|
|
3
4
|
import { validate } from 'schema-utils';
|
|
4
5
|
import { AsyncSeriesHook, SyncHook, SyncWaterfallHook } from 'tapable';
|
|
5
|
-
import { asArray, findMapKeysByValue, getSortedObject, getSRIHash, group
|
|
6
|
+
import { asArray, findMapKeysByValue, getSortedObject, getSRIHash, group } from './helpers.js';
|
|
6
7
|
import { optionsSchema } from './options-schema.js';
|
|
7
8
|
import { isKeyValuePair, isObject } from './type-predicate.js';
|
|
8
9
|
const PLUGIN_NAME = 'WebpackAssetsManifest';
|
|
@@ -207,17 +208,22 @@ export class WebpackAssetsManifest {
|
|
|
207
208
|
async emitAssetsManifest(compilation) {
|
|
208
209
|
const outputPath = this.getOutputPath();
|
|
209
210
|
const output = this.getManifestPath(compilation, this.inDevServer() ? basename(this.options.output) : relative(compilation.compiler.outputPath, outputPath));
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
let release;
|
|
212
|
+
try {
|
|
213
|
+
if (this.options.merge) {
|
|
214
|
+
const outputDir = dirname(outputPath);
|
|
215
|
+
await mkdir(outputDir, { recursive: true });
|
|
216
|
+
release = await lock(outputDir, { lockfilePath: join(outputDir, `${PLUGIN_NAME}.lock`) });
|
|
217
|
+
}
|
|
218
|
+
await this.maybeMerge();
|
|
219
|
+
compilation.emitAsset(output, new compilation.compiler.webpack.sources.RawSource(this.toString(), false), {
|
|
220
|
+
assetsManifest: true,
|
|
221
|
+
generated: true,
|
|
222
|
+
generatedBy: [PLUGIN_NAME],
|
|
223
|
+
});
|
|
212
224
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
assetsManifest: true,
|
|
216
|
-
generated: true,
|
|
217
|
-
generatedBy: [PLUGIN_NAME],
|
|
218
|
-
});
|
|
219
|
-
if (this.options.merge) {
|
|
220
|
-
await unlock(outputPath);
|
|
225
|
+
finally {
|
|
226
|
+
await release?.();
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
229
|
handleProcessAssetsAnalyse(compilation) {
|
|
@@ -230,7 +236,7 @@ export class WebpackAssetsManifest {
|
|
|
230
236
|
const infraLogger = compilation.compiler.getInfrastructureLogger(PLUGIN_NAME);
|
|
231
237
|
for (const module of modules) {
|
|
232
238
|
if (module instanceof NormalModule) {
|
|
233
|
-
const codeGenData = codeGenerationResults
|
|
239
|
+
const codeGenData = codeGenerationResults?.get(module, chunk.runtime).data;
|
|
234
240
|
const filename = module.buildInfo?.['filename'] ?? codeGenData?.get('filename');
|
|
235
241
|
if (!filename) {
|
|
236
242
|
infraLogger.warn(`Unable to get filename from module: "${module.rawRequest}"`);
|
|
@@ -351,10 +357,16 @@ export class WebpackAssetsManifest {
|
|
|
351
357
|
});
|
|
352
358
|
}
|
|
353
359
|
async writeTo(destination) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
360
|
+
const destinationDir = dirname(destination);
|
|
361
|
+
let release;
|
|
362
|
+
try {
|
|
363
|
+
await mkdir(destinationDir, { recursive: true });
|
|
364
|
+
release = await lock(destinationDir, { lockfilePath: join(destinationDir, `${PLUGIN_NAME}.lock`) });
|
|
365
|
+
await writeFile(destination, this.toString());
|
|
366
|
+
}
|
|
367
|
+
finally {
|
|
368
|
+
await release?.();
|
|
369
|
+
}
|
|
358
370
|
}
|
|
359
371
|
clear() {
|
|
360
372
|
Object.keys(this.assets).forEach((key) => {
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -4,6 +4,3 @@ export declare function getSRIHash(algorithm: string, content: string | BinaryLi
|
|
|
4
4
|
export declare function getSortedObject(object: Record<string, unknown>, compareFunction?: (left: string, right: string) => number): typeof object;
|
|
5
5
|
export declare function findMapKeysByValue<K = string, V = string>(map: Map<K, V>): (searchValue: V) => K[];
|
|
6
6
|
export declare function group<T>(data: readonly T[], getGroup: (item: T) => PropertyKey | undefined, mapper?: (item: T, group: PropertyKey) => T): Record<PropertyKey, T[]>;
|
|
7
|
-
export declare function getLockFilename(filename: string): string;
|
|
8
|
-
export declare function lock(filename: string): Promise<void>;
|
|
9
|
-
export declare function unlock(filename: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-assets-manifest",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
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.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
|
|
69
69
|
"scripts": {
|
|
70
70
|
"clean": "rimraf ./coverage/ ./dist/ ./cache/",
|
|
71
71
|
"prebuild": "pnpm clean",
|
|
@@ -85,29 +85,29 @@
|
|
|
85
85
|
"prettier": "@webdeveric/prettier-config",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"deepmerge": "^4.3.1",
|
|
88
|
-
"lockfile": "^1.
|
|
89
|
-
"schema-utils": "^4.3.
|
|
90
|
-
"tapable": "^2.
|
|
88
|
+
"proper-lockfile": "^4.1.2",
|
|
89
|
+
"schema-utils": "^4.3.3",
|
|
90
|
+
"tapable": "^2.3.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"webpack": "^5.61.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@commitlint/config-conventional": "^20.
|
|
97
|
-
"@commitlint/types": "^20.
|
|
98
|
-
"@types/
|
|
99
|
-
"@types/
|
|
100
|
-
"@types/tapable": "^2.
|
|
96
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
97
|
+
"@commitlint/types": "^20.2.0",
|
|
98
|
+
"@types/node": "^20.19.25",
|
|
99
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
100
|
+
"@types/tapable": "^2.3.0",
|
|
101
101
|
"@types/webpack-sources": "^3.2.3",
|
|
102
|
-
"@vitest/coverage-v8": "^
|
|
102
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
103
103
|
"@webdeveric/eslint-config-ts": "^0.11.0",
|
|
104
104
|
"@webdeveric/prettier-config": "^0.3.0",
|
|
105
|
-
"commitlint": "^20.
|
|
105
|
+
"commitlint": "^20.2.0",
|
|
106
106
|
"commitlint-plugin-cspell": "^0.3.0",
|
|
107
107
|
"compression-webpack-plugin": "^11.1.0",
|
|
108
108
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
109
109
|
"copy-webpack-plugin": "^13.0.1",
|
|
110
|
-
"cspell": "^9.
|
|
110
|
+
"cspell": "^9.4.0",
|
|
111
111
|
"css-loader": "^7.1.2",
|
|
112
112
|
"eslint": "^8.57.1",
|
|
113
113
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -116,17 +116,17 @@
|
|
|
116
116
|
"file-loader": "^6.2.0",
|
|
117
117
|
"fs-extra": "^11.3.2",
|
|
118
118
|
"husky": "^9.1.7",
|
|
119
|
-
"lint-staged": "^16.2.
|
|
120
|
-
"memfs": "^4.
|
|
119
|
+
"lint-staged": "^16.2.7",
|
|
120
|
+
"memfs": "^4.51.1",
|
|
121
121
|
"mini-css-extract-plugin": "^2.9.4",
|
|
122
|
-
"prettier": "^3.
|
|
123
|
-
"rimraf": "^6.
|
|
124
|
-
"sass-loader": "^16.0.
|
|
122
|
+
"prettier": "^3.7.4",
|
|
123
|
+
"rimraf": "^6.1.2",
|
|
124
|
+
"sass-loader": "^16.0.6",
|
|
125
125
|
"semantic-release": "^24.2.9",
|
|
126
|
-
"typescript": "^5.9.
|
|
127
|
-
"validate-package-exports": "^0.
|
|
128
|
-
"vitest": "^
|
|
129
|
-
"webpack": "^5.
|
|
126
|
+
"typescript": "^5.9.3",
|
|
127
|
+
"validate-package-exports": "^0.14.0",
|
|
128
|
+
"vitest": "^4.0.15",
|
|
129
|
+
"webpack": "^5.103.0",
|
|
130
130
|
"webpack-dev-server": "^5.2.2",
|
|
131
131
|
"webpack-subresource-integrity": "^5.1.0"
|
|
132
132
|
},
|