一覧へ戻る
tomcphr/rollup-plugin-import-globber(新しいタブで開きます)
主要言語: TypeScript
A rudimentary mimic of Vite's import meta glob for Rollup
- star 数
- 3
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2023/05/08
主要言語: TypeScript
A rudimentary mimic of Vite's import meta glob for Rollup
A rudimentary mimic of Vite's import meta glob for Rollup
Install via package manager of your choice (I use yarn)
yarn install rollup-plugin-import-globberYou will need to define the typings in your tsconfig:
"types": ["./node_modules/rollup-plugin-import-globber/typings"],
You can then use the glob method on import.meta in your code
let modules = import.meta.glob('./modules/**/*.ts');
This will produce code in your output bundle akin to this...
import * as glob_0_1 from './modules/folder1/file1.js'; import * as glob_0_2 from './modules/folder1/file2.js'; let modules = [glob_0_1, glob_0_2];
You can also provide the call with an array of glob patterns to search.
let modules = import.meta.glob([ './modules/**/*.ts', './other-directory/**/*.ts' ]);
And this will produce code in your output bundle akin to this...
import * as glob_0_1 from './modules/folder1/file1.js'; import * as glob_0_2 from './modules/folder1/file2.js'; import * as glob_1_1 from './modules/other-directory/other-file1.js'; import * as glob_1_2 from './modules/other-directory/other-file2.js'; let modules = [glob_0_1, glob_0_2, glob_1_1, glob_1_2];