Skip to content

Commit

Permalink
feat: support --preserveWatchOutput for 'build' command
Browse files Browse the repository at this point in the history
  • Loading branch information
micalevisk committed Jul 30, 2023
1 parent ff52a06 commit b923083
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion actions/build.action.ts
Expand Up @@ -186,7 +186,9 @@ export class BuildAction extends AbstractAction {
watchMode: boolean,
onSuccess: (() => void) | undefined,
) {
const { WebpackCompiler } = await import('../lib/compiler/webpack-compiler')
const { WebpackCompiler } = await import(
'../lib/compiler/webpack-compiler'
);
const webpackCompiler = new WebpackCompiler(this.pluginsLoader);

const webpackPath =
Expand Down
14 changes: 13 additions & 1 deletion commands/build.command.ts
Expand Up @@ -18,7 +18,11 @@ export class BuildCommand extends AbstractCommand {
)
.option('--type-check', 'Enable type checking (when SWC is used).')
.option('--webpackPath [path]', 'Path to webpack configuration.')
.option('--tsc', 'Use tsc for compilation.')
.option('--tsc', 'Use typescript compiler for compilation.')
.option(
'--preserveWatchOutput',
'Use "preserveWatchOutput" option when using tsc watch mode.',
)
.description('Build Nest application.')
.action(async (app: string, command: Command) => {
const options: Input[] = [];
Expand Down Expand Up @@ -67,6 +71,14 @@ export class BuildCommand extends AbstractCommand {
value: command.typeCheck,
});

options.push({
name: 'preserveWatchOutput',
value:
!!command.preserveWatchOutput &&
!!command.watch &&
!isWebpackEnabled,
});

const inputs: Input[] = [];
inputs.push({ name: 'app', value: app });
await this.action.handle(inputs, options);
Expand Down
4 changes: 2 additions & 2 deletions commands/start.command.ts
Expand Up @@ -23,7 +23,7 @@ export class StartCommand extends AbstractCommand {
)
.option('--webpackPath [path]', 'Path to webpack configuration.')
.option('--type-check', 'Enable type checking (when SWC is used).')
.option('--tsc', 'Use tsc for compilation.')
.option('--tsc', 'Use typescript compiler for compilation.')
.option(
'--sourceRoot [sourceRoot]',
'Points at the root of the source code for the single project in standard mode structures, or the default project in monorepo mode structures.',
Expand All @@ -35,7 +35,7 @@ export class StartCommand extends AbstractCommand {
.option('-e, --exec [binary]', 'Binary to run (default: "node").')
.option(
'--preserveWatchOutput',
'Use "preserveWatchOutput" option when tsc watch mode.',
'Use "preserveWatchOutput" option when using tsc watch mode.',
)
.description('Run Nest application.')
.action(async (app: string, command: Command) => {
Expand Down
5 changes: 4 additions & 1 deletion lib/schematics/abstract.collection.ts
Expand Up @@ -3,7 +3,10 @@ import { Schematic } from './nest.collection';
import { SchematicOption } from './schematic.option';

export abstract class AbstractCollection {
constructor(protected collection: string, protected runner: AbstractRunner) {}
constructor(
protected collection: string,
protected runner: AbstractRunner,
) {}

public async execute(
name: string,
Expand Down

0 comments on commit b923083

Please sign in to comment.