You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The upcoming 0.15 compiler release will produce ES Modules, which simplifies the following steps, but until then, a bundler is required.
Demonstrate how to point index.html to output/Main/index.js, bundle, and launch in webpage with parcel.
Note how to enable automatic rebuilds and page refresh with the correct editor configuration.
Bundling for the Browser
spago bundle-app produces a single index.js file.
Demonstrate how to include this in index.html.
Note that bundle-app removes unused code. This steps slows-down rebuilds, so it is best used for production builds, rather than active development.
The output can be further minimized with a bundler, such as parcel. Demonstrate how, and compare to unbundled output.
Analysis of Generated JS code
This is currently part of the "Compiling for the Browser" section. I don't think this material serves the "Getting Started" goal, so I think we should remove it. If we do keep it, the unbundled output is nicer to look at:
// Generated by purs version 0.13.8"use strict";varData_EuclideanRing=require("../Data.EuclideanRing/index.js");varData_Foldable=require("../Data.Foldable/index.js");varData_List=require("../Data.List/index.js");varData_List_Types=require("../Data.List.Types/index.js");varData_Semiring=require("../Data.Semiring/index.js");varns=Data_List.range(0)(999);varmultiples=Data_List.filter(function(n){returnData_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(n)(3)===0||Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(n)(5)===0;})(ns);varanswer=Data_Foldable.sum(Data_List_Types.foldableList)(Data_Semiring.semiringInt)(multiples);module.exports={ns: ns,multiples: multiples,answer: answer};
// Generated by purs version 0.13.8"use strict";varData_Show=require("../Data.Show/index.js");varEffect_Console=require("../Effect.Console/index.js");varEuler=require("../Euler/index.js");varmain=Effect_Console.log("The answer is "+Data_Show.show(Data_Show.showInt)(Euler.answer));module.exports={main: main};
The text was updated successfully, but these errors were encountered:
Suggesting a rewrite of the Compiling for the Browser and Compiling CommonJS Modules sections as follows:
Compiling for the Browser
spago build
produces CommonJS output.index.html
tooutput/Main/index.js
, bundle, and launch in webpage withparcel
.Bundling for the Browser
spago bundle-app
produces a singleindex.js
file.index.html
.bundle-app
removes unused code. This steps slows-down rebuilds, so it is best used for production builds, rather than active development.parcel
. Demonstrate how, and compare to unbundled output.Analysis of Generated JS code
This is currently part of the "Compiling for the Browser" section. I don't think this material serves the "Getting Started" goal, so I think we should remove it. If we do keep it, the unbundled output is nicer to look at:
The text was updated successfully, but these errors were encountered: