Dependency Extraction Webpack Plugin: Handle irregular dependency names (https://github.com/woocommerce/woocommerce-admin/pull/5770)
* fix irregular dependency names * starter pack * blocks registry * update docs
This commit is contained in:
parent
6e2bf974c7
commit
8c8efd59fc
|
@ -22,6 +22,6 @@
|
|||
"devDependencies": {
|
||||
"@wordpress/scripts": "^12.2.1",
|
||||
"@woocommerce/eslint-plugin": "1.0.0-beta.0",
|
||||
"@woocommerce/dependency-extraction-webpack-plugin": "1.0.1"
|
||||
"@woocommerce/dependency-extraction-webpack-plugin": "1.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# 1.1.0
|
||||
|
||||
- Fix: Handle irregular package names that don't conform to a pattern.
|
||||
|
||||
# 1.0.1
|
||||
|
||||
- Fix: Avoid tanspiling packaged code.
|
||||
|
|
|
@ -26,6 +26,9 @@ module.exports = {
|
|||
|
||||
Additional module requests on top of Wordpress [Dependency Extraction Webpack Plugin](https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin) are:
|
||||
|
||||
| Request | Global | Script handle |
|
||||
| ---------------- | --------- | ------------- |
|
||||
| `@woocommerce/*` | `wc['*']` | `wc-*` |
|
||||
| Request | Global | Script handle |
|
||||
| ------------------------------ | ------------------------ | -------------------- |
|
||||
| `@woocommerce/data` | `wc['data']` | `wc-store-data` |
|
||||
| `@woocommerce/csv-export` | `wc['csvExport']` | `wc-csv` |
|
||||
| `@woocommerce/blocks-registry` | `wc['wcBlocksRegistry']` | `wc-blocks-registry` |
|
||||
| `@woocommerce/*` | `wc['*']` | `wc-*` |
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@woocommerce/dependency-extraction-webpack-plugin",
|
||||
"version": "1.0.1",
|
||||
"version": "1.1.0",
|
||||
"description": "WooCommerce Dependency Extraction Webpack Plugin",
|
||||
"author": "Automattic",
|
||||
"license": "GPL-2.0-or-later",
|
||||
|
|
|
@ -19,16 +19,32 @@ function camelCaseDash( string ) {
|
|||
|
||||
const wooRequestToExternal = ( request ) => {
|
||||
if ( packages.includes( request ) ) {
|
||||
return [
|
||||
'wc',
|
||||
camelCaseDash( request.substring( WOOCOMMERCE_NAMESPACE.length ) ),
|
||||
];
|
||||
const handle = request.substring( WOOCOMMERCE_NAMESPACE.length );
|
||||
const irregularExternalMap = {
|
||||
'blocks-registry': [ 'wc', 'wcBlocksRegistry' ],
|
||||
};
|
||||
|
||||
if ( irregularExternalMap[ handle ] ) {
|
||||
return irregularExternalMap[ handle ];
|
||||
}
|
||||
|
||||
return [ 'wc', camelCaseDash( handle ) ];
|
||||
}
|
||||
};
|
||||
|
||||
const wooRequestToHandle = ( request ) => {
|
||||
if ( packages.includes( request ) ) {
|
||||
return 'wc-' + request.substring( WOOCOMMERCE_NAMESPACE.length );
|
||||
const handle = request.substring( WOOCOMMERCE_NAMESPACE.length );
|
||||
const irregularHandleMap = {
|
||||
data: 'wc-store-data',
|
||||
'csv-export': 'wc-csv',
|
||||
};
|
||||
|
||||
if ( irregularHandleMap[ handle ] ) {
|
||||
return irregularHandleMap[ handle ];
|
||||
}
|
||||
|
||||
return 'wc-' + handle;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue