leebenson / reactql

Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
https://reactql.org
MIT License
1.82k stars 173 forks source link

Stuck during production build #181

Closed bensventures closed 4 years ago

bensventures commented 4 years ago

I'm encountering an issue when building my app for production with npm run production:clean. It outputs Building production server... correctly but then hangs there forever. A node process is also taking 100% cpu until I manually kill it.

I've tried with the example app and it seems to work so it is most probably something in my code that's creating an infinite loop or something.

If I comment out

// Attach middleware
  app.use(require(common.compiled.server).default(output));

in the production.ts runner the build completes but obviously the app doesn't work.

If I change NODE_ENV to development the build also completes and I can start the app correctly but no styles etc are loaded.

I'm running node 11.8.0.

Any idea how I could debug that? Maybe a flag to output more logs? Thanks a lot!

bensventures commented 4 years ago

After commenting out all imports from my entry and enabling them one by one I tracked it down to react-intl. When you use any react-intl components server side it hangs at production build.

I first thought I was because of the lack of icu compatibility from node 12 but even after moving to node 13 I get the same problem.

It can be reproduced from a straight download of reactql and installing react-intl and importing and using one of its components, like <FormattedMessage />, on Root.tsx

bensventures commented 4 years ago

Turns out it was because of the version of Typescript. This got me to the fix: https://github.com/formatjs/react-intl/issues/1548

After updating Typescript to 3.7.4 everything builds and run 👍