From 2f9ff3f31d074d3e8577b5ecff08edfcbc24d80f Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Tue, 29 Jul 2025 23:09:51 +1000 Subject: [PATCH] docs --- docs/api/import-meta.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/api/import-meta.md b/docs/api/import-meta.md index 7be078a2d1..8d4f71efc5 100644 --- a/docs/api/import-meta.md +++ b/docs/api/import-meta.md @@ -12,6 +12,8 @@ import.meta.main; // `true` if this file is directly executed by `bun run` // `false` otherwise import.meta.resolve("zod"); // => "file:///path/to/project/node_modules/zod/index.js" + +import.meta.glob("./models/*.js"); // => { "./models/user.js": [Async Function], ... } ``` {% table %} @@ -66,4 +68,17 @@ import.meta.resolve("zod"); // => "file:///path/to/project/node_modules/zod/inde - `import.meta.url` - A `string` url to the current file, e.g. `file:///path/to/project/index.ts`. Equivalent to [`import.meta.url` in browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta#url) +--- + +- `import.meta.glob` +- Import multiple modules using glob patterns. Returns an object mapping file paths to lazy-loading functions. + + ```ts + const modules = import.meta.glob('./modules/*.js'); + // const modules = { + // './modules/a.js': () => import('./modules/a.js'), + // './modules/b.js': () => import('./modules/b.js'), + // } + ``` + {% /table %}