{"id":20244,"library":"null-loader","title":"null-loader","description":"A webpack loader that returns an empty module, useful for silencing unwanted imports (e.g., polyfills) in your bundle. Current stable version is 4.0.1 (released 2020-10-09), supporting webpack 4 and 5. Maintained under the webpack-contrib organization. Unlike other loaders, it provides a minimal no-op module instead of stripping imports entirely.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/webpack-contrib/null-loader","tags":["javascript","webpack"],"install":[{"cmd":"npm install null-loader","lang":"bash","label":"npm"},{"cmd":"yarn add null-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add null-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; works with webpack 4 or 5","package":"webpack","optional":false}],"imports":[{"note":"null-loader is a webpack loader, not a library; it is used in webpack config as a string reference.","wrong":"import 'null-loader'","symbol":"default","correct":"module.exports = { module: { rules: [{ test: /polyfill\\.js$/, use: 'null-loader' }] } }"},{"note":"While both require and import work in Node.js, webpack loader config traditionally uses require(). ESM import also works but is less common.","wrong":"import NullLoader from 'null-loader';","symbol":"NullLoader","correct":"const NullLoader = require('null-loader');"},{"note":"Do not invoke the loader function; pass the path or string name to 'use'. Using require.resolve() ensures correct path resolution.","wrong":"use: require('null-loader')()","symbol":"null-loader (as path)","correct":"use: require.resolve('null-loader')"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: path.resolve(__dirname, 'node_modules/some-polyfill/index.js'),\n        use: 'null-loader',\n      },\n    ],\n  },\n};","lang":"javascript","description":"Basic webpack configuration to replace a polyfill module with an empty module using null-loader."},"warnings":[{"fix":"Upgrade webpack to 4+ and remove any use of `emitFile` option.","message":"v4.0.0 removed support for webpack <4 and dropped the deprecated `emitFile` option.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Remove the 'emitFile' option from the loader configuration.","message":"The 'emitFile' option was removed in v4.0.0. Use webpack module.exportPreservedModules instead.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Always scope null-loader to specific files using `test` or `include` in the rule.","message":"Using null-loader on every JS file will break your build because it replaces modules with empty objects.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure the module being nullified has no side effects required by your application.","message":"null-loader does not preserve side effects; the replaced module is completely empty.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install null-loader --save-dev` and ensure node_modules path is correct.","cause":"null-loader is not installed or webpack cannot resolve it.","error":"Module not found: Error: Can't resolve 'null-loader' in '...'"},{"fix":"Remove the unknown option or upgrade null-loader to latest version.","cause":"Using null-loader with an unsupported option (e.g., `emitFile`).","error":"Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema."},{"fix":"Upgrade to webpack 4+ or use null-loader@3 for webpack 3.","cause":"Using null-loader with webpack 3 or earlier.","error":"TypeError: this.getOptions is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}