@gechiui/library-export-default-webpack-plugin

2.2.0 • Public • Published

Library Export Default Webpack Plugin

DEPRECATED for webpack v5: please use output.library.export instead.

Webpack plugin for exporting default property for selected libraries which use ES6 Modules. Implementation is based on the Webpack's core plugin ExportPropertyMainTemplatePlugin. The only difference is that this plugin allows to include all entry point names where the default export of your entry point will be assigned to the library target.

Installation

Install the module

npm install @gechiui/library-export-default-webpack-plugin --save

Note: This package requires Node.js 12.0.0 or later. It is not compatible with older versions. It works only with webpack v4.

Usage

Construct an instance of LibraryExportDefaultPlugin in your Webpack configurations plugins entry, passing an array where values correspond to the entry point name.

The following example selects boo entry point to be updated by the plugin. When compiled, the built file will ensure that default value exported for the chunk will be assigned to the global variable gc.boo. foo chunk will remain untouched.

const LibraryExportDefaultPlugin = require( '@gechiui/library-export-default-webpack-plugin' );

module.exports = {
	// ...

	entry: {
		boo: './packages/boo',
		foo: './packages/foo',
	},

	output: {
		filename: 'build/[name].js',
		path: __dirname,
		library: [ 'gc', '[name]' ],
		libraryTarget: 'this',
	},

	plugins: [ new LibraryExportDefaultPlugin( [ 'boo' ] ) ],
};



Code is Poetry.

/@gechiui/library-export-default-webpack-plugin/

    Package Sidebar

    Install

    npm i @gechiui/library-export-default-webpack-plugin

    Weekly Downloads

    0

    Version

    2.2.0

    License

    GPL-2.0-or-later

    Unpacked Size

    40.3 kB

    Total Files

    4

    Last publish

    Collaborators

    • gechiui