{"id":25757,"library":"incremental-compiler","title":"Incremental Compiler","description":"A library for building incremental compilers and file watchers in Node.js, version 21.0.45. It wraps @parcel/watcher and chokidar to provide a unified, event-driven API for watching file changes and triggering compilation. Supports TypeScript, project-based configuration, and automatically ignores node_modules and .git. Unlike raw chokidar, it abstracts away watcher differences and provides a base class for project-aware compilation.","status":"active","version":"21.0.45","language":"javascript","source_language":"en","source_url":"https://github.com/darekf77/incremental-compiler","tags":["javascript"],"install":[{"cmd":"npm install incremental-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add incremental-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add incremental-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"native file watching backend","package":"@parcel/watcher","optional":false},{"reason":"fallback file watching backend","package":"chokidar","optional":false}],"imports":[{"note":"Exports are from the 'src' subpath; top-level import will fail.","wrong":"import { BaseClientCompiler } from 'incremental-compiler'","symbol":"BaseClientCompiler","correct":"import { BaseClientCompiler } from 'incremental-compiler/src'"},{"note":"Named export from src subpath; CJS require must use correct path.","wrong":"const { BaseClientCompilerOptions } = require('incremental-compiler')","symbol":"BaseClientCompilerOptions","correct":"import { BaseClientCompilerOptions } from 'incremental-compiler/src'"},{"note":"Same as above; all exports are in src/.","wrong":"import { incrementalWatcher } from 'incremental-compiler'","symbol":"incrementalWatcher","correct":"import { incrementalWatcher } from 'incremental-compiler/src'"}],"quickstart":{"code":"import { incrementalWatcher } from 'incremental-compiler/src';\n\nasync function watchAndCompile() {\n  const watcher = await incrementalWatcher(\n    ['src/**/*.ts', 'src/*.ts'],\n    { name: 'TS Watcher', ignoreInitial: true }\n  );\n  watcher.on('all', (event, filePath) => {\n    console.log(`File ${event}: ${filePath}`);\n    // trigger compilation\n  });\n}\n\nwatchAndCompile();","lang":"typescript","description":"Demonstrates setting up a file watcher with incrementalWatcher that looks for .ts files and logs changes."},"warnings":[{"fix":"Update all imports to use 'incremental-compiler/src' instead of 'incremental-compiler'.","message":"Exports are from 'incremental-compiler/src' subpath, not from the package root.","severity":"breaking","affected_versions":">=21.0.0"},{"fix":"Pass options object as second argument to super().","message":"BaseClientCompiler constructor signature changed: it now accepts options as second parameter.","severity":"deprecated","affected_versions":">=20.0.0"},{"fix":"Use a different watcher if you need to watch these directories.","message":"node_modules and .git directories are always ignored; cannot be overridden via options.","severity":"gotcha","affected_versions":"*"},{"fix":"Always wrap a single pattern in an array: ['pattern'].","message":"incrementalWatcher expects arrays of glob patterns, not single strings.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change import to 'incremental-compiler/src'.","cause":"Importing from package root instead of 'incremental-compiler/src'.","error":"Cannot find module 'incremental-compiler'"},{"fix":"Ensure you import as: import { incrementalWatcher } from 'incremental-compiler/src'.","cause":"Incorrect import path or missing destructuring.","error":"TypeError: incrementalWatcher is not a function"},{"fix":"Pass a valid options object as second argument, e.g., { name: 'my watcher' }.","cause":"Second argument to incrementalWatcher is missing or not an object.","error":"Error: options must be an object"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}