Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WebpackRequireFrom
✓ const WebpackRequireFrom = require('webpack-require-from');
✗ import WebpackRequireFrom from 'webpack-require-from';
Package is CJS-only; ESM import will fail. Use require().
WebpackRequireFrom
✓ const WebpackRequireFrom = require('webpack-require-from').default;
✗ const WebpackRequireFrom = require('webpack-require-from');
For TypeScript projects with esModuleInterop, default export may need .default. Check your TS config.
WebpackRequireFrom as default
✓ import WebpackRequireFrom = require('webpack-require-from');
✗ import WebpackRequireFrom from 'webpack-require-from';
When using TypeScript, use import = require() syntax for CJS modules.
Configures Webpack to resolve dynamic import chunks using a global function that can be defined at runtime.
// webpack.config.js
const WebpackRequireFrom = require('webpack-require-from');
module.exports = {
output: {
publicPath: '/static/',
},
plugins: [
new WebpackRequireFrom({
methodName: 'getChunkURL',
}),
],
};
// In your browser code:
window.getChunkURL = function(chunkName) {
return 'https://cdn.example.com/chunks/' + chunkName;
};
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'tapable'
tapable is a peer dependency and not automatically installed.
fixInstall tapable as a dev dependency: npm install tapable@^2.2.0 --save-dev
TypeError: webpackRequireFrom is not a constructor
Using ES module import syntax on a CJS module with default export.
fixUse require('webpack-require-from') or for TypeScript: import WebpackRequireFrom = require('webpack-require-from') Uncaught ReferenceError: chunkURL is not defined
Variable specified in 'variableName' option is not defined globally at runtime.
fixDefine window.chunkURL = 'your/path/' before any dynamic import.
Audit
Dependencies
tapablerequiredpeer dependency for Webpack plugin compatibility