johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 137 forks source link

replace default export with named export CleanWebpackPlugin #138

Closed chrisblossom closed 5 years ago

chrisblossom commented 5 years ago

Please hold off on merging this as it is a breaking change.

https://github.com/johnagan/clean-webpack-plugin/issues/114#issuecomment-473204185 Oh, this lib is written in TS, I thought it just had a d.ts file. Then I would not change anything and just document the fact that consumers needs to add .default if their IDE/typechecker is yelling at them. The interop with CJS will always be a bit painful/ugly I think.

Jest will move to ES module exports in the next major and ditch export =.

One thing you can do is have a named export in addition to the default one, so people can do const CleanPlugin = require('clean-webpack-plugin').plugin; or something. Not much of a difference, but looks better than default, at least to my eyes

This PR removes the default export and replaces it with a named export CleanWebpackPlugin. It will work better with editors, improved es module/common js interoperability, and removes the (barely maintained) plugin babel-plugin-add-module-exports.

To upgrade users will need to update how they require/import the plugin.

// es modules
import { CleanWebpackPlugin } from 'clean-webpack-plugin';

// common js
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

This will also fix https://github.com/johnagan/clean-webpack-plugin/issues/114.

I personally think this is a good/future proof change. Thoughts?

codecov-io commented 5 years ago

Codecov Report

Merging #138 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #138   +/-   ##
=======================================
  Coverage   98.86%   98.86%           
=======================================
  Files           1        1           
  Lines          88       88           
  Branches       30       30           
=======================================
  Hits           87       87           
  Misses          1        1
Impacted Files Coverage Δ
src/clean-webpack-plugin.ts 98.86% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b74ac15...d0e3408. Read the comment docs.