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

Compiling in production fails silently and isn't verbose enough #1824

Closed
ameft opened this issue Dec 2, 2018 · 16 comments
Closed

Compiling in production fails silently and isn't verbose enough #1824

ameft opened this issue Dec 2, 2018 · 16 comments

Comments

@ameft
Copy link

ameft commented Dec 2, 2018

I have a Rails 5.2 app with Webpacker 4.0.0.pre.3 with runs smoothly in development and instead couldn't compile in production: [Webpacker] Compiling… just hanged there for hours (locally and on Heroku, where @schneems helped me a lot), in a similar way as described in #1534, #1217 and #1003.
After many hours of testing and research I found out that the problem was that two dependencies in package.json (@fortawesome/fontawesome-free and expose-loader) were in devDependencies instead of dependencies, that made compiling failing silently.
Running this command put me on the right path to find the solution, giving me some hits of errors NODE_ENV=production ./bin/webpack --progress --config config/webpack/production.js.
Problem is that instad running RAILS_ENV=production NODE_ENV=production bundle exec rails assets:compile didn't give me any indication of errors, and I don't know why but shouldn't be the case.
What do you think?

@ameft ameft changed the title Compiling in production isn't verbose enough Compiling in production fails silently and isn't verbose enough Dec 2, 2018
@jakeNiemiec
Copy link
Member

jakeNiemiec commented Dec 3, 2018

FontAwesome did a writeup on this known issue. Issue terser/terser#50

There is a merged webpacker PR to fix this #1719 #1816 (comment)

@ameft
Copy link
Author

ameft commented Dec 3, 2018

Thank you @jakeNiemiec, I don't know if also my issues are related to uglify-es, but Webpacker should return some kind of error in any case I'd say.

@jakeNiemiec
Copy link
Member

jakeNiemiec commented Dec 3, 2018

It's not that Webpacker is erroring out, uglify is incorrectly trying to minify all of the FA glyphs & exports. In other words, it's trying to do an impossible amount of work (memory & cpu wise). This is an issue that is just as hard to diagnose with vanilla webpack.

@ameft
Copy link
Author

ameft commented Dec 3, 2018

@jakeNiemiec are you sure that that is what it's happening? Why moving the libraries from devDependencies to dependencies should fix that? Compiling with ./bin/webpack was giving me errors, but Webpacker didn't.
EDIT: I didn't have problems with long compiling times in reality, I think. I had problems with compiling errors not being reported and not halting the process.

@gauravtiwari
Copy link
Member

Yeah, we should fix this. Thanks @ameft for reporting. Please feel free to make a PR

@jakeNiemiec
Copy link
Member

jakeNiemiec commented Dec 3, 2018

@ameft Sorry, my mistake, I conflated some of the issues you pointed to with what you were saying. Now my understanding is: FA was in devDeps when it needed to be in deps and webpacker did not alert you to this error.

It looks like webpacker is configured correctly to display errors:
https://webpack.js.org/configuration/stats/#stats


You should also be able to pass custom settings to ensure errors are being displayed. Here is what I am currently using:

  stats: {
    errors: true,
    errorDetails: true,
    colors: true,
    optimizationBailout: true
  }

Edit: @ameft if you wanted to make the PR, I think adding back the line that this commit removed might solve this problem: #483. (errorDetails should be shown with or without the devServer running )

@ameft
Copy link
Author

ameft commented Dec 3, 2018

I'll try the stats config and to revert the fix to see if the errors are displayed, thank you @jakeNiemiec!

@gauravtiwari
Copy link
Member

@jakeNiemiec I think the issue here is Open3 is hanging for some reason when there is error returned from the shell command. I am looking into alternatives but if someone has ideas feel free to make a PR.

@schneems
Copy link
Member

schneems commented Dec 3, 2018

A thing I've had to recommend fairly frequently is to manually run ./bin/webpack --progress.

Can we make this the default output mode of webpacker? Any other documentation or tips on debugging hung or really slow compiles is appreciated.

@jakeNiemiec
Copy link
Member

@schneems If you also add --profile, this will give you some insight into where the bottlenecks are:
image

We use a progress plugin that does this on every build, here is one that a lot of (react/vue/angular)-cli libraries use: https://www.npmjs.com/package/simple-progress-webpack-plugin#minimal
image

@acrewdson
Copy link

+1 to what @schneems said above with respect to making --progress the webpacker default

@masato-hi
Copy link
Contributor

I do not know about that no error output will occur, but this is maybe related #2143

@rossta
Copy link
Member

rossta commented Aug 28, 2020

@ameft Can this issue be closed and, if so, could you close it? Thank you!

@ameft
Copy link
Author

ameft commented Aug 28, 2020

@rossta I can of course close the issues, but it's not entirely clear to me if now webpacker behaves differently if it encounter certain errors during compiling. I didn't had any more issue on my part but I don't know if the original issue is actually addressed or maybe it's not a real issue to begin with...

@rossta
Copy link
Member

rossta commented Aug 28, 2020

@ameft Ah, thanks for pointing that out.

It's my understanding that Webpacker suppressed the compilation output in the version associated with this issue (Webpacker 4.0.0.pre.3 from the description).

Since 4.1.0 with this PR #2224, Webpacker will now print the compilation output to STDOUT by default though this behavior can be disabled in webpacker.yml

webpack_compile_output: true
.

@ameft
Copy link
Author

ameft commented Aug 28, 2020

@rossta amazing thanks! Issue closed :)

@ameft ameft closed this as completed Aug 28, 2020
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

7 participants