wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.63k stars 1.18k forks source link

Remove redundant steps (`runSetup`) from `wasp build`: they slow it down and produce redundant output #1152

Open Martinsos opened 1 year ago

Martinsos commented 1 year ago

Inspired by this thread: https://discord.com/channels/686873244791210014/1098143517936734319/1098143517936734319 .

On each wasp build you have to wait for node_modules to get reinstalled, completely from scratch, which is a PITA. Here is the "offending" line: https://github.com/wasp-lang/wasp/blob/main/waspc/cli/src/Wasp/Cli/Command/Build.hs#L47 -> we delete the whole .wasp/build dir when creating new build. The idea behind this is to make sure we have clean start, that nothing from the previous build is by accident left over.

But this cleans up node_modules, so they have to be installed from scratch every time!

Potential solution is to remove everything but node_modules. But what if some redundant stuff is left in them from before? Well I think it doesn't matter, they are anyway not getting deployed, it is instead expected that when you deploy you do npm build (it is what we do in our Docker container for deploying server).

There is another thing I wonder here though -> why do we even need node_modules for wasp build? We are just producing code that is to be deployed -> Docker container is anyway building node_modules on its own from what I see, and doing prisma generation and stuff. I think we let wasp build install node_modules because we normally do that after generating code and we just reused logic for that, but it might actually be redundant in this case, and we could possibly just remove it!

We also run migration checks here, which are not really needed? Check the related issue linked in the next comment.

Proposal:

Martinsos commented 1 year ago

Same but older issue about this: https://github.com/wasp-lang/wasp/issues/968 , check it out for some more info.

Solution is the same: skip doing runSetup in writeWebAppCode when doing wasp build!