webpack-contrib / copy-webpack-plugin

Copy files and directories with webpack
MIT License
2.84k stars 281 forks source link

ERROR in directoryPaths.map is not a function with v12.x #761

Closed pachuka closed 8 months ago

pachuka commented 8 months ago

Bug report

Actual Behavior

 webpack --mode=development

<w> [ReactRefreshPlugin] Hot Module Replacement (HMR) is not enabled! React Refresh requires HMR to function properly.
assets by status 673 KiB [cached] 26 assets
assets by path . 19.9 MiB
  asset main.3c3a92acdf0b116d43e7.js 19.9 MiB [emitted] [immutable] (name: main)
  asset favicon.ico 14.7 KiB [compared for emit]
  asset index.html 3.09 KiB [emitted] [compared for emit]
Entrypoint env 222 KiB = runtime.e5782f1dc0b18febe093.js 13.2 KiB env.b24645853cfa4a176be1.js 209 KiB
Entrypoint main 19.9 MiB (451 KiB) = runtime.e5782f1dc0b18febe093.js 13.2 KiB main.3c3a92acdf0b116d43e7.js 19.9 MiB 24 auxiliary assets
orphan modules 4.09 MiB [orphan] 1729 modules
runtime modules 7.24 KiB 13 modules
cacheable modules 6.6 MiB (javascript) 451 KiB (asset)
  modules by path ./node_modules/ 5.51 MiB (javascript) 451 KiB (asset)
    javascript modules 5.51 MiB 1228 modules
    asset modules 1010 bytes (javascript) 451 KiB (asset)
      modules by path ./node_modules/@fontsource/poppins/ 756 bytes (javascript) 361 KiB (asset) 18 modules
      modules by path ./node_modules/@fontsource/mulish/ 252 bytes (javascript) 90.1 KiB (asset)
        modules by path ./node_modules/@fontsource/mulish/files/*.woff2 126 bytes (javascript) 39.6 KiB (asset) 3 modules
        modules by path ./node_modules/@fontsource/mulish/files/*.woff 126 bytes (javascript) 50.5 KiB (asset) 3 modules
  modules by path ./src/ 1.09 MiB 251 modules
  ./env.js 1 KiB [built] [code generated]
  ./CHANGELOG.md 5.06 KiB [built] [code generated]
  ./nextTick (ignored) 15 bytes [built] [code generated]

ERROR in directoryPaths.map is not a function

webpack 5.89.0 compiled with 1 error in 5365 ms

ERROR in directoryPaths.map is not a function is thrown with no additional stacktrace or context. This was not happening in latest 11.x versions.

Configuration:

    new CopyPlugin({
      patterns: [
        {
          from: '**/*',
          context: path.resolve(__dirname, 'public'),
          globOptions: { ignore: '**/index.ejs' }
        }
      ]
    }),

Expected Behavior

The webpack build should pass successfully instead of terminate mid-processing and copy in assets from public directory

How Do We Reproduce?

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

npx webpack-cli info

System: OS: macOS 14.2.1 CPU: (8) arm64 Apple M1 Pro Memory: 92.14 MB / 16.00 GB Binaries: Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node npm: 10.2.4 - ~/.nvm/versions/node/v20.10.0/bin/npm Browsers: Chrome: 120.0.6099.216 Edge: 120.0.2210.133 Firefox: 121.0.1 Safari: 17.2.1 Packages: babel-loader: 9.1.3 => 9.1.3 clean-webpack-plugin: 4.0.0 => 4.0.0 copy-webpack-plugin: 12.0.1 => 12.0.1 css-loader: 6.9.0 => 6.9.0 file-loader: 6.2.0 => 6.2.0 fork-ts-checker-webpack-plugin: 9.0.2 => 9.0.2 html-webpack-plugin: 5.6.0 => 5.6.0 raw-loader: 4.0.2 => 4.0.2 source-map-loader: 4.0.2 => 4.0.2 style-loader: 3.3.4 => 3.3.4 webpack: 5.89.0 => 5.89.0 webpack-bundle-analyzer: 4.10.1 => 4.10.1 webpack-cli: 5.1.4 => 5.1.4 webpack-dev-server: 4.15.1 => 4.15.1

alexander-akait commented 8 months ago

The bug (regression) in globby https://github.com/sindresorhus/globby/issues/262, we can't fix it here, currently you can fix it change ignore: '**/index.ejs' to ignore: ['**/index.ejs'], i.e. as an array

pachuka commented 8 months ago

Ahh, I missed that, much appreciated for the quick response/workaround.

alexander-akait commented 8 months ago

I think we can't fix this because of https://github.com/mrmlnc/fast-glob/releases/tag/3.3.1, it looks like string is not supported since 2018 and this worked just fine thanks to luck, just change it to an array

pachuka commented 8 months ago

Yep, agreed was following that chain. Updating to the array did solve the issue. Given 12.x is a major release this "breaking" is OK and hopefully folks will see this issue if they run into it :). Appreciate the help!

Not sure if you can edit the release notes on the 12.0.0, but if so, maybe worth noting that there.

alexander-akait commented 8 months ago

@pachuka Feel free to send a PR with this updating, I am fine with it