$ npm install bundle-require
💛 You can help the author become a full-time open-source maintainer by sponsoring him on GitHub.
Projects like Vite need to load config files provided by the user, but you can't do it with just require()
because it's not necessarily a CommonJS module, it could also be a .mjs
or even be written in TypeScript, and that's where the bundle-require
package comes in, it loads the config file regardless what module format it is.
node_modules
are excluded because it's problematic to try to bundle it
__filename
, __dirname
and import.meta.url
are replaced with source file's value instead of the one from the temporary output fileesm
format if possible (for .ts
, .js
input files)import()
if possiblenpm i bundle-require esbuild
esbuild
is a peer dependency.
import { bundleRequire } from 'bundle-require'
const { mod } = await bundleRequire({
filepath: './project/vite.config.ts',
})
https://www.jsdocs.io/package/bundle-require
Projects that use bundle-require:
MIT © EGOIST
© 2010 - cnpmjs.org x YWFE | Home | YWFE