You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Currently the types for purgecss-webpack-plugin describe it as exporting the plugin as default, which isn't true - it exports it as module.exports (which in TypeScript is represented by export = instead of export default).
Overall I believe that this is a result of using esModuleInterop - in Typescript or transpiled contexts (e.g. Babel transpiling ESM) this isn't an issue, as they handle this edge case (it's the whole point of esModuleInterop), but if you're using vanilla javascript TypeScript will complain as it wants you to do const { default: ... } = require('purgecss-webpack-plugin') which will never work:
Since turning off esModuleInterop would have some knock-on effects, I think exporting the class as a named export (as well as a default) should also resolve this by allowing us to do const { PurgecssWebpackPlugin } = require('...').
To Reproduce
Steps to reproduce the behavior:
Setup a basic project with TypeScript & checkJs enabled
Create a new JS file
Attempt to create a webpack config using purgecss-webpack-plugin
See error
Expected behavior
No error from TypeScript, and that the config works
Screenshots
(have included screenshots above)
Environment (please complete the following information):
OS: Ubuntu 18.04 (via Windows 10, WSLv1)
Package purgecss-webpack-plugin
Version v4.1.3
Additional context
I'm happy to do a PR adding the named export, if you're open to that.
The text was updated successfully, but these errors were encountered:
Describe the bug
Currently the types for
purgecss-webpack-plugin
describe it as exporting the plugin asdefault
, which isn't true - it exports it asmodule.exports
(which in TypeScript is represented byexport =
instead ofexport default
).Overall I believe that this is a result of using
esModuleInterop
- in Typescript or transpiled contexts (e.g. Babel transpiling ESM) this isn't an issue, as they handle this edge case (it's the whole point ofesModuleInterop
), but if you're using vanilla javascript TypeScript will complain as it wants you to doconst { default: ... } = require('purgecss-webpack-plugin')
which will never work:Since turning off
esModuleInterop
would have some knock-on effects, I think exporting the class as a named export (as well as a default) should also resolve this by allowing us to doconst { PurgecssWebpackPlugin } = require('...')
.To Reproduce
Steps to reproduce the behavior:
checkJs
enabledpurgecss-webpack-plugin
Expected behavior
No error from TypeScript, and that the config works
Screenshots
(have included screenshots above)
Environment (please complete the following information):
purgecss-webpack-plugin
Additional context
I'm happy to do a PR adding the named export, if you're open to that.
The text was updated successfully, but these errors were encountered: