From 6bfd4e6af34360b621f073804f7c6cc3884a3ec4 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 29 Jul 2020 17:53:55 -0700 Subject: [PATCH] [build] rewrite source as transpiled JS later in the process (#73749) Co-authored-by: spalger --- .../kbn-optimizer/src/worker/run_compilers.ts | 15 ++++++++++----- .../kbn-optimizer/src/worker/webpack_helpers.ts | 1 + src/dev/build/build_distributables.ts | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/kbn-optimizer/src/worker/run_compilers.ts b/packages/kbn-optimizer/src/worker/run_compilers.ts index c7be943d65a48..d78eb8214f607 100644 --- a/packages/kbn-optimizer/src/worker/run_compilers.ts +++ b/packages/kbn-optimizer/src/worker/run_compilers.ts @@ -110,7 +110,7 @@ const observeCompiler = ( const bundleRefExportIds: string[] = []; const referencedFiles = new Set(); - let normalModuleCount = 0; + let moduleCount = 0; let workUnits = stats.compilation.fileDependencies.size; if (bundle.manifestPath) { @@ -119,7 +119,7 @@ const observeCompiler = ( for (const module of stats.compilation.modules) { if (isNormalModule(module)) { - normalModuleCount += 1; + moduleCount += 1; const path = getModulePath(module); const parsedPath = parseFilePath(path); @@ -154,7 +154,12 @@ const observeCompiler = ( continue; } - if (isExternalModule(module) || isIgnoredModule(module) || isConcatenatedModule(module)) { + if (isConcatenatedModule(module)) { + moduleCount += module.modules.length; + continue; + } + + if (isExternalModule(module) || isIgnoredModule(module)) { continue; } @@ -180,13 +185,13 @@ const observeCompiler = ( bundleRefExportIds, optimizerCacheKey: workerConfig.optimizerCacheKey, cacheKey: bundle.createCacheKey(files, mtimes), - moduleCount: normalModuleCount, + moduleCount, workUnits, files, }); return compilerMsgs.compilerSuccess({ - moduleCount: normalModuleCount, + moduleCount, }); }) ); diff --git a/packages/kbn-optimizer/src/worker/webpack_helpers.ts b/packages/kbn-optimizer/src/worker/webpack_helpers.ts index e30920b960144..a1f97c4314774 100644 --- a/packages/kbn-optimizer/src/worker/webpack_helpers.ts +++ b/packages/kbn-optimizer/src/worker/webpack_helpers.ts @@ -155,6 +155,7 @@ export interface WebpackConcatenatedModule { id: number; dependencies: Dependency[]; usedExports: string[]; + modules: unknown[]; } export function isConcatenatedModule(module: any): module is WebpackConcatenatedModule { diff --git a/src/dev/build/build_distributables.ts b/src/dev/build/build_distributables.ts index bfcc98d6cd9a8..1d41f4c270caa 100644 --- a/src/dev/build/build_distributables.ts +++ b/src/dev/build/build_distributables.ts @@ -63,17 +63,17 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions await run(Tasks.CopyBinScripts); await run(Tasks.CreateEmptyDirsAndFiles); await run(Tasks.CreateReadme); - await run(Tasks.TranspileBabel); await run(Tasks.BuildPackages); await run(Tasks.CreatePackageJson); await run(Tasks.InstallDependencies); + await run(Tasks.BuildKibanaPlatformPlugins); + await run(Tasks.TranspileBabel); await run(Tasks.RemoveWorkspaces); await run(Tasks.CleanPackages); await run(Tasks.CreateNoticeFile); await run(Tasks.UpdateLicenseFile); await run(Tasks.RemovePackageJsonDeps); await run(Tasks.TranspileScss); - await run(Tasks.BuildKibanaPlatformPlugins); await run(Tasks.OptimizeBuild); await run(Tasks.CleanTypescript); await run(Tasks.CleanExtraFilesFromModules);