{"id":20854,"library":"webpack-watch-external-files-plugin","title":"Webpack Watch External Files Plugin","description":"A zero-dependency Webpack 5 plugin that triggers recompilation when external files (not part of the build graph) change. Current version 4.1.0 is ESM-only with Node >=20 required. Key differentiator: no dependencies, supports glob patterns and negations, lightweight alternative to manual watchers.","status":"active","version":"4.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/amitsingh-007/webpack-watch-external-files-plugin","tags":["javascript","webpack","webpack plugin","watch external files","typescript"],"install":[{"cmd":"npm install webpack-watch-external-files-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-watch-external-files-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-watch-external-files-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for plugin hooks","package":"webpack","optional":false}],"imports":[{"note":"ESM-only since v4.x; use v3.x for CJS.","wrong":"const WatchExternalFilesPlugin = require('webpack-watch-external-files-plugin')","symbol":"WatchExternalFilesPlugin","correct":"import { WatchExternalFilesPlugin } from 'webpack-watch-external-files-plugin'"},{"note":"Default export also works, but named is preferred.","wrong":"import WatchExternalFilesPlugin from 'webpack-watch-external-files-plugin'","symbol":"default (WatchExternalFilesPlugin)","correct":"import WatchExternalFilesPlugin from 'webpack-watch-external-files-plugin'"},{"note":"TypeScript types are bundled since v2.x.","wrong":null,"symbol":"ts type","correct":"import type { WatchExternalFilesPluginOptions } from 'webpack-watch-external-files-plugin'"}],"quickstart":{"code":"import { WatchExternalFilesPlugin } from 'webpack-watch-external-files-plugin';\n\nexport default {\n  plugins: [\n    new WatchExternalFilesPlugin({\n      files: ['/config/**/*.json', '!/config/secrets.json'],\n    }),\n  ],\n};","lang":"typescript","description":"Example webpack config showing how to watch external JSON configs excluding secrets."},"warnings":[{"fix":"Use import syntax or downgrade to v3.x.","message":"ESM-only since v4.0: Cannot require() the module.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade Node.js to v20+ or use v3.x (requires Node >=16).","message":"Node.js >=20 required since v4.0.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade Node.js to v16+ or use v2.x (requires Node >=14).","message":"Node.js >=16 required since v3.0.","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"},{"fix":"Use the same pattern as in the example: files: ['**/*.txt', '!**/ignore.txt'].","message":"Negated glob patterns are supported but must be part of the same array.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add '!**/node_modules/**' to the files array.","message":"The plugin does not ignore node_modules by default; you must explicitly add !**/node_modules/** if needed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install webpack-watch-external-files-plugin --save-dev and use Node >=20","cause":"Missing install or Node.js version too low for ESM.","error":"Cannot find module 'webpack-watch-external-files-plugin'"},{"fix":"Change require to import: import { WatchExternalFilesPlugin } from 'webpack-watch-external-files-plugin'","cause":"Using require() on ESM-only v4+.","error":"WatchExternalFilesPlugin is not a constructor"},{"fix":"Ensure files option is an array of glob patterns.","cause":"Passing empty or invalid options (e.g., files missing).","error":"Error: [webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}