webpack-require-http is a webpack plugin designed to enable the direct `require()` of HTTP and HTTPS resources within JavaScript code. This functionality is achieved by configuring it within webpack's `externals` option, where it transforms remote URL imports into asynchronous operations that fetch and inject the external scripts or stylesheets into the browser environment. The `require()` call then returns a `Promise` which resolves upon successful loading of the resource. The package, currently at version 0.4.3, was last updated in 2017, indicating it is no longer actively maintained. A key differentiator is its ability to accept custom rules (using regular expressions or functions) to rewrite or re-map requested URLs, offering flexibility in handling external resource paths. While it addressed a specific need for loading remote assets directly via `require` in earlier webpack versions, modern webpack (v5+) provides more robust and integrated solutions for handling external dependencies and remote modules, making this package largely superseded.
npm install webpack-require-httpVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure `webpack-require-http` in a basic webpack setup to allow `require()` calls for HTTP resources, showing the asynchronous nature of the loading process with `Promise.all`.
Consider migrating to modern Webpack features like Module Federation, dynamic `import()`, or asset modules for handling remote dependencies instead of this plugin.
Always use `.then()` or `await` with `require('http://...')` calls to ensure the resource is loaded before attempting to use it or any global variables it exposes.Evaluate modern Webpack features for remote asset loading. For shared modules across multiple applications, Module Federation is recommended. For simple dynamic script injection, consider native `import()` or custom asset modules.
Exercise extreme caution when using this package, especially in production environments. Prefer loading assets from trusted CDN sources with integrity checks if possible, or consider self-hosting critical external scripts. Regularly audit your dependencies.
Ensure `externals: [require('webpack-require-http')]` (or `require('webpack-require-http').custom(...)`) is correctly placed within your webpack configuration's top-level object.Always wait for the `require()` Promise to resolve before attempting to use any global variables or side effects exposed by the remote script. Wrap usage in a `.then()` block or use `await`.
Ensure your Webpack configuration and environment are set up to process CommonJS `require` calls. This package is not compatible with native ESM `import` statements for remote resources.
No dependency data recorded yet.