A esbuild plugin which allows to import multiple files using the glob syntax.
-
Install this plugin in your project:
npm install --save-dev esbuild-plugin-import-glob
-
Add this plugin to your esbuild build script:
+const ImportGlobPlugin = require('esbuild-plugin-import-glob'); ... esbuild.build({ ... plugins: [ + ImportGlobPlugin(), ], })
-
Use import or require
// @ts-ignore import migrationsArray from './migrations/**/*'; // contains default export migrationsArray[0].default;
// @ts-ignore import * as migrations from './migrations/**/*'; const { default: migrationsArray, filenames } = migrations;
const { default: migrationsArray, filenames } = require('./migrations/**/*');