cereallarceny / cra-ssr

[DEPRECATED] Server-side rendering with create-react-app, React Router v4, Helmet, Redux, and Thunk
484 stars 118 forks source link

Serve crashes if the app is ejected #51

Open angelcustodio opened 5 years ago

angelcustodio commented 5 years ago

Everything works fine without ejecting the app but if you yarn eject, then... 💥 yarn build do the job correctly but yarn serve returns this problem:

/cra-ssr/node_modules/@babel/runtime/helpers/esm/objectSpread.js:1
(function (exports, require, module, __filename, __dirname) { import defineProperty from "./defineProperty";
                                                                     ^^^^^^^^^^^^^^

I assume it's related with Node being unable to resolve ES6 imports, right? Is there any workaround or solid fix for it? Maybe babel-node?

koyta commented 5 years ago

@angelcustodio you fixed this?

angelcustodio commented 5 years ago

Running babel-node works but there should be some kind of magic with some dependency. In any case, it can be workarounded tweaking a lot the Babel configuration but it's not straightforward. I'll probably work on it a few days to have it clean and clear and do a PR if you think it's useful enough :)

koyta commented 5 years ago

@angelcustodio I fixed this by installing few packages for babel, edited server/index.js config, edited babel config in package.json and edit webpack.config.js. Also I removed babel-preset-react-app for @babel/preset-react one

Here's my gists of working configs:

You can make diff and see what you must change after eject

P.S. Configs are prettified with prettier, sorry :)

12finger commented 5 years ago

@koyta would really love to see the diff of the changes so i can apply them easier.

cereallarceny commented 5 years ago

Hey, my apologies for the long wait @angelcustodio - I'm looking to ensure this is fixed with version 2.0. If you're interested, I could really use your thoughts for what you'd like to see in the upcoming version. Feel free to comment on the issue here with any suggestions. :)

@12finger @koyta In the future we will support both ejected and non-ejected CRA builds.