Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails if webpack config exports an array of functions #1935

Closed
danoc opened this issue Oct 13, 2020 · 2 comments · Fixed by #1946
Closed

Build fails if webpack config exports an array of functions #1935

danoc opened this issue Oct 13, 2020 · 2 comments · Fixed by #1946
Labels

Comments

@danoc
Copy link

danoc commented Oct 13, 2020

Describe the bug

webpack-cli@4.0.0 is not able to handle a webpack config that exports an array of functions.

Take this config, for example:

module.exports = [
  () => ({
    entry: "./src/entry1.js",
  }),
  () => ({
    entry: "./src/entry2.js",
  }),
];

It worked in webpack-cli@^3.0.0 but fails in 4.0.0 with this error:

assets by status 0 bytes [cached] 1 asset

ERROR in main
Module not found: Error: Can't resolve './src' in '/Users/doconnor/Thumbtack/webpack5-array-of-functions'

webpack 5.1.0 compiled with 1 error in 120 ms

assets by status 0 bytes [cached] 1 asset

ERROR in main
Module not found: Error: Can't resolve './src' in '/Users/doconnor/Thumbtack/webpack5-array-of-functions'

webpack 5.1.0 compiled with 1 error in 119 ms

webpack-cli@4.0.0 doesn't recognize the entry value and errors saying that it can't find ./src, the webpack default.

What is the current behavior?

Fails to find entrypoint if an array of functions is exported from the webpack config.

To Reproduce

Steps to reproduce the behavior:

  1. Clone https://github.com/danoc/webpack-cli-4-array-of-functions
  2. Run npm i
  3. Run npm run build
  4. See error

Expected behavior

Compiles ./src/entry1.js and ./src/entry2.js without errors.

Screenshots

N/A

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

System:
  OS: macOS 10.15.7
  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Memory: 3.02 GB / 32.00 GB
Binaries:
  Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
  Yarn: 1.16.0 - /usr/local/bin/yarn
  npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm
Browsers:
  Chrome: 86.0.4240.75
  Firefox: 81.0.1
  Safari: 14.0
Packages:
  webpack: ^5.0.0 => 5.1.0
  webpack-cli: ^4.0.0 => 4.0.0

Additional context

The build works if the webpack config exports a single function or an array of objects. It specifically fails with an array of functions.

Might be related to #1843.

@danoc danoc added the Bug label Oct 13, 2020
@anshumanv
Copy link
Member

Confirmed the issue, thanks for the detailed report!

We will fix it soon.

@alexander-akait
Copy link
Member

WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants