diff --git a/cli/cli.ts b/cli/cli.ts index d06f13c84c5..e049502375a 100644 --- a/cli/cli.ts +++ b/cli/cli.ts @@ -1,16 +1,16 @@ -import process from 'node:process'; +import { argv, exit, stdin } from 'node:process'; import help from 'help.md'; import { version } from 'package.json'; import argParser from 'yargs-parser'; import { commandAliases } from '../src/utils/options/mergeOptions'; import run from './run/index'; -const command = argParser(process.argv.slice(2), { +const command = argParser(argv.slice(2), { alias: commandAliases, configuration: { 'camel-case-expansion': false } }); -if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) { +if (command.help || (argv.length <= 2 && stdin.isTTY)) { console.log(`\n${help.replace('__VERSION__', version)}\n`); } else if (command.version) { console.log(`rollup v${version}`); @@ -22,5 +22,5 @@ if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) { // do nothing } - run(command); + run(command).then(() => exit(0)); } diff --git a/cli/run/index.ts b/cli/run/index.ts index 6f0da69a708..24c382430b7 100644 --- a/cli/run/index.ts +++ b/cli/run/index.ts @@ -55,7 +55,7 @@ export default async function runRollup(command: Record): Promise): Promise { if (watcher) await watcher.close(); if (configWatcher) configWatcher.close(); - if (code) { - // eslint-disable-next-line unicorn/no-process-exit - process.exit(code); - } + // eslint-disable-next-line unicorn/no-process-exit + process.exit(code || 0); } + + // return a promise that never resolves to keep the process running + return new Promise(() => {}); } diff --git a/rollup.config.ts b/rollup.config.ts index 76c37cac3da..9c3d9c71e08 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,4 +1,3 @@ -import { exit } from 'node:process'; import { fileURLToPath } from 'node:url'; import alias from '@rollup/plugin-alias'; import commonjs from '@rollup/plugin-commonjs'; @@ -138,16 +137,7 @@ export default async function ( terser({ module: true, output: { comments: 'some' } }), collectLicensesBrowser(), writeLicenseBrowser(), - cleanBeforeWrite('browser/dist'), - { - closeBundle() { - // On CI, MacOS runs sometimes do not close properly. This is a hack - // to fix this until the problem is understood. - console.log('Force quit.'); - setTimeout(() => exit(0)); - }, - name: 'force-close' - } + cleanBeforeWrite('browser/dist') ], strictDeprecations: true, treeshake