windicss / windicss-webpack-plugin

🍃 Windi CSS for webpack ⚡
https://windicss.org/integrations/webpack.html
79 stars 19 forks source link

[Next.js] TypeError: WindiCSSWebpackPlugin is not a constructor #98

Closed HenrijsS closed 2 years ago

HenrijsS commented 2 years ago

Describe the bug The module seems to not recognize the class.

To Reproduce Steps to reproduce the behavior:

  1. Install Next@latest
  2. Add windicss-webpack-plugin
  3. Import it in next.config.js
  4. See it's not recognized as a class

Expected behavior When I started the project, the plugin was at version 1.4.10 and that seems to be working fine. The issue breaks on the latest 1.5.5 version.

Here's my next.config.js

const WindiCSSWebpackPlugin = require("windicss-webpack-plugin").default;

module.exports = {
    reactStrictMode: true,
    webpack(config) {
        config.plugins.push(new WindiCSSWebpackPlugin());
        return config;
    },
    images: {
        deviceSizes: [828, 1080, 1200, 1920, 2048, 3840],
    },
};

I've also looked at the package in node_modules for both v1.4.10 and v1.5.5 and they both seem to export the same Class with a constructor.

EDIT: I've created a simple Repo for the issue: https://github.com/HenrijsS/windicss-nextjs-bug Try switching from v1.4.10 and v1.5.5

HenrijsS commented 2 years ago

Nevermind. Removed the .default from the require and it worked. Saw it in the release notes and somehow missed it while visiting the docs.

Defite commented 2 years ago

Nevermind. Removed the .default from the require and it worked. Saw it in the release notes and somehow missed it while visiting the docs.

Strange, but I still have this error.

HenrijsS commented 2 years ago

@Defite Make sure you're on the latest version. Can you please share the Config file?

Defite commented 2 years ago

@Defite Make sure you're on the latest version. Can you please share the Config file?

My fault, sorry. Had to clean .next folder and reinstall node_modules. Now it's ok.