1- import { prettifyPackageDistJson , prettifyPackageJson , prettifyReadme , prettifySrc } from "./build-prettier" ;
21import { Command } from "commander" ;
3- import { buildDistFiles } from "./build-distfiles" ;
4- import { buildTS } from "./build-tsc" ;
5- import { bundle } from "./build-bundle" ;
6- import { clearDist } from "./build-clear" ;
7- import fs from "fs-extra" ;
8- import { getDistStats } from "./build-diststats" ;
9- import { lint } from "./build-eslint" ;
10- import path from "path" ;
112
123const buildCommand = new Command ( "build" ) ;
134
@@ -42,13 +33,18 @@ buildCommand.action(async (argPath: string) => {
4233 tsc = all || ! ! opts . tsc ;
4334
4435 const basePath = process . cwd ( ) ,
36+ { getDistStats } = await import ( "./build-diststats.js" ) ,
4537 oldStats = await getDistStats ( basePath ) ;
4638
4739 if ( clean ) {
40+ const { clearDist } = await import ( "./build-clear.js" ) ;
41+
4842 await clearDist ( basePath ) ;
4943 }
5044
51- const srcPath = path . join ( basePath , argPath ) ;
45+ const path = await import ( "path" ) ,
46+ srcPath = path . join ( basePath , argPath ) ,
47+ fs = await import ( "fs-extra" ) ;
5248
5349 if ( ! ( await fs . pathExists ( srcPath ) ) ) {
5450 throw new Error ( "Provided path does not exist" ) ;
@@ -57,28 +53,40 @@ buildCommand.action(async (argPath: string) => {
5753 let canContinue = true ;
5854
5955 if ( canContinue && prettier ) {
56+ const { prettifySrc } = await import ( "./build-prettier.js" ) ;
57+
6058 canContinue = await prettifySrc ( basePath , srcPath , ci ) ;
6159 }
6260
6361 if ( canContinue && doLint ) {
62+ const { lint } = await import ( "./build-eslint.js" ) ;
63+
6464 canContinue = await lint ( ci ) ;
6565 }
6666
6767 if ( canContinue && tsc ) {
68+ const { buildTS } = await import ( "./build-tsc.js" ) ;
69+
6870 canContinue = await buildTS ( basePath ) ;
6971 }
7072
7173 if ( canContinue && doBundle ) {
74+ const { bundle } = await import ( "./build-bundle.js" ) ;
75+
7276 canContinue = await bundle ( basePath ) ;
7377 }
7478
7579 if ( canContinue && prettier ) {
80+ const { prettifyReadme, prettifyPackageJson, prettifyPackageDistJson } = await import ( "./build-prettier" ) ;
81+
7682 canContinue = await prettifyReadme ( basePath , ci ) ;
7783 canContinue = await prettifyPackageJson ( basePath , ci ) ;
7884 canContinue = await prettifyPackageDistJson ( basePath , ci ) ;
7985 }
8086
8187 if ( canContinue && distfiles ) {
88+ const { buildDistFiles } = await import ( "./build-distfiles.js" ) ;
89+
8290 canContinue = await buildDistFiles ( basePath ) ;
8391 }
8492
0 commit comments