Skip to content

Commit

Permalink
Merge pull request #2179 from micalevisk/perf/eage-load-compilers
Browse files Browse the repository at this point in the history
perf(actions): only load the files of the used compiler on running `build` or `start` commands
  • Loading branch information
kamilmysliwiec committed Jul 17, 2023
2 parents 36a7111 + 5cc0c8a commit 7609844
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.d.ts
src/**/*.test.ts
src/**/files/**
test/**
test/**
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 7609844

Please sign in to comment.