rushstack
rushstack copied to clipboard
[rush] Rebuild command fails when build is configured to ignoreMissingScript
Is this a feature or a bug?
- [ ] Feature
- [X] Bug
Please describe the actual behavior.
build
can be specified as a "ignoreMissingScript": true
and build will succeed successfully, ignoring any packages that do not have a script entry for build
.
However, the default rebuild
command will fail on said packages:
ERROR: The project [...] does not define a 'build' command in the 'scripts' section of its package.json
If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.
https://github.com/JasonGore/rush-build-rebuild-repro
- Clone and run
rush install
- Run
rush build
, which will completely successfully - Run
rush rebuild
, which will error
What is the expected behavior?
The default rebuild
command should run without error if build
is set to ignoreMissingScript
.
If this is a bug, please provide the tool version, Node.js version, and OS.
- Tool: Rush
- Tool Version: 5.23.3
-
Node Version: 12.16.3
- Is this a LTS version? Y
- Have you tested on a LTS version?
- OS: Windows
Thanks for the bug report.
It looks like rush rebuild will correctly handle an empty build script (printing out "had an empty script"), but does not handle the missing build script scenario. Rebuild should probably behave the same way build does, and should treat a missing script like an empty script when ingoreMissingScript
is set to true
.
Workaround
Until a fix is available, you can set an empty build script as a workaround for rush rebuild.
"scripts": {
"build": ""
}
That's what I've had to do for now, but these types of script entries are incompatible with npm. If users try to run npm run build
in that package, it will error for some versions of Node.
will this bug be fixed ?
Note that if the "rebuild" command is overridden here, it becomes separated from the "build" command and will call the "rebuild" script instead of the "build" script.
⬆️ reference from the document,is this a feature ?
still can not ignore missing build script???
I would also like an option to ignore projects that do not contain the specified command. For example, my eslint
project in my repo defines configurations for all of the other projects, but I obviously don't need an eslint command for it because it has no files that the command would need to be ran on. The workaround works for now but I would prefer to keep a cleaner package.json
that doesn't contain unnecessary commands.