{"_id":"watchpack@2.6.3","bugs":{"url":"https://github.com/webpack/watchpack/issues"},"dist":{"shasum":"880d8c437c425104b2da58bee6bd8fbc33bf78d3","tarball":"http://registry-npm.ywwl.com/watchpack/download/watchpack-2.6.3.tgz","fileCount":19,"integrity":"sha512-s3NZy0QpTY9qGqzc0wtz4qI28z3+5qKbbAec4MV4G9N3CfgZ9wgvQRr0cl2jh/tqkWG1NWHkmVMHZpCamev5Wg==","signatures":[{"sig":"MEQCIFLLjOz6StJSc/c2eRrqHanssV4sFd3mo8uJVmbmGVdKAiAqzNAcWCGU2aAqv9rWPoCReNXvaqGUwSTKENSOspeBuA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD73Y8n0LzK28hWvTQkick5NdbAeaaVuYjmEJvAph1eKQIhALGHuo7JWMFvTFg+w8RKR8gcsf3An8tOI1T6GggG3GyR"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/watchpack@2.6.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":117621,"size":28570,"noattachment":false,"key":"/watchpack/-/watchpack-2.6.3.tgz"},"main":"lib/index.js","name":"watchpack","types":"types/index.js","author":{"name":"Tobias Koppers @sokra"},"engines":{"node":">=10.13.0"},"gitHead":"f70878275d1fe34339414149baa0e5ef2b84dd0f","license":"MIT","scripts":{"fix":"npm run fix:code && npm run fix:declarations","fmt":"npm run fmt:base -- --log-level warn --write","lint":"npm run lint:code && npm run lint:types && npm run lint:types-test && npm run lint:declarations && npm run fmt:check","test":"npm run test:coverage","pretest":"npm run lint","release":"changeset publish","version":"changeset version","fix:code":"npm run lint:code -- --fix","fmt:base":"prettier --cache --ignore-unknown .","benchmark":"node --max-old-space-size=4096 --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./benchmark/run.mjs","fmt:check":"npm run fmt:base -- --check","lint:code":"eslint --cache .","test:base":"jest --runInBand","test:only":"npm run test:base","lint:types":"tsc --noEmit","test:watch":"npm run test:base -- --watch","test:coverage":"npm run test:base -- --collectCoverageFrom=\"lib/**/*.js\" --coverage","lint:types-test":"tsc -p tsconfig.types.test.json --noEmit","fix:declarations":"tsc && npm run fmt -- ./types","lint:declarations":"npm run fix:declarations && git diff --exit-code ./types"},"version":"2.6.3","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"e429b9f1-21d4-46a5-aea9-671c3ca84705"}},"homepage":"https://github.com/webpack/watchpack","repository":{"url":"git+https://github.com/webpack/watchpack.git","type":"git"},"_npmVersion":"11.19.0","description":"Wrapper library for directory and file watching.","directories":{"test":"test"},"maintainers":[{"name":"15000621931","email":"784487301@qq.com"},{"name":"ev1stensberg","email":"evenstensberg@gmail.com"},{"name":"__hai","email":"haijie0619@gmail.com"},{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"avivkeller","email":"me@aviv.sh"},{"name":"evilebottnawi","email":"sheo13666q@gmail.com"}],"_nodeVersion":"24.21.0","dependencies":{"graceful-fs":"^4.1.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.5.2","eslint":"^9.39.5","prettier":"^3.9.10","tinybench":"^6.2.2","typescript":"^6.0.2","@types/jest":"^30.0.0","@types/node":"^24.19.2","@codspeed/core":"^5.2.0","@changesets/cli":"^3.0.3","write-file-atomic":"^8.0.0","@types/graceful-fs":"^4.1.9","@types/glob-to-regexp":"^0.4.4","eslint-config-webpack":"^4.15.0","@changesets/get-github-info":"^1.0.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/watchpack_2.6.3_1792336049392_0.5889846311994378"},"readme":"# watchpack\n\nWrapper library for directory and file watching.\n\n[![Test](https://github.com/webpack/watchpack/actions/workflows/test.yml/badge.svg)](https://github.com/webpack/watchpack/actions/workflows/test.yml)\n[![Codecov](https://codecov.io/gh/webpack/watchpack/graph/badge.svg?token=8xk2OrrxWm)](https://codecov.io/gh/webpack/watchpack)\n[![Downloads](https://img.shields.io/npm/dm/watchpack.svg)](https://www.npmjs.com/package/watchpack)\n\n## Concept\n\nwatchpack high level API doesn't map directly to watchers. Instead a three level architecture ensures that for each directory only a single watcher exists.\n\n- The high level API requests `DirectoryWatchers` from a `WatcherManager`, which ensures that only a single `DirectoryWatcher` per directory is created.\n- A user-faced `Watcher` can be obtained from a `DirectoryWatcher` and provides a filtered view on the `DirectoryWatcher`.\n- Reference-counting is used on the `DirectoryWatcher` and `Watcher` to decide when to close them.\n- The real watchers are created by the `DirectoryWatcher`.\n- Files are never watched directly. This should keep the watcher count low.\n- Watching can be started in the past. This way watching can start after file reading.\n- Symlinks are not followed, instead the symlink is watched.\n\n## API\n\n```javascript\nconst Watchpack = require(\"watchpack\");\n\nconst wp = new Watchpack({\n\t// options:\n\taggregateTimeout: 1000,\n\t// fire \"aggregated\" event when after a change for 1000ms no additional change occurred\n\t// aggregated defaults to undefined, which doesn't fire an \"aggregated\" event\n\n\tpoll: true,\n\t// poll: true - use polling with the default interval\n\t// poll: 10000 - use polling with an interval of 10s\n\t// poll defaults to undefined, which prefer native watching methods\n\t// Note: enable polling when watching on a network path\n\t// When WATCHPACK_POLLING environment variable is set it will override this option\n\n\tfollowSymlinks: true,\n\t// true: follows symlinks and watches symlinks and real files\n\t//   (This makes sense when symlinks has not been resolved yet, comes with a performance hit)\n\t// false (default): watches only specified item they may be real files or symlinks\n\t//   (This makes sense when symlinks has already been resolved)\n\n\tignored: \"**/.git\",\n\t// ignored: \"string\" - a glob pattern for files or folders that should not be watched\n\t// ignored: [\"string\", \"string\"] - multiple glob patterns that should be ignored\n\t// ignored: [\"string\", /regexp/] - a mix of glob patterns and regular expressions that should be ignored\n\t// ignored: /regexp/ - a regular expression for files or folders that should not be watched\n\t// ignored: (entry) => boolean - an arbitrary function which must return truthy to ignore an entry\n\t// For all cases expect the arbitrary function the path will have path separator normalized to '/'.\n\t// All subdirectories are ignored too\n});\n\n// Watchpack.prototype.watch({\n//   files: Iterable<string>,\n//   directories: Iterable<string>,\n//   missing: Iterable<string>,\n//   startTime?: number\n// })\nwp.watch({\n\tfiles: listOfFiles,\n\tdirectories: listOfDirectories,\n\tmissing: listOfNotExistingItems,\n\tstartTime: Date.now() - 10000,\n});\n// starts watching these files and directories\n// calling this again will override the files and directories\n// files: can be files or directories, for files: content and existence changes are tracked\n//        for directories: only existence and timestamp changes are tracked\n// directories: only directories, directory content (and content of children, ...) and\n//              existence changes are tracked.\n//              assumed to exist, when directory is not found without further information a remove event is emitted\n// missing: can be files or directories,\n//          only existence changes are tracked\n//          expected to not exist, no remove event is emitted when not found initially\n// files and directories are assumed to exist, when they are not found without further information a remove event is emitted\n// missing is assumed to not exist and no remove event is emitted\n\nwp.on(\"change\", (filePath, mtime, explanation) => {\n\t// filePath: the changed file\n\t// mtime: last modified time for the changed file\n\t// explanation: textual information how this change was detected\n});\n\nwp.on(\"remove\", (filePath, explanation) => {\n\t// filePath: the removed file or directory\n\t// explanation: textual information how this change was detected\n});\n\nwp.on(\"aggregated\", (changes, removals) => {\n\t// changes: a Set of all changed files\n\t// removals: a Set of all removed files\n\t// watchpack gives up ownership on these Sets.\n});\n\n// Watchpack.prototype.pause()\nwp.pause();\n// stops emitting events, but keeps watchers open\n// next \"watch\" call can reuse the watchers\n// The watcher will keep aggregating events\n// which can be received with getAggregated()\n\n// Watchpack.prototype.close()\nwp.close();\n// stops emitting events and closes all watchers\n\n// Watchpack.prototype.getAggregated(): { changes: Set<string>, removals: Set<string> }\nconst { changes, removals } = wp.getAggregated();\n// returns the current aggregated info and removes that from the watcher\n// The next aggregated event won't include that info and will only emitted\n// when futher changes happen\n// Can also be used when paused.\n\n// Watchpack.prototype.collectTimeInfoEntries(fileInfoEntries: Map<string, Entry>, directoryInfoEntries: Map<string, Entry>)\nwp.collectTimeInfoEntries(fileInfoEntries, directoryInfoEntries);\n// collects time info objects for all known files and directories\n// this include info from files not directly watched\n// key: absolute path, value: object with { safeTime, timestamp }\n// safeTime: a point in time at which it is safe to say all changes happened before that\n// timestamp: only for files, the mtime timestamp of the file\n\n// Watchpack.prototype.getTimeInfoEntries()\nconst fileTimes = wp.getTimeInfoEntries();\n// returns a Map with all known time info objects for files and directories\n// similar to collectTimeInfoEntries but returns a single map with all entries\n\n// (deprecated)\n// Watchpack.prototype.getTimes()\nconst fileTimesOld = wp.getTimes();\n// returns an object with all known change times for files\n// this include timestamps from files not directly watched\n// key: absolute path, value: timestamp as number\n```\n\n## Environment variables\n\n- `WATCHPACK_POLLING`: when set, overrides the `poll` option (see above).\n- `WATCHPACK_RETRIES`: number of times to retry `fs.lstat` when it returns\n  `EBUSY` (default: `3`). Useful on Windows where anti-virus scanners,\n  indexers or editors briefly lock files — without retries watchpack would\n  see a spurious `remove` and stop tracking the file. Set to `0` or\n  `\"false\"` to disable retrying.\n","publish_time":1792336049498,"_cnpm_publish_time":1792336049498,"dist-tags":{"beta":"2.0.0-beta.15","latest":"2.6.3","watchpack-1":"1.7.5"}}