rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

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

Open JasonGore opened this issue 4 years ago • 5 comments

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

  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.

  • 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

JasonGore avatar May 19 '20 17:05 JasonGore

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": ""
}

halfnibble avatar May 27 '20 18:05 halfnibble

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.

JasonGore avatar May 27 '20 18:05 JasonGore

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 ?

yujiaze avatar May 20 '21 12:05 yujiaze

still can not ignore missing build script???

leohxj avatar Apr 09 '22 04:04 leohxj

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.

ajmeese7 avatar Jun 18 '22 14:06 ajmeese7