![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
watcher-require
Advanced tools
Require a module and receive a callback each time the module or one of his dependencies has been modified
With this module you will receive a callback when a module or its dependencies are modified.
To receive a callback for any non-native dependecies an specific module loads, see https://github.com/Llorx/custom-require
To always receive an updated version of your modules, checking files and dependencies modifications, see https://github.com/Llorx/updated-require
npm install watcher-require
If you want a lightweight installation, but less consistent as uses nodejs fs.watch()
instead of chokidar
library, install with:
npm install watcher-require --no-optional
/* FILE: test1.js */
// Load any non-native module
require("react");
/* FILE: test2.js */
// Load any non-native module
require("react");
require("redux");
/* FILE: main.js */
// Load the module at the top of the entry point file
var WatcherRequire = require("watcher-require").WatcherRequire;
// If you are using TypeScript, you can use import
import { WatcherRequire } from "watcher-require";
// Instantiate an object with a callback that will be called with all the new changes
var watcherRequire = new WatcherRequire(function(changes) {
console.log("Something has changed! decache and reload!");
console.log(changes.add, changes.changed, changes.unlink);
}, {
delay: 300, // The callback will not be called instantly. You will receive one callback per each bunch of files changed
persistent: true // Keep the process open, watching files
});
// Require a module to start watching
watcherRequire.require("./test");
// You can also require another file to watch
watcherRequire.require("./test2");
// You can create different Watcher Require instances together in the same script
var secondWatcher = new WatcherRequire(function() {
console.log("Second watcher");
});
// Requiring modules already required by another instance will not be a problem
// Second watcher will receive all the dependencies too
// The require method will work as the default require one, returning the exports contents
var yay = secondWatcher.require("./test");
// Yay it
console.log(yay);
// After you have finished, call dispose() to clean resources attached to modules
watcherRequire.dispose();
secondWatcher.dispose();
Also, it works with asynchronous requires
/* FILE: async_test.js */
// Load any non-native module
require("react");
setTimeout(function() {
require("redux");
}, 1000);
See Custom Require limitations: https://github.com/Llorx/custom-require#limitations
FAQs
Require a module and receive a callback each time the module or one of his dependencies has been modified
The npm package watcher-require receives a total of 24 weekly downloads. As such, watcher-require popularity was classified as not popular.
We found that watcher-require demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.