0

I was thinking of making the dev experience as smooth as possible and the feedback loop as short as possible when compiling the Reason+React application. If I use

import React from 'react';

in a file, does that mean I have to bundle React with the file at every change? Or can I pre-compile the dependencies of that file, and only compile the changed file without any other process getting fired in the build system?

glennsl
  • 28,186
  • 12
  • 57
  • 75
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
  • It's not clear what you mean by either dependencies or compilation here. Every file is compiled individually, but requires the type information of any dependent modules. The build system manages these dependencies for you, including making sure that third party packages are built, but still only produces separate output for each module. You can then optionally bundle the modules together in a single file using a third party bundler like webpack, Only this last optional build step actually requires react.js to be present. – glennsl Dec 11 '20 at 13:47
  • @glennsl Well, consider React to be the dependency, and the app being just one file, for example. When changing the file, I want to inspect the changes in the browser without compiling or bundling React again. – Olle Härstedt Dec 11 '20 at 13:51
  • If the type information (i.e. bindings) is part of the React dependency, then no. If it's part of the app then yes. You can't compile anything without the type information of dependencies, but as long as you have that you can precompile and package the actual code of the dependencies any way you like. You'll most likely not be able to use `bsb` though. – glennsl Dec 11 '20 at 13:58
  • @glennsl OK, maybe I have to experiment a bit more so I can be more precise later. Thanks! – Olle Härstedt Dec 11 '20 at 14:45

0 Answers0