method
bun.__internal.ImportMetaGlob.glob
pattern: string | string[],
): Record<string, () => Promise<TModule>>;
Import every module that matches a glob pattern. Compatible with Vite's import.meta.glob.
Bun's transpiler and bundler replace the call with an object literal, so the arguments must be literals.
const pages = import.meta.glob("./pages/*.tsx");
// {
// "./pages/about.tsx": () => import("./pages/about.tsx"),
// "./pages/home.tsx": () => import("./pages/home.tsx"),
// }pattern: string | string[],
): Record<string, TModule>;
const pages = import.meta.glob("./pages/*.tsx", { eager: true });
// import * as about from "./pages/about.tsx";
// import * as home from "./pages/home.tsx";
// { "./pages/about.tsx": about, "./pages/home.tsx": home }