oscaroox / react-typescript-ssr-boilerplate

react typescript ssr boilerplate
9 stars 2 forks source link

`start` fails #1

Open timm-aym opened 6 years ago

timm-aym commented 6 years ago

Hi,

I am very interested in this project and wanted to check out whether your dev server allows react-loadable to be used with only one webpack compilation pass (by deferring the server until the client is ready).

Unfortunately I can't start the server (with yarn run build && yarn run start), it fails with:

    ERROR in multi ./server/render.tsx
    Module not found: Error: Can't resolve './server/render.tsx' in '.../Sources/github/react-typescript-ssr-boilerplate/build'
     @ multi ./server/render.tsx
timm-aym commented 6 years ago

Fixing the above issue in webpack.server.ts (just removing the .tsx) extension I get the following error when running opening the web server:

Error: Chunk name vendor does not exists in stats file

Did this project ever support the use case mentioned above, e.g. not requiring webpack to build twice to generate the react-loadable.json? That would be super useful for our project, as running the compiler twice just takes unnecessarily long.

oscaroox commented 6 years ago

What do you mean with using react-loadable with one webpack pass, I will check the error when I get behind a computer.

timm-aym commented 6 years ago

@oscaroox The way I understand it at the moment, people run webpack once to build the react-loadable.json and then another time to start up the server that then makes use of the JSON file within loadable.

I thought your approach worked around this, by directly starting the webpack compiler inside the dev server and deferring the Loadable load until the client compiler wrote the JSON to disk.

If that's the way this project is supposed to work, I imagine it's much faster the the other method and I'd like to incorporate it into our project.

oscaroox commented 6 years ago

Do you mean during development or when building for production. Building for production always has to build the client first so that react loadable emits the json to disk and then the server gets build. for development react loadable doesn't get used.

I have recently updated this repo to also use react-loadable had to do some testing before pushing.

timm-aym commented 6 years ago

I was also talking about development.

We still have react-loadable used during development, to be closer to the production setup.

Do you think that is wrong / has obvious drawbacks? I didn't see any recommendation from react-loadable not to do it.

oscaroox commented 6 years ago

yes during development you only need to run webpack once, I've updated the code to also run react-loadable in development. There also doesn't seem to be any drawbacks using it in development

Ill try to fix the error in this repo.