{"id":20817,"library":"webpack-require-from","title":"webpack-require-from","description":"Webpack plugin to control dynamic import chunk paths/URLs at runtime. v1.8.6 supports Webpack 2-5 and web workers. Lightweight, zero dependencies, production-tested. Unlike static output.publicPath, it allows runtime path overrides via a fixed path, a global variable, or a global method. Last release in 2021; stable maintenance mode.","status":"maintenance","version":"1.8.6","language":"javascript","source_language":"en","source_url":"https://github.com/agoldis/webpack-require-from","tags":["javascript","dynamic import","webpack","plugin","import","require.ensure","dynamic chunks"],"install":[{"cmd":"npm install webpack-require-from","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-require-from","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-require-from","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Webpack plugin compatibility","package":"tapable","optional":false}],"imports":[{"note":"Package is CJS-only; ESM import will fail. Use require().","wrong":"import WebpackRequireFrom from 'webpack-require-from';","symbol":"WebpackRequireFrom","correct":"const WebpackRequireFrom = require('webpack-require-from');"},{"note":"For TypeScript projects with esModuleInterop, default export may need .default. Check your TS config.","wrong":"const WebpackRequireFrom = require('webpack-require-from');","symbol":"WebpackRequireFrom","correct":"const WebpackRequireFrom = require('webpack-require-from').default;"},{"note":"When using TypeScript, use import = require() syntax for CJS modules.","wrong":"import WebpackRequireFrom from 'webpack-require-from';","symbol":"WebpackRequireFrom as default","correct":"import WebpackRequireFrom = require('webpack-require-from');"}],"quickstart":{"code":"// webpack.config.js\nconst WebpackRequireFrom = require('webpack-require-from');\n\nmodule.exports = {\n  output: {\n    publicPath: '/static/',\n  },\n  plugins: [\n    new WebpackRequireFrom({\n      methodName: 'getChunkURL',\n    }),\n  ],\n};\n\n// In your browser code:\nwindow.getChunkURL = function(chunkName) {\n  return 'https://cdn.example.com/chunks/' + chunkName;\n};","lang":"javascript","description":"Configures Webpack to resolve dynamic import chunks using a global function that can be defined at runtime."},"warnings":[{"fix":"Use 'suppressErrors' instead of 'supressErrors'.","message":"v1.3.1: 'supressErrors' option renamed to 'suppressErrors' (typo fix). Old name still works but deprecated.","severity":"breaking","affected_versions":">=1.3.1"},{"fix":"npm install tapable@^2.2.0","message":"v1.3.1: moved tapable from dependencies to peerDependencies. Ensure tapable@^2.2.0 is installed.","severity":"deprecated","affected_versions":">=1.3.1"},{"fix":"Provide only one of these options in the plugin config.","message":"The options 'path', 'variableName', and 'methodName' are mutually exclusive. Only one can be used at a time.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Define the variable on window or globalThis before any dynamic import.","message":"VariableName option must be a global variable name; it is evaluated at runtime. Ensure the variable exists before dynamic imports occur.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use v1.8.2 or later for Webpack 5.","message":"For Webpack 5, ensure your Webpack version is compatible; v1.8.2 added Webpack 5 support.","severity":"gotcha","affected_versions":">=1.8.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install tapable as a dev dependency: npm install tapable@^2.2.0 --save-dev","cause":"tapable is a peer dependency and not automatically installed.","error":"Module not found: Error: Can't resolve 'tapable'"},{"fix":"Use require('webpack-require-from') or for TypeScript: import WebpackRequireFrom = require('webpack-require-from')","cause":"Using ES module import syntax on a CJS module with default export.","error":"TypeError: webpackRequireFrom is not a constructor"},{"fix":"Define window.chunkURL = 'your/path/' before any dynamic import.","cause":"Variable specified in 'variableName' option is not defined globally at runtime.","error":"Uncaught ReferenceError: chunkURL is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}