diff --git a/lib/compiler/watch-compiler.ts b/lib/compiler/watch-compiler.ts index 79985c7a3..f1d8cf9ed 100644 --- a/lib/compiler/watch-compiler.ts +++ b/lib/compiler/watch-compiler.ts @@ -58,6 +58,12 @@ export class WatchCompiler { this.createWatchStatusChanged(origWatchStatusReporter, onSuccess), ); + const restartable = getValueOrDefault( + configuration, + 'compilerOptions.restartable', + appName, + ); + const pluginsConfig = getValueOrDefault( configuration, 'compilerOptions.plugins', @@ -72,7 +78,9 @@ export class WatchCompiler { host: ts.CompilerHost, oldProgram: ts.EmitAndSemanticDiagnosticsBuilderProgram, ) => { - displayManualRestartTip(); + if (restartable) { + displayManualRestartTip(); + } const tsconfigPathsPlugin = options ? tsconfigPathsBeforeHookFactory(options) @@ -128,16 +136,18 @@ export class WatchCompiler { const watchProgram = tsBin.createWatchProgram(host); - listenForManualRestart(() => { - watchProgram.close(); - this.run( - configuration, - configFilename, - appName, - tsCompilerOptions, - onSuccess, - ); - }); + if (restartable) { + listenForManualRestart(() => { + watchProgram.close(); + this.run( + configuration, + configFilename, + appName, + tsCompilerOptions, + onSuccess, + ); + }); + } } private createDiagnosticReporter( diff --git a/lib/configuration/configuration.ts b/lib/configuration/configuration.ts index 94fb170b4..2f6547adc 100644 --- a/lib/configuration/configuration.ts +++ b/lib/configuration/configuration.ts @@ -23,6 +23,7 @@ interface CompilerOptions { plugins?: string[] | PluginOptions[]; assets?: string[]; deleteOutDir?: boolean; + restartable?: boolean; } interface PluginOptions { diff --git a/lib/configuration/defaults.ts b/lib/configuration/defaults.ts index 3e7e39486..db3ff518b 100644 --- a/lib/configuration/defaults.ts +++ b/lib/configuration/defaults.ts @@ -15,6 +15,7 @@ export const defaultConfiguration: Required = { webpackConfigPath: 'webpack.config.js', plugins: [], assets: [], + restartable: true, }, generateOptions: {}, }; diff --git a/test/lib/configuration/nest-configuration.loader.spec.ts b/test/lib/configuration/nest-configuration.loader.spec.ts index 73fdf3e4a..c9a1cc3bf 100644 --- a/test/lib/configuration/nest-configuration.loader.spec.ts +++ b/test/lib/configuration/nest-configuration.loader.spec.ts @@ -52,6 +52,7 @@ describe('Nest Configuration Loader', () => { tsConfigPath: 'tsconfig.json', webpack: false, webpackConfigPath: 'webpack.config.js', + restartable: true, }, generateOptions: {}, }); @@ -76,6 +77,7 @@ describe('Nest Configuration Loader', () => { tsConfigPath: 'tsconfig.json', webpack: false, webpackConfigPath: 'webpack.config.js', + restartable: true, }, generateOptions: {}, });