webpack-assets-manifest 5.0.6 → 5.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-assets-manifest",
3
- "version": "5.0.6",
3
+ "version": "5.2.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": {
@@ -27,17 +27,7 @@
27
27
  "files": [
28
28
  "src"
29
29
  ],
30
- "scripts": {
31
- "lint": "eslint --fix src test",
32
- "typecheck": "tsc",
33
- "spellcheck": "cspell --no-progress './{.github,src,test}/**/*.{js,json}' './*.{md,js}' './package.json'",
34
- "test": "nyc mocha --colors",
35
- "test:report": "nyc --reporter=lcov --reporter=text mocha --colors",
36
- "lcov": "nyc report --reporter=text-lcov > coverage.lcov",
37
- "pre-commit": "lint-staged",
38
- "prepare": "husky install",
39
- "prepublishOnly": "npm run spellcheck && npm run lint && npm test"
40
- },
30
+ "packageManager": "pnpm@8.15.1+sha256.245fe901f8e7fa8782d7f17d32b6a83995e2ae03984cb5b62b8949bfdc27c7b5",
41
31
  "lint-staged": {
42
32
  "*.{js,json,md}": "cspell lint --no-progress --no-summary --no-must-find-files",
43
33
  "*.js": "eslint --fix"
@@ -50,46 +40,58 @@
50
40
  "name": "Eric King",
51
41
  "url": "http://webdeveric.com/"
52
42
  },
43
+ "prettier": "@webdeveric/prettier-config",
53
44
  "dependencies": {
54
- "chalk": "^4.0",
55
- "deepmerge": "^4.0",
56
- "lockfile": "^1.0",
57
- "lodash.get": "^4.0",
58
- "lodash.has": "^4.0",
59
- "schema-utils": "^3.0",
60
- "tapable": "^2.0"
45
+ "chalk": "^4.1.2",
46
+ "deepmerge": "^4.3.1",
47
+ "lockfile": "^1.0.4",
48
+ "lodash.get": "^4.4.2",
49
+ "lodash.has": "^4.5.2",
50
+ "schema-utils": "^3.3.0",
51
+ "tapable": "^2.2.1"
61
52
  },
62
53
  "peerDependencies": {
63
54
  "webpack": "^5.2.0"
64
55
  },
65
56
  "devDependencies": {
66
- "@types/lodash.get": "^4.4.6",
67
- "@types/lodash.has": "^4.5.6",
68
- "@types/node": "^14.14.41",
69
- "@types/tapable": "^2.2.2",
70
- "@types/webpack-sources": "^2.1.0",
71
- "@webdeveric/eslint-config": "^0.1.2",
72
- "chai": "^4.3.0",
73
- "chai-spies": "^1.0.0",
57
+ "@types/lodash.get": "^4.4.9",
58
+ "@types/lodash.has": "^4.5.9",
59
+ "@types/node": "^20.11.20",
60
+ "@types/tapable": "^2.2.7",
61
+ "@types/webpack-sources": "^3.2.3",
62
+ "@webdeveric/eslint-config": "^0.4.0",
63
+ "@webdeveric/prettier-config": "^0.2.0",
64
+ "chai": "^4.4.1",
65
+ "chai-spies": "^1.1.0",
74
66
  "compression-webpack-plugin": "^7.1.2",
75
67
  "copy-webpack-plugin": "^8.1.1",
76
- "cspell": "^5.3.12",
77
- "css-loader": "^5.2.4",
78
- "eslint": "^7.24.0",
68
+ "cspell": "^8.4.1",
69
+ "css-loader": "^5.2.7",
70
+ "eslint": "^8.56.0",
71
+ "eslint-config-prettier": "^9.1.0",
79
72
  "file-loader": "^6.2.0",
80
- "fs-extra": "^9.1.0",
81
- "husky": "^6.0.0",
82
- "lint-staged": "^10.5.4",
73
+ "fs-extra": "^11.2.0",
74
+ "husky": "^9.0.11",
75
+ "lint-staged": "^15.2.2",
83
76
  "memory-fs": "^0.5.0",
84
- "mini-css-extract-plugin": "^1.5.0",
85
- "mkdirp": "^1.0.4",
86
- "mocha": "^8.3.0",
77
+ "mini-css-extract-plugin": "^1.6.2",
78
+ "mocha": "^10.3.0",
87
79
  "nyc": "^15.1.0",
88
- "rimraf": "^3.0.2",
89
- "superagent": "^6.1.0",
90
- "typescript": "^4.2.4",
91
- "webpack": "^5.35.0",
92
- "webpack-dev-server": "^3.11.2",
80
+ "prettier": "^3.2.5",
81
+ "rimraf": "^5.0.5",
82
+ "superagent": "^8.1.2",
83
+ "typescript": "^5.3.3",
84
+ "webpack": "^5.90.3",
85
+ "webpack-dev-server": "^3.11.3",
93
86
  "webpack-subresource-integrity": "^1.5.2"
87
+ },
88
+ "scripts": {
89
+ "lint": "eslint --fix src test",
90
+ "format": "prettier --write .",
91
+ "typecheck": "tsc --noEmit",
92
+ "spellcheck": "cspell --no-progress './{.github,src,test}/**/*.{js,json}' './*.{md,js}' './package.json'",
93
+ "test": "NODE_OPTIONS='--openssl-legacy-provider' nyc mocha --colors",
94
+ "test:report": "nyc --reporter=lcov --reporter=text mocha --colors",
95
+ "lcov": "nyc report --reporter=text-lcov > coverage.lcov"
94
96
  }
95
- }
97
+ }
package/readme.md CHANGED
@@ -1,35 +1,41 @@
1
1
  # Webpack Assets Manifest
2
2
 
3
- [![Build Status](https://github.com/webdeveric/webpack-assets-manifest/workflows/Node.js%20CI/badge.svg)](https://github.com/webdeveric/webpack-assets-manifest/actions)
3
+ [![Node.js CI](https://github.com/webdeveric/webpack-assets-manifest/actions/workflows/node.js.yml/badge.svg)](https://github.com/webdeveric/webpack-assets-manifest/actions/workflows/node.js.yml)
4
4
  [![codecov](https://codecov.io/gh/webdeveric/webpack-assets-manifest/branch/master/graph/badge.svg)](https://codecov.io/gh/webdeveric/webpack-assets-manifest)
5
- [![dependencies Status](https://david-dm.org/webdeveric/webpack-assets-manifest/status.svg)](https://david-dm.org/webdeveric/webpack-assets-manifest)
6
- [![devDependencies Status](https://david-dm.org/webdeveric/webpack-assets-manifest/dev-status.svg)](https://david-dm.org/webdeveric/webpack-assets-manifest?type=dev)
7
5
 
8
6
  This webpack plugin will generate a JSON file that matches the original filename with the hashed version.
9
7
 
10
8
  ## Installation
11
9
 
12
10
  ```shell
13
- npm install webpack-assets-manifest --save-dev
11
+ pnpm add -D webpack-assets-manifest
12
+ ```
13
+
14
+ ```shell
15
+ npm install webpack-assets-manifest -D
16
+ ```
17
+
18
+ ```shell
19
+ yarn add webpack-assets-manifest -D
14
20
  ```
15
21
 
16
22
  ## New in version 5
17
23
 
18
- * Compatible with webpack 5 only (5.1+ required).
19
- * Supports finding [asset modules](https://webpack.js.org/guides/asset-modules/).
20
- * Updated options schema to prevent additional properties. This helps with catching typos in option names.
21
- * :warning: Updated default value of the `output` option to be `assets-manifest.json`.
24
+ - Compatible with webpack 5 only (5.1+ required).
25
+ - Supports finding [asset modules](https://webpack.js.org/guides/asset-modules/).
26
+ - Updated options schema to prevent additional properties. This helps with catching typos in option names.
27
+ - :warning: Updated default value of the `output` option to be `assets-manifest.json`.
22
28
  This is to prevent confusion when working with [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest) or [WebExtension manifests](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json).
23
-
29
+
24
30
  ## New in version 4
25
31
 
26
- * Requires Node 10+.
27
- * Compatible with webpack 4 only (4.40+ required).
28
- * Added options: [`enabled`](#enabled), [`entrypointsUseAssets`](#entrypointsUseAssets), [`contextRelativeKeys`](#contextRelativeKeys).
29
- * Updated [`writeToDisk`](#writeToDisk) option to default to `auto`.
30
- * Use lock files for various operations.
31
- * `done` hook is now an `AsyncSeriesHook`.
32
- * :warning: The structure of the `entrypoints` data has been updated to include `preload` and `prefetch` assets. Assets for an entrypoint are now included in an `assets` property under the entrypoint.
32
+ - Requires Node 10+.
33
+ - Compatible with webpack 4 only (4.40+ required).
34
+ - Added options: [`enabled`](#enabled), [`entrypointsUseAssets`](#entrypointsUseAssets), [`contextRelativeKeys`](#contextRelativeKeys).
35
+ - Updated [`writeToDisk`](#writeToDisk) option to default to `auto`.
36
+ - Use lock files for various operations.
37
+ - `done` hook is now an `AsyncSeriesHook`.
38
+ - :warning: The structure of the `entrypoints` data has been updated to include `preload` and `prefetch` assets. Assets for an entrypoint are now included in an `assets` property under the entrypoint.
33
39
 
34
40
  Example:
35
41
 
@@ -38,22 +44,14 @@ npm install webpack-assets-manifest --save-dev
38
44
  "entrypoints": {
39
45
  "main": {
40
46
  "assets": {
41
- "css": [
42
- "main.css"
43
- ],
44
- "js": [
45
- "main.js"
46
- ]
47
+ "css": ["main.css"],
48
+ "js": ["main.js"]
47
49
  },
48
50
  "prefetch": {
49
- "js": [
50
- "prefetch.js"
51
- ]
51
+ "js": ["prefetch.js"]
52
52
  },
53
53
  "preload": {
54
- "js": [
55
- "preload.js"
56
- ]
54
+ "js": ["preload.js"]
57
55
  }
58
56
  }
59
57
  }
@@ -65,17 +63,17 @@ npm install webpack-assets-manifest --save-dev
65
63
  In your webpack config, require the plugin then add an instance to the `plugins` array.
66
64
 
67
65
  ```js
68
- const path = require('path');
69
- const WebpackAssetsManifest = require('webpack-assets-manifest');
66
+ const path = require("path");
67
+ const WebpackAssetsManifest = require("webpack-assets-manifest");
70
68
 
71
69
  module.exports = {
72
70
  entry: {
73
71
  // Your entry points
74
72
  },
75
73
  output: {
76
- path: path.join( __dirname, 'dist' ),
77
- filename: '[name]-[hash].js',
78
- chunkFilename: '[id]-[chunkhash].js',
74
+ path: path.join(__dirname, "dist"),
75
+ filename: "[name]-[hash].js",
76
+ chunkFilename: "[id]-[chunkhash].js",
79
77
  },
80
78
  module: {
81
79
  // Your loader rules go here.
@@ -84,7 +82,7 @@ module.exports = {
84
82
  new WebpackAssetsManifest({
85
83
  // Options go here
86
84
  }),
87
- ],
85
+ ],
88
86
  };
89
87
  ```
90
88
 
@@ -205,7 +203,7 @@ See the [sorted](examples/sorted.js) example.
205
203
  new WebpackAssetsManifest({
206
204
  sortManifest(a, b) {
207
205
  // Return -1, 0, or 1
208
- }
206
+ },
209
207
  });
210
208
  ```
211
209
 
@@ -220,12 +218,12 @@ The default behavior is to use the existing keys/values without modification.
220
218
 
221
219
  ```js
222
220
  new WebpackAssetsManifest({
223
- output: '/path/to/manifest.json',
224
- merge: true
221
+ output: "/path/to/manifest.json",
222
+ merge: true,
225
223
  });
226
224
  ```
227
225
 
228
- If you need to customize during merge, use `merge: 'customize'`.
226
+ If you need to customize during merge, use `merge: 'customize'`.
229
227
 
230
228
  If you want to know if `customize` was called when merging with an existing manifest, you can check `manifest.isMerging`.
231
229
 
@@ -258,7 +256,7 @@ When using a string, it will be the value prefix. One common use is to prefix yo
258
256
 
259
257
  ```js
260
258
  const manifest = new WebpackAssetsManifest({
261
- publicPath: '//cdn.example.com',
259
+ publicPath: "//cdn.example.com",
262
260
  });
263
261
  ```
264
262
 
@@ -266,11 +264,10 @@ If you'd like to have more control, use a function. See the [custom CDN](example
266
264
 
267
265
  ```js
268
266
  const manifest = new WebpackAssetsManifest({
269
- publicPath(filename, manifest)
270
- {
267
+ publicPath(filename, manifest) {
271
268
  // customize filename here
272
269
  return filename;
273
- }
270
+ },
274
271
  });
275
272
  ```
276
273
 
@@ -389,14 +386,14 @@ This plugin is using hooks from [Tapable](https://github.com/webpack/tapable/).
389
386
 
390
387
  The `apply`, `customize`, `transform`, and `done` options are automatically tapped into the appropriate hook.
391
388
 
392
- | Name | Type | Callback signature |
393
- | ---- | ---- | --------- |
394
- | `apply` | `SyncHook` | `function(manifest){}` |
395
- | `customize` | `SyncWaterfallHook` | `function(entry, original, manifest, asset){}` |
396
- | `transform` | `SyncWaterfallHook` | `function(assets, manifest){}` |
397
- | `done` | `AsyncSeriesHook` | `async function(manifest, stats){}` |
398
- | `options` | `SyncWaterfallHook` | `function(options){}` |
399
- | `afterOptions` | `SyncHook` | `function(options){}` |
389
+ | Name | Type | Callback signature |
390
+ | -------------- | ------------------- | ---------------------------------------------- |
391
+ | `apply` | `SyncHook` | `function(manifest){}` |
392
+ | `customize` | `SyncWaterfallHook` | `function(entry, original, manifest, asset){}` |
393
+ | `transform` | `SyncWaterfallHook` | `function(assets, manifest){}` |
394
+ | `done` | `AsyncSeriesHook` | `async function(manifest, stats){}` |
395
+ | `options` | `SyncWaterfallHook` | `function(options){}` |
396
+ | `afterOptions` | `SyncHook` | `function(options){}` |
400
397
 
401
398
  #### Tapping into hooks
402
399
 
@@ -408,32 +405,35 @@ See the [customized](examples/customized.js) and [transformed](examples/transfor
408
405
  ```js
409
406
  const manifest = new WebpackAssetsManifest();
410
407
 
411
- manifest.hooks.apply.tap('YourPluginName', function(manifest) {
408
+ manifest.hooks.apply.tap("YourPluginName", function (manifest) {
412
409
  // Do something here
413
- manifest.set('some-key', 'some-value');
410
+ manifest.set("some-key", "some-value");
414
411
  });
415
412
 
416
- manifest.hooks.customize.tap('YourPluginName', function(entry, original, manifest, asset) {
417
- // customize entry here
418
- return entry;
419
- });
413
+ manifest.hooks.customize.tap(
414
+ "YourPluginName",
415
+ function (entry, original, manifest, asset) {
416
+ // customize entry here
417
+ return entry;
418
+ }
419
+ );
420
420
 
421
- manifest.hooks.transform.tap('YourPluginName', function(assets, manifest) {
421
+ manifest.hooks.transform.tap("YourPluginName", function (assets, manifest) {
422
422
  // customize assets here
423
423
  return assets;
424
424
  });
425
425
 
426
- manifest.hooks.options.tap('YourPluginName', function(options) {
426
+ manifest.hooks.options.tap("YourPluginName", function (options) {
427
427
  // customize options here
428
428
  return options;
429
429
  });
430
430
 
431
- manifest.hooks.done.tap('YourPluginName', function(manifest, stats) {
431
+ manifest.hooks.done.tap("YourPluginName", function (manifest, stats) {
432
432
  console.log(`The manifest has been written to ${manifest.getOutputPath()}`);
433
433
  console.log(`${manifest}`);
434
434
  });
435
435
 
436
- manifest.hooks.done.tapPromise('YourPluginName', async (manifest, stats) => {
436
+ manifest.hooks.done.tapPromise("YourPluginName", async (manifest, stats) => {
437
437
  await yourAsyncOperation();
438
438
  });
439
439
  ```
@@ -445,7 +445,7 @@ new WebpackAssetsManifest({
445
445
  done(manifest, stats) {
446
446
  console.log(`The manifest has been written to ${manifest.getOutputPath()}`);
447
447
  console.log(`${manifest}`);
448
- }
448
+ },
449
449
  });
450
450
  ```
451
451
 
@@ -464,7 +464,7 @@ If you want to write the manifest to another location, you can use `writeTo(dest
464
464
  ```js
465
465
  new WebpackAssetsManifest({
466
466
  async done(manifest) {
467
- await manifest.writeTo('/some/other/path/assets-manifest.json');
468
- }
467
+ await manifest.writeTo("/some/other/path/assets-manifest.json");
468
+ },
469
469
  });
470
470
  ```