Volt.JS.GlobImport (Volt v0.10.1)

Copy Markdown View Source

Transform import.meta.glob() calls into static import maps.

Uses OXC AST to find calls, resolves glob patterns at build time, and patches the source with OXC.patch_string/2.

Example

// Source
const modules = import.meta.glob('./pages/*.ts')

// Transformed (lazy  default)
const modules = {
  "./pages/home.ts": () => import("./pages/home.ts"),
  "./pages/about.ts": () => import("./pages/about.ts"),
}

// With { eager: true }
import * as __glob_0 from "./pages/home.ts"
import * as __glob_1 from "./pages/about.ts"
const modules = {
  "./pages/home.ts": __glob_0,
  "./pages/about.ts": __glob_1,
}

Summary

Functions

Transform import.meta.glob() calls in source code.

Functions

transform(source, base_dir, filename \\ "glob.ts")

@spec transform(String.t(), String.t(), String.t()) :: String.t()

Transform import.meta.glob() calls in source code.

base_dir is the directory of the file containing the glob call, used to resolve the glob pattern to actual files.