New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@abstract-money/bundle-require

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abstract-money/bundle-require

bundle and require a file

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-92.31%
Maintainers
0
Weekly downloads
 
Created
Source

@abstract-money/bundle-require

npm version npm downloads jsDocs.io

Disclaimer

This package is a fork of egoist/bundle-require version 3.1.2 with the corrected esbuild peer dependency as one breaks when used as peer in the projects that depend on the esbuild<0.17.0.

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.

How it works

  • Bundle your file with esbuild, 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 file
  • Output file in esm format if possible (for .ts, .js input files)
  • Load output file with import() if possible
  • Return the loaded module and its dependencies (imported files)

Install

npm i @abstract-money/bundle-require esbuild

esbuild is a peer dependency.

Usage

import { bundleRequire } from '@abstract-money/bundle-require'

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

API

https://www.jsdocs.io/package/@abstract-money/bundle-require

Projects Using @abstract-money/bundle-require

Projects that use @abstract-money/bundle-require:

  • VuePress: :memo: Minimalistic Vue-powered static site generator.

Sponsors

sponsors

License

MIT © EGOIST

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc