0.0.4 • Published 3 years ago

exports-library-plugin v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Webpack ExportsLibraryPlugin

I threw this together because Node 14+ supports ESM style imports against CommonJS modules, but only if exports are directly assigned to exports, but not if exports is reassigned.

Webpack reassigns exports for some reason, so resulting libraries don't work this way.

This plugin will add code to export the library in a node-friendly way.

Usage

npm install --save-dev exports-library-plugin

In webpack.config.js, either in entry[name] or in output:

library: {
  name: 'exports',
  type: 'assign-properties'
}

Then

const ExportsLibraryPlugin = require('exports-library-plugin')

module.exports = {
  plugins: [
    new ExportsLibraryPlugin()
  ]
}

This will preserve the ability to import from the resulting library.

Cheers!!

PS: If someone from Webpack would like to do this properly, I would greatly appreciate it!

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago