Skip to content

ES Modules ​

Scripts are organized with import / export, and relative paths are resolved against the current file. lib.js:

js
export const PI = 3.14
export function double(x) { return x * 2 }

main.js:

js
import { PI, double } from "./lib.js"

setTimeout(() => console.log("tick"), 10)
console.log(double(PI))
text
$ gox main.js
6.28
tick

Default exports, namespace imports, and dynamic import() are also supported:

js
import sq, { PI } from "./math_utils.js"     // default export + named exports
import * as math from "./math_utils.js"      // namespace

import("./math_utils.js").then(m => console.log(m.PI))   // dynamic loading
LimitationDescription
ES modules onlyNo CommonJS: require / module.exports / __dirname do not exist
No npm resolutionNo node_modules lookup, no bare package names — only relative paths and gx/* / gox built-in modules
Import aliasesimport { x as y } is supported; see Language Boundaries