![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
bundle-require
Advanced tools
The bundle-require npm package allows you to require modules that are bundled using various bundlers like Webpack, Rollup, or esbuild. It simplifies the process of loading and executing bundled code in Node.js environments.
Require Bundled Code
This feature allows you to require a bundled JavaScript file using a specified bundler. In this example, the bundled file is loaded using Webpack.
const { bundleRequire } = require('bundle-require');
(async () => {
const result = await bundleRequire({
filepath: './path/to/your/bundled/file.js',
bundler: 'webpack'
});
console.log(result);
})();
Support for Multiple Bundlers
This feature demonstrates the ability to use different bundlers like Rollup. The bundler option can be changed to 'webpack', 'rollup', or 'esbuild' based on your needs.
const { bundleRequire } = require('bundle-require');
(async () => {
const result = await bundleRequire({
filepath: './path/to/your/bundled/file.js',
bundler: 'rollup'
});
console.log(result);
})();
Dynamic Import of Bundled Code
This feature shows how to dynamically import a bundled module using esbuild. The default export of the bundled module is accessed and logged.
const { bundleRequire } = require('bundle-require');
(async () => {
const result = await bundleRequire({
filepath: './path/to/your/bundled/file.js',
bundler: 'esbuild'
});
const { default: module } = result;
console.log(module);
})();
The require-from-string package allows you to require a module from a string of code. Unlike bundle-require, it does not support bundlers directly but can be used to load code dynamically from a string.
The esm package enables ES module support in Node.js. While it does not directly handle bundling, it allows you to use ES modules seamlessly, which can be useful in conjunction with bundlers.
The import-fresh package allows you to import a module while bypassing the require cache. This can be useful for dynamically loading modules, but it does not handle bundling like 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
FAQs
bundle and require a file
The npm package bundle-require receives a total of 1,167,689 weekly downloads. As such, bundle-require popularity was classified as popular.
We found that bundle-require demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.