{"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,"search_vec":"'-09':30 '-10':29 '2020':28 '4':33 '4.0.1':26 '5':35 'bundl':21 'contrib':41 'current':22 'e.g':17 'empti':10 'entir':58 'import':16,57 'instead':54 'javascript':59 'loader':3,6,45 'maintain':36 'minim':49 'modul':11,53 'no-op':50 'null':2 'null-load':1 'op':52 'organ':42 'polyfil':18 'provid':47 'releas':27 'return':8 'silenc':14 'stabl':23 'strip':56 'support':31 'unlik':43 'unwant':15 'use':12 'version':24 'webpack':5,32,40,60 'webpack-contrib':39","created_at":"2026-04-25T11:22:05.433379+00:00","updated_at":"2026-04-25T11:22:05.433379+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/webpack-contrib/null-loader","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/null-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}