ES Modules in Script: File-Based Resolution, Caching, and Cross-Module Calls
docs.script-lang.org·4d
Preview
Report Post

Script now has full ES module support with import and export statements, file-based resolution, SHA256 caching, and cross-module function calls. This post explains how we built it, the decisions we made, and what’s coming next.

The Goal

ES modules are the modern way to organize JavaScript code. We wanted Script to support the same syntax:

// math.tsclexport function add(a: number, b: number): number {    return a + b;}export const PI = 3.14159;// main.tsclimport { add, PI } from './math';console.log(add(2, 3));  // 5console.log(PI);         // 3.14159

But we also wanted:

  • Fast incremental builds: Cache modules to avoid recompiling
  • Cross-module calls: Functions from different modules calling each other
  • **Error diag…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help