Skip to content

Rollup doesn't exit correclty within a prepublishOnly lifecycle #4998

@weaintplastic

Description

@weaintplastic

Rollup Version

3.21.3

Operating System (or Browser)

Mac OS

Node Version (if applicable)

16

Link To Reproduction

https://stackblitz.com/edit/node-7qf5yb?file=package.json,rollup.config.js,index.js

Expected Behaviour

Given npm scripts that are structured like this:

"scripts": {
    "build": "npm run build.job1 && npm run build.job2 && npm run build.job3",
    "build.job1": "echo job 1",
    "build.job2": "rollup -c --bundleConfigAsCjs",
    "build.job3": "echo job 2",
    "prepublishOnly": "npm run build"
  }

It's expected that all build jobs (1, 2, 3) are executed and terminated correctly when calling npm run build or when they are called as part of npm's publishing lifecycle through prepublishOnly.

Actual Behaviour

Starting with version 3.21.3 we notice some unexpected behavior.

All build jobs (1, 2, 3) are running and terminated as expected when running them with npm run build directly.
Though when their execution is part of the prepublishOnly lifecycle, things are getting odd:

  • npm run build.job3 is never called
  • npm is publishing the package too early. The process is kicked off the moment npm run build.job2 (which is executing rollup) seems to have finished its job but somehow hasn't terminated correctly

I've tried to create a reproduction example but without the whole npm ecosystem set up with a package that actually can be published, it's quite hard to create such case.

I'm happy to ramp up a whole setup if needed to inspect this issue in more depth. Buth maybe the behavior I described does already ring a bell 🤞

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions