Choosing an engine version
The slim loader from epanet-js/slim lets you choose any of the published EPANET engines at runtime, instead of using the v2.3.5 build embedded in the default Workspace. Use this when you want:
- A smaller bundle that ships only the engine binary you actually need.
- Deterministic version loading** for reproducible results.
- Compare results across engine versions.
- An EPANET version other than v2.3.5 with MSX support (via the
-msxengine variants — see the MSX example).
Loading a specific version
Section titled “Loading a specific version”import { Workspace } from "epanet-js/slim";import { Project } from "epanet-js";import { EpanetEngine } from "epanet-js/engines/v2.3.3";
const ws = new Workspace();await ws.loadModuleVersion(() => Promise.resolve(EpanetEngine));
const project = new Project(ws);ws.writeFile("net.inp", inpText);project.open("net.inp", "report.rpt", "out.bin");project.solveH();project.report();const report = ws.readFile("report.rpt");project.close();A few notes:
loadModuleVersiontakes a callback that returns a promise resolving to the engine module. The simplest form wraps a static import as above.- The callback must be imported from the package
epanet-js/engines/<version>. This package holds the code to find the WASM asset next to the JS glue code. Most bundlers (Vite, Webpack 5, Rspack, esbuild) handle the WASM emission automatically.
Available engine variants
Section titled “Available engine variants”| Import path | EPANET version | MSX |
|---|---|---|
epanet-js/engines/v2.2 | 2.2 | — |
epanet-js/engines/v2.3 | 2.3.0 | — |
epanet-js/engines/v2.3.1 … v2.3.5 | 2.3.1 – 2.3.5 | — |
epanet-js/engines/master | OWA master snapshot | — |
epanet-js/engines/dev | OWA dev snapshot | — |
epanet-js/engines/v2.2-msx | 2.2 | ✓ |
epanet-js/engines/v2.3-msx | 2.3.0 | ✓ |
epanet-js/engines/v2.3.1-msx … v2.3.5-msx | 2.3.1 – 2.3.5 | ✓ |
epanet-js/engines/master-msx | OWA master snapshot | ✓ |
epanet-js/engines/dev-msx | OWA dev snapshot | ✓ |
Comparing two engines side by side
Section titled “Comparing two engines side by side”A common use case is verifying a simulation against an older EPANET version:
import { Workspace } from "epanet-js/slim";import { Project } from "epanet-js";
async function runOn(version: string, inpText: string) { const ws = new Workspace(); await ws.loadModuleVersion(() => import(`epanet-js/engines/${version}`)); const project = new Project(ws); ws.writeFile("net.inp", inpText); project.open("net.inp", "report.rpt", "out.bin"); project.solveH(); project.report(); const report = ws.readFile("report.rpt"); project.close(); return { version: ws.version, report };}
const [v22, v235] = await Promise.all([ runOn("v2.2", inpText), runOn("v2.3.5", inpText),]);The Project methods you can call depend on the engine that was loaded. You will find a badge showing which is the minimum required engine version needed for each function on the project functions page. Calling a function the loaded engine doesn’t support will throw an exception.