February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's inspect the binding to JavaScript's require function at the top of App.re. Since we're going to dive deeper into BuckleScript in Chapter 4, BuckleScript, Belt, and Interoperability, let's defer discussing the details and just briefly see what this binding is doing:
[@bs.val] external require: string => string = "";require("../../../src/App.scss");
The external keyword creates a new binding, similar to the let keyword. After binding to JavaScript's require function, we can use it in Reason, as long as we're using the BuckleScript compiler. We use it to require App.scss as well as a few images. Inspecting the compiled output at lib/es6/src/App.bs.js shows that the preceding Reason code compiles to the following:
require("../../../src/App.scss"); ...Read now
Unlock full access