Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purgecss-webpack-plugin types are incorrect #820

Closed
G-Rath opened this issue Dec 19, 2021 · 0 comments
Closed

purgecss-webpack-plugin types are incorrect #820

G-Rath opened this issue Dec 19, 2021 · 0 comments
Labels
Milestone

Comments

@G-Rath
Copy link
Contributor

G-Rath commented Dec 19, 2021

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:

image

image

image

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:

  1. Setup a basic project with TypeScript & checkJs enabled
  2. Create a new JS file
  3. Attempt to create a webpack config using purgecss-webpack-plugin
  4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants