webpack-contrib/copy-webpack-plugin

No default export found in imported module "copy-webpack-plugin" in webpack.config.ts

Closed this issue · 1 comments

Bug report

When I am using the CopyWebpackPlugin (the most recent version) in webpack.config.ts, I am getting an error No default export found in imported module "copy-webpack-plugin from ESlint. The plugin still works as expected but the only way to pass the error is to disable ESlint.

Actual Behavior

  1. I import the CopyWebpackPlugin into the webpack.config.ts with the import statement like so:

import CopyWebpackPlugin from 'copy-webpack-plugin';

  1. I am getting an error with no default export module available:
Capture d’écran, le 2024-05-15 à 20 26 57

It seems that this happens specifically when it is a Typescript config. Adding // eslint-disable-next-line import/default resolves the issue.

Expected Behavior

I expected the import statement to work when being used in the Typescript config.

How Do We Reproduce?

Here is a detailed configuration of my webpack.config.ts:

https://github.com/Automattic/studio/blob/93aad76e8bf0b500fd19710bb8b2067b4aa78414/webpack.main.config.ts#L3

Please paste the results of npx webpack-cli info here, and mention other relevant information

    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 113.81 MB / 16.00 GB
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v15.0.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
  Browsers:
    Chrome: 124.0.6367.207
    Safari: 17.0
  Packages:
    copy-webpack-plugin: ^12.0.2 => 12.0.2 
    css-loader: ^6.0.0 => 6.9.1 
    fork-ts-checker-webpack-plugin: ^7.2.13 => 7.3.0 
    node-loader: ^2.0.0 => 2.0.0 
    postcss-loader: ^7.3.3 => 7.3.4 
    ts-loader: ^9.2.2 => 9.5.1 
    webpack-dev-middleware: 5.3.4 => 5.3.4 

Please open an issue in eslint-plugin-import, we can't fix it here, sorry