Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically force close Rollup when done #4969

Merged
merged 1 commit into from May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/cli.ts
Expand Up @@ -22,5 +22,6 @@ if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
// do nothing
}

run(command);
// eslint-disable-next-line unicorn/no-process-exit
run(command).then(() => process.exit(0));
}
2 changes: 1 addition & 1 deletion cli/run/index.ts
Expand Up @@ -55,7 +55,7 @@ export default async function runRollup(command: Record<string, any>): Promise<v
if (isWatchEnabled(command.watch)) {
await loadFsEvents();
const { watch } = await import('./watch-cli');
watch(command);
await watch(command);
} else {
try {
const { options, warnings } = await getConfigs(command);
Expand Down
9 changes: 5 additions & 4 deletions cli/run/watch-cli.ts
Expand Up @@ -154,9 +154,10 @@ export async function watch(command: Record<string, any>): Promise<void> {
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(() => {});
}
12 changes: 1 addition & 11 deletions 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';
Expand Down Expand Up @@ -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
Expand Down