microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.82k stars 592 forks source link

[rush] Rebuild command fails when build is configured to ignoreMissingScript #1877

Open JasonGore opened 4 years ago

JasonGore commented 4 years ago

Is this a feature or a 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

  1. Clone and run rush install
  2. Run rush build, which will completely successfully
  3. 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.

halfnibble commented 4 years ago

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": ""
}
JasonGore commented 4 years ago

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.

yujiaze commented 3 years ago

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 ?

leohxj commented 2 years ago

still can not ignore missing build script???

ajmeese7 commented 2 years ago

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.