Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions runtime/fundamentals/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ Uint8Array(12) [
// ]
```

## Deferred module evaluation

Starting in Deno 2.8, the
[TC39 Deferred Module Evaluation proposal](https://github.com/tc39/proposal-defer-import-eval)
is supported. The `import defer` syntax loads a module — including its
dependencies — but does **not** execute its top-level code until you first read
a property from the namespace:

```ts title="main.ts"
import defer * as expensive from "./expensive.ts";

console.log("startup is fast — expensive.ts has not run yet");

// Touching any property triggers synchronous evaluation
console.log(expensive.value);
```

Use it to defer the cost of modules that are only needed conditionally — for
example, error-path code in a CLI tool or feature flags whose implementation is
heavy to initialize.

The proposal is still at TC39 Stage 3, so the syntax is considered experimental
and may change. Standard `import` remains the right default.

## WebAssembly modules

Deno supports importing Wasm modules directly:
Expand Down