Skip to content

Commit

Permalink
fix: close assets watchers after compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jun 19, 2023
1 parent c249246 commit 0cd25e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions actions/build.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class BuildAction extends AbstractAction {
'typeCheck',
options,
),
assetsManager: this.assetsManager,
},
onSuccess,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/swc/forked-type-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ForkedTypeChecker extends BaseCompiler {
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string | undefined,
extras: SwcCompilerExtras,
extras: Pick<SwcCompilerExtras, 'typeCheck' | 'watch'>,
) {
const { readonlyVisitors } = this.loadPlugins(
configuration,
Expand Down
8 changes: 7 additions & 1 deletion lib/compiler/swc/swc-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { join } from 'path';
import { Configuration } from '../../configuration';
import { ERROR_PREFIX } from '../../ui';
import { treeKillSync } from '../../utils/tree-kill';
import { AssetsManager } from '../assets-manager';
import { BaseCompiler } from '../base-compiler';
import { swcDefaultsFactory } from '../defaults/swc-defaults';
import { PluginMetadataGenerator } from '../plugins/plugin-metadata-generator';
Expand All @@ -20,6 +21,7 @@ import { TypeCheckerHost } from './type-checker-host';
export type SwcCompilerExtras = {
watch: boolean;
typeCheck: boolean;
assetsManager: AssetsManager;
};

export class SwcCompiler extends BaseCompiler {
Expand Down Expand Up @@ -56,7 +58,11 @@ export class SwcCompiler extends BaseCompiler {
await this.runTypeChecker(configuration, tsConfigPath, appName, extras);
}
await this.runSwc(swcOptions, extras);
onSuccess?.();
if (onSuccess) {
onSuccess();
} else {
extras.assetsManager?.closeWatchers();
}
}
}

Expand Down

0 comments on commit 0cd25e6

Please sign in to comment.