Skip to content
main
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
Oct 9, 2021
Oct 9, 2021
Oct 9, 2021
Oct 9, 2021
Oct 9, 2021

💛 You can help the author become a full-time open-source maintainer by sponsoring him on GitHub.


bundle-require

npm version

Use Case

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.

This is implemented by pre-bundling the file with esbuild and then loading it with require().

Install

npm i bundle-require esbuild

esbuild is a peer dependency.

Usage

import { bundleRequire } from 'bundle-require'

const mod = await bundleRequire({
  filepath: './project/vite.config.ts',
})

License

MIT © EGOIST

About

bundle and `require` a file

Resources

License

Sponsor this project

 

Packages

No packages published