-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependency Extraction Webpack Plugin: Make the plugin work when using…
… `optimizations.runtimeChunk = 'single'` (#26214) * Include asset filenames in snapshots * Use entrypoint chunk instead of runtime chunk This results in the asset files being named after the entry points, instead of the runtime chunk when using `runtimeChunk = 'single'`. Fixes #24352 * Add outputFilename option Allows specifying the asset filename format separately from the output filename format. This is useful when the output filenames include a hash.
- Loading branch information
1 parent
50b19e7
commit d2d673d
Showing
12 changed files
with
199 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...pendency-extraction-webpack-plugin/test/fixtures/option-function-output-filename/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { isBlobURL } from '@wordpress/blob'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import _ from 'lodash'; | ||
|
||
_.isEmpty( isBlobURL( '' ) ); |
14 changes: 14 additions & 0 deletions
14
...extraction-webpack-plugin/test/fixtures/option-function-output-filename/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const DependencyExtractionWebpackPlugin = require( '../../..' ); | ||
|
||
module.exports = { | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { | ||
outputFilename( chunkData ) { | ||
return `chunk--${ chunkData.chunk.name }--[name].asset.php`; | ||
}, | ||
} ), | ||
], | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages/dependency-extraction-webpack-plugin/test/fixtures/option-output-filename/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { isBlobURL } from '@wordpress/blob'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import _ from 'lodash'; | ||
|
||
_.isEmpty( isBlobURL( '' ) ); |
12 changes: 12 additions & 0 deletions
12
...pendency-extraction-webpack-plugin/test/fixtures/option-output-filename/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const DependencyExtractionWebpackPlugin = require( '../../..' ); | ||
|
||
module.exports = { | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { | ||
outputFilename: '[name]-foo.asset.php', | ||
} ), | ||
], | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/dependency-extraction-webpack-plugin/test/fixtures/runtime-chunk-single/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { isBlobURL } from '@wordpress/blob'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import atob from 'atob'; | ||
|
||
isBlobURL( '' ); | ||
atob( 'SGVsbG8sIFdvcmxkIQ==' ); |
11 changes: 11 additions & 0 deletions
11
packages/dependency-extraction-webpack-plugin/test/fixtures/runtime-chunk-single/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { isBlobURL } from '@wordpress/blob'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import _ from 'lodash'; | ||
|
||
_.isEmpty( isBlobURL( '' ) ); |
15 changes: 15 additions & 0 deletions
15
...dependency-extraction-webpack-plugin/test/fixtures/runtime-chunk-single/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const DependencyExtractionWebpackPlugin = require( '../../..' ); | ||
|
||
module.exports = { | ||
entry: { | ||
a: './a', | ||
b: './b', | ||
}, | ||
plugins: [ new DependencyExtractionWebpackPlugin() ], | ||
optimization: { | ||
runtimeChunk: 'single', | ||
}, | ||
}; |