{"name":"bundle-require","version":"5.1.0","description":"bundle and require a file","publishConfig":{"access":"public"},"type":"module","main":"./dist/index.js","exports":{".":{"import":"./dist/index.js","default":"./dist/index.cjs"}},"types":"./dist/index.d.ts","scripts":{"build":"tsup src/index.ts --format esm,cjs --dts-resolve --target node12.20.0","test":"npm run build && vitest run","prepublishOnly":"npm run build"},"license":"MIT","devDependencies":{"@egoist/prettier-config":"1.0.0","@types/node":"18.11.18","esbuild":"0.18.20","prettier":"2.8.3","tsup":"6.5.0","typescript":"4.9.5","vitest":"0.28.3"},"dependencies":{"load-tsconfig":"^0.2.3"},"peerDependencies":{"esbuild":">=0.18"},"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"_id":"bundle-require@5.1.0","gitHead":"8ca47fef6353369bc3b49d7ef73fdad239355f0c","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==","shasum":"8db66f41950da3d77af1ef3322f4c3e04009faee","tarball":"http://registry-npm.ywwl.com/bundle-require/download/bundle-require-5.1.0.tgz","fileCount":6,"unpackedSize":26376,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCS0ABuIGdyLgAcPANJM9TSpXK3BI/IKKH2JdF1nBl7ugIgEUl1KuzgGRzBRzKT91vZ1koXG7HdixMCcMeZHtJc7z0="}],"size":6739,"noattachment":false,"key":"/bundle-require/-/bundle-require-5.1.0.tgz"},"_npmUser":{"name":"egoist","email":"0x142857@gmail.com"},"directories":{},"maintainers":[{"name":"egoist","email":"0x142857@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bundle-require_5.1.0_1734880394630_0.23966909906859546"},"_hasShrinkwrap":false,"readme":"**💛 You can help the author become a full-time open-source maintainer by [sponsoring him on GitHub](https://github.com/sponsors/egoist).**\n\n---\n\n# bundle-require\n\n[![npm version](https://badgen.net/npm/v/bundle-require)](https://npm.im/bundle-require) [![npm downloads](https://badgen.net/npm/dm/bundle-require)](https://npm.im/bundle-require) [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/bundle-require)\n\n## Use Case\n\nProjects like [Vite](https://vitejs.dev) 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.\n\n## How it works\n\n- Bundle your file with esbuild, `node_modules` are excluded because it's problematic to try to bundle it\n  - `__filename`, `__dirname` and `import.meta.url` are replaced with source file's value instead of the one from the temporary output file\n- Output file in `esm` format if possible (for `.ts`, `.js` input files)\n- Load output file with `import()` if possible\n- Return the loaded module and its dependencies (imported files)\n\n## Install\n\n```bash\nnpm i bundle-require esbuild\n```\n\n`esbuild` is a peer dependency.\n\n## Usage\n\n```ts\nimport { bundleRequire } from 'bundle-require'\n\nconst { mod } = await bundleRequire({\n  filepath: './project/vite.config.ts',\n})\n```\n\n## API\n\nhttps://www.jsdocs.io/package/bundle-require\n\n## Projects Using bundle-require\n\nProjects that use **bundle-require**:\n\n- [VuePress](https://github.com/vuejs/vuepress): :memo: Minimalistic Vue-powered static site generator.\n\n## Sponsors\n\n[![sponsors](https://sponsors-images.egoist.dev/sponsors.svg)](https://github.com/sponsors/egoist)\n\n## License\n\nMIT &copy; [EGOIST](https://github.com/sponsors/egoist)\n","publish_time":1734880394839,"_cnpm_publish_time":1734880394839,"dist-tags":{"latest":"5.1.0"}}