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

UglifyJS errors don't bail the build with --bail #2390

Closed
graingert opened this issue Apr 25, 2016 · 10 comments
Closed

UglifyJS errors don't bail the build with --bail #2390

graingert opened this issue Apr 25, 2016 · 10 comments

Comments

@graingert
Copy link

webpack --bail:

ERROR in entrypoint-xxx.bundle.js from UglifyJs
Unexpected character '`' ./src/path/to/file.js:1487,0]
@bebraw
Copy link
Contributor

bebraw commented Aug 29, 2016

Can you provide a test case so this can be debugged?

@pdillon
Copy link

pdillon commented Oct 5, 2016

@bebraw Check out at https://github.com/pdillon/webpack-bail-example. Ran into this issue where the babel loader was pulling in files outside of the include path, bypassing transpilation, and uglify throws an error.

@bebraw
Copy link
Contributor

bebraw commented Oct 7, 2016

@pdillon Thanks. I added this to webpack 2 work. Given there's a test case, it should be easier to figure out the root cause.

@pdillon
Copy link

pdillon commented Oct 8, 2016

@bebraw would it make sense for bail to map to the NoErrorsPlugin, and for the plugin to pass an error to the callback if compilation.errors > 0?

@bebraw
Copy link
Contributor

bebraw commented Oct 8, 2016

@pdillon I'm not sure. I think we'll have to wait for Tobias to check this out to get the behavior right.

@gdborton
Copy link
Contributor

Is this not going to be fixed in webpack 1.13.x?

@JLHwung
Copy link
Contributor

JLHwung commented Jan 5, 2017

Here is another minimal example.

Webpack 2 does not bail when babel finds a syntax error.

@q42jaap
Copy link

q42jaap commented Mar 21, 2017

I've created a workaround that will detect UglifyJs errors and exit the process with a non-zero status code:

class DetectUglifyJsErrors {
  apply(compiler) {
    compiler.plugin('compilation', compilation => {
      compilation.plugin('optimize-chunk-assets', (chunks, callback) => {
        if (compilation.errors.length > 0) {
          compilation.errors.forEach(error => {
            console.error(`ERROR in ${error.message}`);
          });
          process.exit(1);
        }
        callback();
      });
    });
  }
}

This works for me and outputs the same message webpack would otherwise output.

@webpack-bot
Copy link
Contributor

This issue had no activity for at least half a year.

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

@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

No branches or pull requests

7 participants