I have a React multimodule project.
Every module is built with rollup and has its commands defined as
"build": "rollup -c","watch": "rollup -cw"
From the main package.json
I have this scripts section:
"watch:all": "npm-run-all build:shared --parallel watch:shared watch:a watch:b","watch:a": "yarn w:a watch","watch:b": "yarn w:b watch","watch:shared": "yarn w:shared watch","build:shared": "yarn w:shared build"
Since the modules a
and b
depend both on the shared
module, I build the shared package first, in order to have my dependencies satisfied, and then I watch everything in parallel, so it is easy to develop. This works fine, but obliges me to build the shared package BEFORE watching all.
I want to use the yarn workspaces foreach command instead of the npm-run-all
package, because it can with the -t
flag wait for the packages that depend on others. This in fact works nicely when I do
yarn workspaces foreach -Rpvti --from "{@company/shared,@company/a,@company/b}" run build
But when I do
yarn workspaces foreach -Rpvti --from "{@company/shared,@company/a,@company/b}" run watch
the shared package is correctly built as you can see from the logs:
➤ YN0000: [@company/shared]: Process started➤ YN0000: [@company/shared]: (node:6013) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time➤ YN0000: [@company/shared]: (Use `node --trace-warnings ...` to show where the warning was created)➤ YN0000: [@company/shared]: rollup v4.12.1➤ YN0000: [@company/shared]: bundles src/index.ts → lib/esm/index.js, lib/cjs/index.js...➤ YN0000: [@company/shared]: created lib/esm/index.js, lib/cjs/index.js in 3s
But then it remains stuck here and it doesn't proceed at all.
I really can't understand why it is doing such a weird behavior.