Overview
BuckleScript incorpora su propio sistema de build, Bsb, que aspira a ser rápido, ligero y estándar de facto en la comunidad a la hora de construir projectos.
Bsb provee algunos templates para crear proyectos rápidamente:
bsb -init nombre-del-directorio
Para generar un proyecto Reason:
bsb -init nombre-del-directorio -theme basic-reason
Puedes inspeccionar los archivos en el directorio recién generado. Para ver todos los templates disponibles, ejecuta:
bsb -themes
El archivo de configuración de la build se llama bsconfig.json
. Todos los proyectos que usan BuckleScript necesitan uno.
To build a project, run:
bsb -make-world
Añade -w
para mantener el vigía incorporado en ejecución. Cualquier nuevo cambio en los archivos será tomado y la construcción se volverá a ejecutar.
Nota: las librerías de terceros (en node_modules
) no están vigiladas, ya que hacerlo puede exceder el límite de cuenta del vigía node.js. Si estás haciendo modificaciones rápidas y sucias dentro de node_modules
, tienes que usar bsb -clean-world -make-world
para reconstuirlas.
Note 2: The watcher clears the screen with each rebuild. To suppress this, set the environment variable BS_WATCHNOCLEAR to some truthy value: BS_WATCHNOCLEAR=1 npm start
Note 3: If you are developing across multiple devices, you may find the -ws
configuration useful in order to have live-reloading across the network. Possible configurations are: - bsb -make-world -w -ws _
(default) - bsb -make-world -w -ws 0.0.0.0:9999
- bsb -make-world -w -ws 5000
To build only yourself, use bsb -make
.
bsb -help
to see all the available options.
Limpieza de archivos intermedios
If you ever get into an unstable build for edge-case reasons, use:
bsb -clean-world
Or bsb -clean
to clean only your own artifacts.
Soporte de editores
Bsb generates a .merlin
file, used by various editor plugins under the hood to power e.g. autocomplete, type hint, diagnosis, etc.
Bonus: you can directly pipe the bsb terminal error messages into VSCode by setting the config here.
Consejos y sugerencias
A typical problem with traditional build systems is that they're not resilient against the user moving/deleting source files. Most don't clean up the old artifacts correctly after such user action*. Bsb is unfortunately no different, unless you turn on "suffix": ".bs.js"
in bsconfig.json
, in which case we can track which JS artifact belongs to which source file correctly, even against source file moving/deletion.
Decisiones de diseño
* One such build system that tracks these correctly & efficiently is Tup. See the (rather accessible!) paper here. Unfortunately, Tup's implementation uses FUSE and other systems, which we can't safely use on every platform.