Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
watch-module
Advanced tools
A Javascript module watcher to work locally with packages.
Replace the "not-really-functionnal" npm | yarn link.
Place yourself at the root of your main package and call:
npx watch-module /path/to/my/module
watch-module will detect code changes in your module, run the build
script (if available) and copy the code into your node_modules
folder.
watch-module will not copy the node_modules folder contained inside your module
watch-modules does support multiple modules:
npx watch-module /path/to/my/module ../my-other-module
On first launch, watch-module creates an empty configuration file to {HOME_FOLDER}/.config/watch-module/watch-module.json
In order to force a different configuration for a specific module, you can add "per module" entries to this file :
{
// watch the files in the "lib" directory
// and call "npm run build:prepare" script when there is a change
"my-awesome-module": {
"includes": ["lib"],
"command": "npm run build:prepare"
},
// watch all the files in the root directory
// do not watch the files in the "dist" directory
// do not call any command before copying the files
"my-other-module": {
"command": null,
"includes": [""], // use "" or "." to watch all files
"excludes": ["dist"]
}
}
You can override this global configuration by configuring the targeted module's package.json
file direclty:
{
"name": "my package",
"scripts": {
"build:prod": "touch build.js"
},
"watch-module": {
"command": "yarn run build:prod",
"includes": ["src"]
}
}
If no configuration is found for a module, watch-module falls back to the default configuration:
{
"command": "yarn|npm run build", // default configs tries to detect yarn or npm
"includes": ["src"],
"excludes": []
}
yarn|npm run build
)The command that will be triggered when a change is detected.
It can either be:
string
of a command to run{ [pattern: string]: string }
to trigger specific command according to the file changes (ex: { "*.js": "npm run build:js", "*.css": "npm run build:css" }
) [experimental]null
if you just want to copy the files and do nothing elseUsing an object of pattern: command
is still experimental and needs some real-world usage.
An array of string of files or directory to watch.
Default is ['src/']
An array of string of files or directory to exclude from included paths.
Default is []
If you overrides only some parts of the configuration, then the keys that are not overiden will use the default configuration.
[npm link | yarn link] : it does work fine until you have dependencies, etc. in your package.
yalc : nice alternative, but too complex for our purpose (it does use a local repository, that you need to push on change, etc.)
If you have the error Command not found
, you can force npx to use the latest version of the package:
npx watch-module@latest
It should resolve the issue.
You can start a builder in watch mode with yarn dev
. It will automatically build on each change of file in the src/
directory.
In another terminal, you can go in the demo/app
folder and use the build this way:
cd demo/app
node ../../build/watch-module.js ../package ../package2 -v
3.0.2
FAQs
A Javascript module watcher to work locally with package
The npm package watch-module receives a total of 2 weekly downloads. As such, watch-module popularity was classified as not popular.
We found that watch-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.