Registry / devops / component-watcher

component-watcher

JSON →
library1.0.3jsnpmunverified

The `component-watcher` package, last updated in 2015 with version 1.0.3, served as a file watching utility specifically designed for the "Component" JavaScript module system. It monitored a `component.json` file and emitted events (`resolve`, `scripts`, `styles`) when changes occurred in relevant files, allowing external tools to trigger rebuilds or re-resolutions of assets. The package’s development ceased around 2015, coinciding with the broader decline of the "Component" ecosystem in favor of modern bundlers like Webpack, Rollup, and Parcel. Consequently, it is not actively maintained, does not follow a release cadence, and is largely obsolete for contemporary web development workflows. Its core differentiator was its tight integration with the now-defunct "Component" build process, which is no longer a prevalent method for front-end asset management.

npm install component-watcher
INSTALL
IMPORT
SIG · COMPONENT-WATCHER
C
component-watcher
devopsjavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

watch
const watch = require('component-watcher')
import { watch } from 'component-watcher'
This package is CommonJS-only, as it was last updated in 2015. Direct ESM imports are not supported.
Watcher instance
const watcher = require('component-watcher')()
import watcher from 'component-watcher'
The default export is the `watch` function, which is then called to create a watcher instance. There is no default ESM export.

This quickstart demonstrates how to initialize the `component-watcher` to monitor a `component.json` file and associated script files within a specified root directory. It sets up event listeners for `resolve`, `scripts`, and `styles` changes, logging messages when these events are emitted, and includes basic setup and cleanup for a temporary project structure.

const watch = require('component-watcher'); const path = require('path'); // Create a dummy component.json and a script file for demonstration const fs = require('fs'); const rootDir = path.join(__dirname, 'temp_component_project'); const componentJsonPath = path.join(rootDir, 'component.json'); const scriptFilePath = path.join(rootDir, 'index.js'); if (!fs.existsSync(rootDir)) fs.mkdirSync(rootDir, { recursive: true }); fs.writeFileSync(componentJsonPath, JSON.stringify({ "name": "my-component", "version": "1.0.0", "scripts": [ "index.js" ] }, null, 2)); fs.writeFileSync(scriptFilePath, '// Initial script content\nconsole.log("Hello");'); console.log(`Watching directory: ${rootDir}`); const watcher = watch({ root: rootDir, development: true, // Watch development specific fields extensions: { scripts: ['js', 'json', 'html'], styles: ['css'] }, fields: { scripts: ['scripts', 'json', 'templates'], styles: ['styles'] } }); watcher.on('resolve', () => { console.log('Event: resolve - component.json or file added/removed. Re-resolve dependencies.'); }); watcher.on('scripts', () => { console.log('Event: scripts - A script file changed. Rebuild scripts.'); }); watcher.on('styles', () => { console.log('Event: styles - A style file changed. Rebuild styles.'); }); watcher.on('error', (err) => { console.error('Watcher encountered an error:', err); }); // The watcher starts automatically, but can be manually started/restarted // watcher.start(); console.log('Watcher initialized. Try modifying or deleting temp_component_project/index.js or temp_component_project/component.json'); console.log('Press Ctrl+C to stop and clean up.'); // Keep the process alive and clean up on exit process.on('SIGINT', () => { console.log('\nStopping watcher and cleaning up...'); watcher.stop(); fs.unlinkSync(componentJsonPath); fs.unlinkSync(scriptFilePath); fs.rmdirSync(rootDir); process.exit(); });
Debug
Known issues
breakingThe `component-watcher` package is abandoned and has not been updated since 2015. It relies on the defunct 'Component' JavaScript module system, which is no longer used in modern web development. Using this package in contemporary projects is highly discouraged.
fix
Migrate to modern file watching solutions like `chokidar` or bundler-specific watch modes (e.g., Webpack's `watch` option, Rollup's `rollup -w`, Parcel's built-in watcher).
affects: >=1.0.0
gotchaThis package is CommonJS-only. Attempting to use `import` syntax directly in an ESM module will result in a `TypeError: require is not a function` or similar module resolution errors. It was developed prior to widespread ESM adoption in Node.js.
fix
Ensure usage strictly adheres to CommonJS `require()` syntax within a CommonJS environment. If used in an ESM project, an explicit CommonJS wrapper or bundler configuration would be necessary, but this is not recommended due to the package's overall deprecation.
affects: >=1.0.0
gotchaThe package's reliance on a specific `component.json` structure and the 'Component' ecosystem means it will not function as a general-purpose file watcher for projects using other module systems or build tools. Its events are tailored to the 'Component' build process.
fix
Use dedicated file watchers or build tool features for your specific project setup. For example, `webpack-dev-server` for Webpack projects, `rollup-plugin-serve` for Rollup, or `nodemon` for Node.js server restarts.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `import watch from 'component-watcher'` in an ECMAScript Module (ESM) context.
fix
This package is CommonJS-only. Use `const watch = require('component-watcher');` instead, and ensure your project or file is treated as CommonJS.
Error: EMFILE: too many open files, watch
The underlying file watching mechanism (likely Node.js `fs.watch`) hit the system's limit for open file descriptors when watching a large number of files or deeply nested directories.
fix
This package is not actively maintained and may not implement robust error handling or optimization for file descriptor limits. Consider using modern file watchers like `chokidar` or `@parcel/watcher` which offer better performance and handle these issues more gracefully. If you must use it, try increasing your system's `ulimit -n`.
Watcher encountered an error: Error: ENOENT: no such file or directory, stat 'path/to/component.json'
`component-watcher` was initialized with a `root` option that does not contain a `component.json` file or refers to a non-existent path.
fix
Ensure the `root` option points to a directory that exists and contains a valid `component.json` file, as this package is tightly coupled to that specific project structure.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
component-watcher — npm install component-watcher · libregistry