woocommerce/plugins/woocommerce-admin/packages/dependency-extraction-webpa...
louwie17 69dfdf733c Add tree shaking support for woocommerce components (https://github.com/woocommerce/woocommerce-admin/pull/7034)
* Add woocommerce/components tree shaking support

* Compile individual component styles for individual use

* Update readme

* Add changelog

* Fix correct import

* Update readme with dependency extraction updates

* Update dependency extraction naming
2021-05-26 16:35:46 -03:00
..
assets Try ExPlat: Add A/A test (https://github.com/woocommerce/woocommerce-admin/pull/6669) 2021-04-15 13:32:46 +12:00
src Add tree shaking support for woocommerce components (https://github.com/woocommerce/woocommerce-admin/pull/7034) 2021-05-26 16:35:46 -03:00
.npmrc New Package: DependencyExtractionWebpackPlugin (https://github.com/woocommerce/woocommerce-admin/pull/5198) 2020-10-15 09:50:57 +13:00
CHANGELOG.md Add tree shaking support for woocommerce components (https://github.com/woocommerce/woocommerce-admin/pull/7034) 2021-05-26 16:35:46 -03:00
README.md Add tree shaking support for woocommerce components (https://github.com/woocommerce/woocommerce-admin/pull/7034) 2021-05-26 16:35:46 -03:00
package.json Making experimental package public and updating its dependency versions (https://github.com/woocommerce/woocommerce-admin/pull/6810) 2021-04-16 15:34:15 +12:00

README.md

Dependency Extraction Webpack Plugin

Extends Wordpress Dependency Extraction Webpack Plugin to automatically include WooCommerce dependencies in addition to WordPress dependencies.

Installation

Install the module

npm install @woocommerce/dependency-extraction-webpack-plugin --save-dev

Usage

Use this as you would Dependency Extraction Webpack Plugin. The API is exactly the same, except that WooCommerce packages are also handled automatically.

// webpack.config.js
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );

module.exports = {
	// …snip
	plugins: [ new WooCommerceDependencyExtractionWebpackPlugin() ],
};

Additional module requests on top of Wordpress Dependency Extraction Webpack Plugin are:

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/settings wc['wcSettings'] wc-settings
@woocommerce/* wc['*'] wc-*

Options

An object can be passed to the constructor to customize the behavior, for example:

module.exports = {
	plugins: [
		new WooCommerceDependencyExtractionWebpackPlugin( {
			bundledPackages: [ '@woocommerce/components' ],
		} ),
	],
};
bundledPackages
  • Type: array
  • Default: []

A list of potential WooCommerce excluded packages, this will include the excluded package within the bundle (example above).

For more supported options see the original dependency extraction plugin.