@wordpress/dependency-extraction-webpack-plugin 6.7.1-next.1f6eadc42.0 → 6.8.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/lib/index.js +27 -7
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -269,7 +269,7 @@ class DependencyExtractionWebpackPlugin {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
//
|
|
272
|
+
// Prepare to hash the sources. We can't just use
|
|
273
273
|
// `chunk.contentHash` because that's not updated when
|
|
274
274
|
// assets are minified. In practice the hash is updated by
|
|
275
275
|
// `RealContentHashPlugin` after minification, but it only modifies
|
|
@@ -278,12 +278,32 @@ class DependencyExtractionWebpackPlugin {
|
|
|
278
278
|
const { hashFunction, hashDigest, hashDigestLength } =
|
|
279
279
|
compilation.outputOptions;
|
|
280
280
|
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
281
|
+
const hashBuilder = createHash( hashFunction );
|
|
282
|
+
|
|
283
|
+
const processContentsForHash = ( content ) => {
|
|
284
|
+
hashBuilder.update( content );
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Prepare to look for magic comments, in order to decide whether
|
|
288
|
+
// `wp-polyfill` is needed.
|
|
289
|
+
const processContentsForMagicComments = ( content ) => {
|
|
290
|
+
if ( content.includes( '/* wp:polyfill */' ) ) {
|
|
291
|
+
chunkStaticDeps.add( 'wp-polyfill' );
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// Go through the assets to process the sources.
|
|
296
|
+
// This allows us to generate hashes, as well as look for magic comments.
|
|
297
|
+
chunkFiles.sort().forEach( ( filename ) => {
|
|
298
|
+
const asset = compilation.getAsset( filename );
|
|
299
|
+
const content = asset.source.buffer();
|
|
300
|
+
|
|
301
|
+
processContentsForHash( content );
|
|
302
|
+
processContentsForMagicComments( content );
|
|
303
|
+
} );
|
|
304
|
+
|
|
305
|
+
// Finalise hash.
|
|
306
|
+
const contentHash = hashBuilder
|
|
287
307
|
.digest( hashDigest )
|
|
288
308
|
.slice( 0, hashDigestLength );
|
|
289
309
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dependency-extraction-webpack-plugin",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "Extract WordPress script dependencies from webpack bundles.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "cecf5e14d317aa67407f77a7e5c8b6a43016bd42"
|
|
42
42
|
}
|