webpack-assets-manifest 5.2.1 → 6.0.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/dist/cjs/helpers.js +68 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/options-schema.js +183 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugin.js +528 -0
- package/dist/cjs/type-predicate.js +14 -0
- package/dist/cjs/types.js +2 -0
- package/dist/mjs/helpers.js +58 -0
- package/dist/mjs/index.js +2 -0
- package/dist/mjs/options-schema.js +180 -0
- package/dist/mjs/package.json +1 -0
- package/dist/mjs/plugin.js +491 -0
- package/dist/mjs/type-predicate.js +9 -0
- package/dist/mjs/types.js +1 -0
- package/dist/types/helpers.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/options-schema.d.ts +174 -0
- package/dist/types/plugin.d.ts +86 -0
- package/dist/types/type-predicate.d.ts +4 -0
- package/dist/types/types.d.ts +16 -0
- package/package.json +97 -57
- package/readme.md +46 -48
- package/src/WebpackAssetsManifest.js +0 -885
- package/src/helpers.js +0 -221
- package/src/options-schema.json +0 -181
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asArray = asArray;
|
|
4
|
+
exports.getSRIHash = getSRIHash;
|
|
5
|
+
exports.getSortedObject = getSortedObject;
|
|
6
|
+
exports.findMapKeysByValue = findMapKeysByValue;
|
|
7
|
+
exports.group = group;
|
|
8
|
+
exports.getLockFilename = getLockFilename;
|
|
9
|
+
exports.lock = lock;
|
|
10
|
+
exports.unlock = unlock;
|
|
11
|
+
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
|
+
const type_predicate_js_1 = require("./type-predicate.js");
|
|
16
|
+
function asArray(data) {
|
|
17
|
+
return Array.isArray(data) ? data : [data];
|
|
18
|
+
}
|
|
19
|
+
function getSRIHash(algorithm, content) {
|
|
20
|
+
return `${algorithm}-${(0, node_crypto_1.createHash)(algorithm).update(content, 'utf8').digest('base64')}`;
|
|
21
|
+
}
|
|
22
|
+
function getSortedObject(object, compareFunction) {
|
|
23
|
+
return Object.fromEntries(Object.entries(object).sort(compareFunction ? (left, right) => compareFunction(left[0], right[0]) : undefined));
|
|
24
|
+
}
|
|
25
|
+
function findMapKeysByValue(map) {
|
|
26
|
+
const entries = [...map.entries()];
|
|
27
|
+
return (searchValue) => entries.filter(([, value]) => value === searchValue).map(([name]) => name);
|
|
28
|
+
}
|
|
29
|
+
function group(data, getGroup, mapper) {
|
|
30
|
+
return data.reduce((obj, item) => {
|
|
31
|
+
const group = getGroup(item);
|
|
32
|
+
if ((0, type_predicate_js_1.isPropertyKey)(group)) {
|
|
33
|
+
(obj[group] ??= []).push(mapper ? mapper(item, group) : item);
|
|
34
|
+
}
|
|
35
|
+
return obj;
|
|
36
|
+
}, Object.create(null));
|
|
37
|
+
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.js"), exports);
|
|
18
|
+
__exportStar(require("./plugin.js"), exports);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optionsSchema = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
exports.optionsSchema = {
|
|
6
|
+
title: 'Webpack Assets Manifest options schema',
|
|
7
|
+
description: 'Webpack Assets Manifest options',
|
|
8
|
+
type: 'object',
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
properties: {
|
|
11
|
+
enabled: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
default: true,
|
|
14
|
+
},
|
|
15
|
+
assets: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
default: {},
|
|
18
|
+
},
|
|
19
|
+
output: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: 'assets-manifest.json',
|
|
22
|
+
},
|
|
23
|
+
replacer: {
|
|
24
|
+
default: null,
|
|
25
|
+
oneOf: [
|
|
26
|
+
{
|
|
27
|
+
$ref: '#/definitions/functionOrNull',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'array',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
space: {
|
|
35
|
+
oneOf: [
|
|
36
|
+
{
|
|
37
|
+
type: 'integer',
|
|
38
|
+
multipleOf: 1.0,
|
|
39
|
+
minimum: 0,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'string',
|
|
43
|
+
minLength: 1,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
default: 2,
|
|
47
|
+
},
|
|
48
|
+
writeToDisk: {
|
|
49
|
+
oneOf: [
|
|
50
|
+
{
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
const: 'auto',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
default: 'auto',
|
|
58
|
+
},
|
|
59
|
+
fileExtRegex: {
|
|
60
|
+
oneOf: [
|
|
61
|
+
{
|
|
62
|
+
instanceof: 'RegExp',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'null',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
const: false,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
sortManifest: {
|
|
73
|
+
default: true,
|
|
74
|
+
oneOf: [
|
|
75
|
+
{
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
instanceof: 'Function',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
merge: {
|
|
84
|
+
default: false,
|
|
85
|
+
oneOf: [
|
|
86
|
+
{
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
const: 'customize',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
publicPath: {
|
|
95
|
+
default: null,
|
|
96
|
+
oneOf: [
|
|
97
|
+
{
|
|
98
|
+
type: 'string',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'null',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
instanceof: 'Function',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
contextRelativeKeys: {
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
default: false,
|
|
114
|
+
},
|
|
115
|
+
apply: {
|
|
116
|
+
$ref: '#/definitions/functionOrNull',
|
|
117
|
+
},
|
|
118
|
+
customize: {
|
|
119
|
+
$ref: '#/definitions/functionOrNull',
|
|
120
|
+
},
|
|
121
|
+
transform: {
|
|
122
|
+
$ref: '#/definitions/functionOrNull',
|
|
123
|
+
},
|
|
124
|
+
done: {
|
|
125
|
+
$ref: '#/definitions/functionOrNull',
|
|
126
|
+
},
|
|
127
|
+
entrypoints: {
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
default: false,
|
|
130
|
+
},
|
|
131
|
+
entrypointsKey: {
|
|
132
|
+
default: 'entrypoints',
|
|
133
|
+
oneOf: [
|
|
134
|
+
{
|
|
135
|
+
type: 'string',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
const: false,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
entrypointsUseAssets: {
|
|
143
|
+
type: 'boolean',
|
|
144
|
+
default: false,
|
|
145
|
+
},
|
|
146
|
+
integrity: {
|
|
147
|
+
type: 'boolean',
|
|
148
|
+
default: 'a',
|
|
149
|
+
},
|
|
150
|
+
integrityHashes: {
|
|
151
|
+
type: 'array',
|
|
152
|
+
items: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
enum: (0, node_crypto_1.getHashes)(),
|
|
155
|
+
},
|
|
156
|
+
default: ['sha256', 'sha384', 'sha512'],
|
|
157
|
+
},
|
|
158
|
+
integrityPropertyName: {
|
|
159
|
+
description: 'The `asset.info` property name where the SRI hash is stored',
|
|
160
|
+
type: 'string',
|
|
161
|
+
minLength: 1,
|
|
162
|
+
default: 'integrity',
|
|
163
|
+
},
|
|
164
|
+
extra: {
|
|
165
|
+
description: 'A place to put your arbitrary data',
|
|
166
|
+
type: 'object',
|
|
167
|
+
default: {},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
definitions: {
|
|
171
|
+
functionOrNull: {
|
|
172
|
+
default: null,
|
|
173
|
+
oneOf: [
|
|
174
|
+
{
|
|
175
|
+
instanceof: 'Function',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: 'null',
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|