Skip to content

Commit

Permalink
perf(actions): on build, only import the used compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
micalevisk committed Jul 16, 2023
1 parent 27faa64 commit 984b697
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions actions/build.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ import { join } from 'path';
import * as ts from 'typescript';
import { Input } from '../commands';
import { AssetsManager } from '../lib/compiler/assets-manager';
import { Compiler } from '../lib/compiler/compiler';
import { getBuilder } from '../lib/compiler/helpers/get-builder';
import { getTscConfigPath } from '../lib/compiler/helpers/get-tsc-config.path';
import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default';
import { getWebpackConfigPath } from '../lib/compiler/helpers/get-webpack-config-path';
import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
import { SwcCompiler } from '../lib/compiler/swc/swc-compiler';
import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
import { WatchCompiler } from '../lib/compiler/watch-compiler';
import { WebpackCompiler } from '../lib/compiler/webpack-compiler';
import { WorkspaceUtils } from '../lib/compiler/workspace-utils';
import {
Configuration,
Expand Down Expand Up @@ -159,6 +155,7 @@ export class BuildAction extends AbstractAction {
tsOptions: ts.CompilerOptions,
onSuccess: (() => void) | undefined,
) {
const { SwcCompiler } = await import('../lib/compiler/swc/swc-compiler');
const swc = new SwcCompiler(this.pluginsLoader);
await swc.run(
configuration,
Expand All @@ -180,7 +177,7 @@ export class BuildAction extends AbstractAction {
);
}

private runWebpack(
private async runWebpack(
configuration: Required<Configuration>,
appName: string,
commandOptions: Input[],
Expand All @@ -189,6 +186,7 @@ export class BuildAction extends AbstractAction {
watchMode: boolean,
onSuccess: (() => void) | undefined,
) {
const { WebpackCompiler } = await import('../lib/compiler/webpack-compiler')
const webpackCompiler = new WebpackCompiler(this.pluginsLoader);

const webpackPath =
Expand All @@ -214,7 +212,7 @@ export class BuildAction extends AbstractAction {
);
}

private runTsc(
private async runTsc(
watchMode: boolean,
options: Input[],
configuration: Required<Configuration>,
Expand All @@ -223,6 +221,7 @@ export class BuildAction extends AbstractAction {
onSuccess: (() => void) | undefined,
) {
if (watchMode) {
const { WatchCompiler } = await import('../lib/compiler/watch-compiler');
const watchCompiler = new WatchCompiler(
this.pluginsLoader,
this.tsConfigProvider,
Expand All @@ -240,6 +239,7 @@ export class BuildAction extends AbstractAction {
onSuccess,
);
} else {
const { Compiler } = await import('../lib/compiler/compiler');
const compiler = new Compiler(
this.pluginsLoader,
this.tsConfigProvider,
Expand Down

0 comments on commit 984b697

Please sign in to comment.