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

Option 'bail' causes failed build #11594

Closed
meskill opened this issue Oct 6, 2020 · 10 comments · Fixed by #13944
Closed

Option 'bail' causes failed build #11594

meskill opened this issue Oct 6, 2020 · 10 comments · Fixed by #13944

Comments

@meskill
Copy link

meskill commented Oct 6, 2020

Bug report

What is the current behavior?

Setting option bail to true will break the build for unresolved modules wrapped in try...catch
After setting bail to false bundle builds successfully

If the current behavior is a bug, please provide the steps to reproduce.

  1. Set bail: true in config
  2. Add require to unresolved module wrapped in try...catch
    let packageJson = {};
    
    try {
      packageJson = require('../../../../package.json');
    } catch (e) {
    }
    
  3. Start build as always

What is the expected behavior?

There is should be only a warning about the unresolved module, bundle should be built successfully.

Other relevant information:
webpack version: 5.0.0-rc.3
Node.js version: 12.18.4

@alexander-akait
Copy link
Member

alexander-akait commented Oct 7, 2020

Unresolved module is an error, try to run this code in node wrong, it is a warning in try/catch

@meskill
Copy link
Author

meskill commented Oct 7, 2020

@evilebottnawi, please, look carefully
require is wrapped in try..catch so error for an unresolved module is handled, and it works fine without the option

image

@alexander-akait
Copy link
Member

alexander-akait commented Oct 7, 2020

Oh, I was wrong here, it is bug on webpack-cli, please use latest rc release of webpack-cli

@alexander-akait
Copy link
Member

From my test:

WARNING in ./test.js 4:18-53
Module not found: Error: Can't resolve '../../../../package.json' in '/home/user/path/to/package'
# echo $?
0

@meskill
Copy link
Author

meskill commented Oct 12, 2020

@evilebottnawi I've created a test repo to show this issue and the difference between webpack4 and webpack5
https://github.com/meskill/webpack5-bail-option-repro

@code1x1

This comment has been minimized.

@meskill
Copy link
Author

meskill commented Oct 19, 2020

is it a bug for sure?

shouldn't webpack only care if the required source is not found while the bundler is running even though the require is inside a try catch.

and not if a require is resolving in runtime because of the try catch.

I think those cases should be handled by setting the externals property in config?!?
https://webpack.js.org/configuration/externals/

this bug describes only bundle-time case.
we have a tool to wrap a webpack execution from our users and thats why we may face case when user app doesn't have some dependencies in their modules tree.
And it works as expected, except for this bug, when option bail: true leads to unsuccessful build

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@alexander-akait
Copy link
Member

bump

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

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

Successfully merging a pull request may close this issue.

4 participants