build icon indicating copy to clipboard operation
build copied to clipboard

copy-webpack-plugin causes build failure

Open larkonesvk opened this issue 2 years ago • 4 comments

Describe the bug

Adding plugin causes build failure in netlify. They use import() to load ESM dependencies, looks like your env is not supported it

Steps to reproduce

When running webpack build, it fails on:
8:55:20 PM: $ npm run build
8:55:20 PM: > [email protected] build /opt/build/repo
8:55:20 PM: > webpack --mode production
8:55:31 PM: (node:3235) ExperimentalWarning: The ESM module loader is experimental.
8:55:31 PM: [webpack-cli] HookWebpackError: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at makeWebpackError (/opt/build/repo/node_modules/webpack/lib/HookWebpackError.js:48:9)
8:55:31 PM: at /opt/build/repo/node_modules/webpack/lib/Compilation.js:3059:12
8:55:31 PM: at eval (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), :78:1)
8:55:31 PM: at /opt/build/repo/node_modules/webpack/lib/Compilation.js:510:26
8:55:31 PM: at /opt/build/repo/node_modules/copy-webpack-plugin/dist/index.js:708:13
8:55:31 PM: -- inner error --
8:55:31 PM: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:720:11)
8:55:31 PM: at Loader.resolve (internal/modules/esm/loader.js:97:40)
8:55:31 PM: at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
8:55:31 PM: at ModuleWrap. (internal/modules/esm/module_job.js:42:40)
8:55:31 PM: at link (internal/modules/esm/module_job.js:41:36)
8:55:31 PM: caused by plugins in Compilation.hooks.processAssets
8:55:31 PM: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
8:55:31 PM: at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:720:11)
8:55:31 PM: at Loader.resolve (internal/modules/esm/loader.js:97:40)
8:55:31 PM: at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
8:55:31 PM: at ModuleWrap. (internal/modules/esm/module_job.js:42:40)
8:55:31 PM: at link (internal/modules/esm/module_job.js:41:36)

Configuration

No response

Environment

System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 17.37 GB / 31.78 GB
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (100.0.1185.36)
Internet Explorer: 11.0.19041.1566
Packages:
babel-loader: ^8.2.4 => 8.2.4
clean-webpack-plugin: ^4.0.0 => 4.0.0
css-loader: ^6.7.1 => 6.7.1
html-webpack-plugin: ^5.5.0 => 5.5.0
postcss-loader: ^6.2.1 => 6.2.1
style-loader: ^3.3.1 => 3.3.1
ts-loader: ^9.2.8 => 9.2.8
webpack: ^5.70.0 => 5.72.0
webpack-bundle-analyzer: ^4.5.0 => 4.5.0
webpack-cli: ^4.9.2 => 4.9.2
webpack-dev-server: ^4.7.4 => 4.8.1
copy-webpack-plugin: ^10.2.4 => 10.2.4

larkonesvk avatar Apr 12 '22 09:04 larkonesvk

Hi @larkonesvk, thanks for reporting the issue. I transferred it to a more suitable repo.

Does the problem happen when running the build outside of Netlify? That is, if you run npm run build locally, does the build finish successfully?

Also, do you mind posting this question in https://answers.netlify.com/? You should be able to get some answers there and it will help us confirm if this is a bug with our build system or something specific to your configuration

erezrokah avatar Apr 12 '22 11:04 erezrokah

Nope, when I runbuild on my local machine or even in gitlab ci pipeline everything worked fine. Ok I will post question in https://answers.netlify.com/.

larkonesvk avatar Apr 12 '22 13:04 larkonesvk

Nope, when I runbuild on my local machine or even in gitlab ci pipeline everything worked fine. Ok I will post question in https://answers.netlify.com/.

Thanks @larkonesvk, can you provide an example public repo that reproduces this issue?

erezrokah avatar Apr 12 '22 13:04 erezrokah

@erezrokah I ran into this same issue on my public repo. The version at https://github.com/jeffslofish/ics2csv-report/tree/b6e0ca24192633e4fc2cc31a7981d5d1813b7099 is using [email protected] and I get the error above when building on netlify. After downgrading copy-webpack-plugin to version 6.4.1 then it works fine.

jeffslofish avatar Jul 26 '22 19:07 jeffslofish

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!

github-actions[bot] avatar Jul 27 '23 14:07 github-actions[bot]

This issue was closed because it had no activity for over 1 year.

github-actions[bot] avatar Aug 10 '23 14:08 github-actions[bot]