Skip to content

Breaking change with import via CommonJS in 2.5.0 #896

Closed
@Cherry

Description

@Cherry

Bug report

Since 2.5.0, importing via CommonJS no longer matches what it did in the past, or what is shown in the documentation.

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
console.log(MiniCssExtractPlugin);
{
  default: [class MiniCssExtractPlugin] {
    loader: 'E:\\GitHub\\website\\node_modules\\mini-css-extract-plugin\\dist\\loader.js'
  },
  pluginName: 'mini-css-extract-plugin',
  pluginSymbol: Symbol(mini-css-extract-plugin)
}

Actual Behavior

new MiniCssExtractPlugin()

This throws a TypeError: MiniCssExtractPlugin is not a constructor when attempting to use in the documented way. Using the exported .default works fine, but I assume is not the intended behaviour.

Expected Behavior

It should behave exactly as it did in 2.4.6 and below. This is likely the result of the change to the main export in 5b5654c#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L14, and the deletion of the src/cjs.js script and its build.

Previously in 2.4.6:

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
console.log(MiniCssExtractPlugin);
[class MiniCssExtractPlugin] {
  loader: 'E:\\GitHub\\website\\node_modules\\mini-css-extract-plugin\\dist\\loader.js'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions