@wordpress/dependency-extraction-webpack-plugin
Advanced tools
Comparing version 2.9.0 to 3.0.0-next.0
@@ -5,2 +5,8 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/master/packages#maintaining-changelogs. --> | ||
## 3.0.0-next.0 (2021-01-20) | ||
### Breaking Changes | ||
- Increase the minimum Node.js version to 12 ([#27934](https://github.com/WordPress/gutenberg/pull/27934)). | ||
## 2.9.0 (2020-12-17) | ||
@@ -10,3 +16,3 @@ | ||
- Make the plugin compatible with webpack 5. | ||
- Make the plugin compatible with webpack 5. | ||
@@ -17,3 +23,3 @@ ## 2.7.0 (2020-06-15) | ||
- Include TypeScript type declarations ([#22498](https://github.com/WordPress/gutenberg/pull/22498)) | ||
- Include TypeScript type declarations ([#22498](https://github.com/WordPress/gutenberg/pull/22498)) | ||
@@ -24,3 +30,3 @@ ## 2.5.0 (2020-04-01) | ||
- The plugin now supports an optional `combinedOutputFile` option that is useful only when another `combineAssets` option is enabled. It allows providing a custom output file for the generated single assets file ([#20844](https://github.com/WordPress/gutenberg/pull/20844)). | ||
- The plugin now supports an optional `combinedOutputFile` option that is useful only when another `combineAssets` option is enabled. It allows providing a custom output file for the generated single assets file ([#20844](https://github.com/WordPress/gutenberg/pull/20844)). | ||
@@ -31,3 +37,3 @@ ## 2.3.0 (2020-02-21) | ||
- The plugin now supports optional `combineAssets` option. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory ([#20330](https://github.com/WordPress/gutenberg/pull/20330)). | ||
- The plugin now supports optional `combineAssets` option. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory ([#20330](https://github.com/WordPress/gutenberg/pull/20330)). | ||
@@ -38,3 +44,3 @@ ## 2.0.0 (2019-09-16) | ||
- The plugin now adds, for each entry point, an asset file saved by default in PHP format that declares an object with the list of WordPress script dependencies for the entry point ([#17298](https://github.com/WordPress/gutenberg/pull/17298)). There is also an option to use JSON as the output format. The shape of metadata is also different from the previous version. Note that the file name has also changed from `*.deps.json` to `*.asset.json` or `*.asset.php`. References to the `*.deps.json` filename will need to be updated, even if you choose to use the JSON formatted file. Read more in the [README](./README.md) file. | ||
- The plugin now adds, for each entry point, an asset file saved by default in PHP format that declares an object with the list of WordPress script dependencies for the entry point ([#17298](https://github.com/WordPress/gutenberg/pull/17298)). There is also an option to use JSON as the output format. The shape of metadata is also different from the previous version. Note that the file name has also changed from `*.deps.json` to `*.asset.json` or `*.asset.php`. References to the `*.deps.json` filename will need to be updated, even if you choose to use the JSON formatted file. Read more in the [README](./README.md) file. | ||
@@ -45,3 +51,3 @@ ## 1.0.1 (2019-05-22) | ||
- Fix missing file entry for `util.js` in `package.json` | ||
- Fix missing file entry for `util.js` in `package.json` | ||
@@ -52,2 +58,2 @@ ## 1.0.0 (2019-05-21) | ||
- Introduce the `@wordpress/dependency-extraction-webpack-plugin` package. | ||
- Introduce the `@wordpress/dependency-extraction-webpack-plugin` package. |
### WordPress - Web publishing software | ||
Copyright 2011-2020 by the contributors | ||
Copyright 2011-2021 by the contributors | ||
@@ -37,3 +37,3 @@ This program is free software; you can redistribute it and/or modify | ||
WordPress is released under the GPL | ||
--- | ||
@@ -45,3 +45,3 @@ | ||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. | ||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
@@ -140,7 +140,7 @@ | ||
**a)** You must cause the modified files to carry prominent notices | ||
stating that you changed the files and the date of any change. | ||
**b)** You must cause any work that you distribute or publish, that in | ||
@@ -151,3 +151,3 @@ whole or in part contains or is derived from the Program or any part | ||
**c)** If the modified program normally reads commands interactively | ||
@@ -189,3 +189,3 @@ when run, you must cause it, when started running for such interactive | ||
**a)** Accompany it with the complete corresponding machine-readable | ||
@@ -195,3 +195,3 @@ source code, which must be distributed under the terms of Sections 1 | ||
**b)** Accompany it with a written offer, valid for at least three | ||
@@ -204,3 +204,3 @@ years, to give any third party, for a charge no more than your cost of | ||
**c)** Accompany it with the information you received as to the offer | ||
@@ -380,3 +380,3 @@ to distribute corresponding source code. (This alternative is allowed | ||
type `show w'. This is free software, and you are welcome | ||
to redistribute it under certain conditions; type `show c' | ||
to redistribute it under certain conditions; type `show c' | ||
for details. | ||
@@ -396,3 +396,3 @@ | ||
interest in the program `Gnomovision' | ||
(which makes passes at compilers) written | ||
(which makes passes at compilers) written | ||
by James Hacker. | ||
@@ -399,0 +399,0 @@ |
{ | ||
"name": "@wordpress/dependency-extraction-webpack-plugin", | ||
"version": "2.9.0", | ||
"version": "3.0.0-next.0", | ||
"description": "Extract WordPress script dependencies from webpack bundles.", | ||
@@ -22,2 +22,5 @@ "author": "The WordPress Contributors", | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"files": [ | ||
@@ -31,3 +34,3 @@ "lib", | ||
"json2php": "^0.0.4", | ||
"webpack-sources": "^1.3.0" | ||
"webpack-sources": "^2.2.0" | ||
}, | ||
@@ -40,3 +43,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "0f57de12b3c47128b216629b08e5c1657e1ee329" | ||
"gitHead": "eb424c9ed3dffb9ca4c31d7c81a3be85b0c94a74" | ||
} |
128
README.md
@@ -5,5 +5,5 @@ # Dependency Extraction Webpack Plugin | ||
- Externalize dependencies that are available as script dependencies on modern WordPress sites. | ||
- Add an asset file for each entry point that declares an object with the list of WordPress script dependencies for the | ||
entry point. The asset file also contains the current version calculated for the current source code. | ||
- Externalize dependencies that are available as script dependencies on modern WordPress sites. | ||
- Add an asset file for each entry point that declares an object with the list of WordPress script dependencies for the | ||
entry point. The asset file also contains the current version calculated for the current source code. | ||
@@ -23,2 +23,4 @@ This allows JavaScript bundles produced by webpack to leverage WordPress style dependency sharing | ||
**Note**: This package requires Node.js 12.0.0 or later. It also requires webpack 4.8.3 and newer. It is not compatible with older versions. | ||
## Usage | ||
@@ -35,7 +37,5 @@ | ||
module.exports = { | ||
// …snip | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin(), | ||
] | ||
} | ||
// …snip | ||
plugins: [ new DependencyExtractionWebpackPlugin() ], | ||
}; | ||
``` | ||
@@ -50,14 +50,15 @@ | ||
const config = { | ||
...defaultConfig, | ||
plugins: [ | ||
...defaultConfig.plugins.filter( | ||
plugin => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin', | ||
), | ||
new DependencyExtractionWebpackPlugin( { | ||
injectPolyfill: true, | ||
requestToExternal(request) { | ||
/* My externals */ | ||
}, | ||
} ), | ||
], | ||
...defaultConfig, | ||
plugins: [ | ||
...defaultConfig.plugins.filter( | ||
( plugin ) => | ||
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin' | ||
), | ||
new DependencyExtractionWebpackPlugin( { | ||
injectPolyfill: true, | ||
requestToExternal( request ) { | ||
/* My externals */ | ||
}, | ||
} ), | ||
], | ||
}; | ||
@@ -83,12 +84,12 @@ ``` | ||
| Request | Global | Script handle | | ||
| --- | --- | --- | | ||
| Request | Global | Script handle | | ||
| ---------------------------- | -------------------- | ------------- | | ||
| `@babel/runtime/regenerator` | `regeneratorRuntime` | `wp-polyfill` | | ||
| `@wordpress/*` | `wp['*']` | `wp-*` | | ||
| `jquery` | `jQuery` | `jquery` | | ||
| `lodash-es` | `lodash` | `lodash` | | ||
| `lodash` | `lodash` | `lodash` | | ||
| `moment` | `moment` | `moment` | | ||
| `react-dom` | `ReactDOM` | `react-dom` | | ||
| `react` | `React` | `react` | | ||
| `@wordpress/*` | `wp['*']` | `wp-*` | | ||
| `jquery` | `jQuery` | `jquery` | | ||
| `lodash-es` | `lodash` | `lodash` | | ||
| `lodash` | `lodash` | `lodash` | | ||
| `moment` | `moment` | `moment` | | ||
| `react-dom` | `ReactDOM` | `react-dom` | | ||
| `react` | `React` | `react` | | ||
@@ -111,6 +112,6 @@ **Note:** This plugin overlaps with the functionality provided by [webpack | ||
module.exports = { | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ), | ||
] | ||
} | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ), | ||
], | ||
}; | ||
``` | ||
@@ -120,4 +121,4 @@ | ||
- Type: string | ||
- Default: `php` | ||
- Type: string | ||
- Default: `php` | ||
@@ -128,4 +129,4 @@ The output format for the generated asset file. There are two options available: 'php' or 'json'. | ||
- Type: boolean | ||
- Default: `false` | ||
- Type: boolean | ||
- Default: `false` | ||
@@ -136,4 +137,4 @@ By default, one asset file is created for each entry point. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory. | ||
- Type: string | ||
- Default: `null` | ||
- Type: string | ||
- Default: `null` | ||
@@ -144,4 +145,4 @@ This option is useful only when the `combineAssets` option is enabled. It allows providing a custom output file for the generated single assets file. It's possible to provide a path that is relative to the output directory. | ||
- Type: boolean | ||
- Default: `true` | ||
- Type: boolean | ||
- Default: `true` | ||
@@ -152,4 +153,4 @@ Pass `useDefaults: false` to disable the default request handling. | ||
- Type: boolean | ||
- Default: `false` | ||
- Type: boolean | ||
- Default: `false` | ||
@@ -161,8 +162,7 @@ Force `wp-polyfill` to be included in each entry point's dependency list. This would be the same as | ||
- Type: function | ||
- Type: function | ||
`requestToExternal` allows the module handling to be customized. The function should accept a | ||
module request string and may return a string representing the global variable to use. An array of | ||
strings may be used to access globals via an object path, e.g. `wp.i18n` may be represented as `[ | ||
'wp', 'i18n' ]`. | ||
strings may be used to access globals via an object path, e.g. `wp.i18n` may be represented as `[ 'wp', 'i18n' ]`. | ||
@@ -181,15 +181,12 @@ `requestToExternal` provided via configuration has precedence over default external handling. | ||
function requestToExternal( request ) { | ||
// Handle imports like `import myModule from 'my-module'` | ||
if ( request === 'my-module' ) { | ||
// Expect to find `my-module` as myModule in the global scope: | ||
return 'myModule'; | ||
} | ||
// Handle imports like `import myModule from 'my-module'` | ||
if ( request === 'my-module' ) { | ||
// Expect to find `my-module` as myModule in the global scope: | ||
return 'myModule'; | ||
} | ||
} | ||
module.exports = { | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { requestToExternal } ), | ||
] | ||
} | ||
plugins: [ new DependencyExtractionWebpackPlugin( { requestToExternal } ) ], | ||
}; | ||
``` | ||
@@ -199,3 +196,3 @@ | ||
- Type: function | ||
- Type: function | ||
@@ -218,15 +215,12 @@ All of the external modules handled by the plugin are expected to be WordPress script dependencies | ||
function requestToHandle( request ) { | ||
// Handle imports like `import myModule from 'my-module'` | ||
if ( request === 'my-module' ) { | ||
// `my-module` depends on the script with the 'my-module-script-handle' handle. | ||
return 'my-module-script-handle'; | ||
} | ||
// Handle imports like `import myModule from 'my-module'` | ||
if ( request === 'my-module' ) { | ||
// `my-module` depends on the script with the 'my-module-script-handle' handle. | ||
return 'my-module-script-handle'; | ||
} | ||
} | ||
module.exports = { | ||
plugins: [ | ||
new DependencyExtractionWebpackPlugin( { requestToExternal } ), | ||
] | ||
} | ||
plugins: [ new DependencyExtractionWebpackPlugin( { requestToExternal } ) ], | ||
}; | ||
``` | ||
@@ -233,0 +227,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
39724
8
294
1
235
+ Added@types/node@22.13.1(transitive)
+ Addedcaniuse-lite@1.0.30001698(transitive)
+ Addedelectron-to-chromium@1.5.96(transitive)
+ Addedenhanced-resolve@5.18.1(transitive)
+ Addedterser@5.38.1(transitive)
+ Addedwebpack-sources@2.3.1(transitive)
- Removed@types/node@22.13.0(transitive)
- Removedcaniuse-lite@1.0.30001696(transitive)
- Removedelectron-to-chromium@1.5.90(transitive)
- Removedenhanced-resolve@5.18.0(transitive)
- Removedterser@5.37.0(transitive)
- Removedwebpack-sources@1.4.3(transitive)
Updatedwebpack-sources@^2.2.0