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

Webpack process never exits on missing JS import #759

Closed
lneveu opened this issue Sep 12, 2019 · 6 comments
Closed

Webpack process never exits on missing JS import #759

lneveu opened this issue Sep 12, 2019 · 6 comments

Comments

@lneveu
Copy link

lneveu commented Sep 12, 2019

  • Operating System: Debian 8 (jessie)
  • Node Version: 10.15.3
  • NPM Version: 6.9.0
  • webpack Version: 4.39.2
  • sass-loader Version: 8.0.0

Expected Behavior

In bail mode, Webpack build process should fail out and stop on first error (in this case, a missing import file).

Actual Behavior

Webpack build process get stuck after throwing the expected error. The process never exits.

Code

// webpack.config.js
const path = require('path');
module.exports = {
  mode: 'production',
  bail: true,
  entry: {
    app: ['./src/app.js', './src/foo.scss']
  },
  output: {
    path: path.resolve(__dirname, './dist')
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: 'babel-loader'
      },
      {
        test: /.s?css$/,
        use: ['css-loader', 'sass-loader']
      }
    ]
  }
};
// src/app.js
import './missing-module'; // <-- this import will fail on purpose
console.log('app');
// src/foo.scss
@import './bar';
body { color: red; }
// src/bar.scss
h1 { color: blue; }

How Do We Reproduce?

Run Webpack using the given configuration.
Mandatory conditions to reproduce the bug:

  • bail mode must be enabled
  • a scss file must be specified in the entry list
  • the scss entry point (foo.scss, here) must contains a valid @import. If foo.scss is replaced by bar.scss, everything works as expected.

Let me know if you need more details.
Thanks!

@alexander-akait
Copy link
Member

Please create minimum reproducible test repo

@alexander-akait
Copy link
Member

Can't reproduce

@lneveu
Copy link
Author

lneveu commented Sep 12, 2019

Sure: https://github.com/lneveu/bug-repro-webpack-sass-loader
Just run webpack inside the repo.

@alexander-akait
Copy link
Member

Thanks look on this in near future

@lneveu
Copy link
Author

lneveu commented Sep 13, 2019

I found similar issues here: nodejs/node#17872 and here: #523.

A fix was proposed and merged in the main Webpack repository: webpack/webpack#6193. I tried to apply the same patch, but in webpack/cli (since the code was moved there: https://github.com/webpack/webpack-cli/blob/master/bin/cli.js#L317) and it seems to fix the bug.
I'll submit a pull request in the cli repo.

@alexander-akait
Copy link
Member

let's close in favor webpack/webpack-cli#1078, anyway thanks for the issue and the PR

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

No branches or pull requests

2 participants