From eee77a6f3cd5b6b3014a40cb46de78e2369512cd Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Tue, 29 Oct 2024 18:05:59 -0600 Subject: [PATCH] progressively write files to the staging area --- .../experimental/commands/compile/index.ts | 16 ++++++------- src/build/stable/commands/compile/index.ts | 24 ++++--------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/build/experimental/commands/compile/index.ts b/src/build/experimental/commands/compile/index.ts index f7623e8441..325d1f7830 100644 --- a/src/build/experimental/commands/compile/index.ts +++ b/src/build/experimental/commands/compile/index.ts @@ -1,7 +1,8 @@ import { IOType } from 'child_process'; import { rm } from 'fs/promises'; +import { outputFile } from 'fs-extra'; +import { join } from 'path'; -import { writeGeneratedFiles } from '../../../stable/commands/compile'; import { execSyncPretty } from '../../../stable/utils/exec_sync_pretty'; import { CanisterConfig } from '../../../stable/utils/types'; import { logSuccess } from '../../utils/log_success'; @@ -32,6 +33,8 @@ export async function runCommand( const javaScript = await compileJavaScript(main, esmAliases, esmExternals); + await outputFile(join(canisterPath, 'main.js'), javaScript); + const { candid, methodMeta } = await getCandidAndMethodMeta( canisterConfig.custom?.candid_gen, candidPath, @@ -40,6 +43,8 @@ export async function runCommand( wasmData ); + await outputFile(candidPath, candid); + const wasmBinary = await getWasmBinary( ioType, javaScript, @@ -47,14 +52,7 @@ export async function runCommand( methodMeta ); - await writeGeneratedFiles( - canisterPath, - candidPath, - wasmBinaryPath, - candid, - javaScript, - wasmBinary - ); + await outputFile(wasmBinaryPath, wasmBinary); buildAssets(canisterConfig, ioType); diff --git a/src/build/stable/commands/compile/index.ts b/src/build/stable/commands/compile/index.ts index 8f7a8e706c..4087d74a9a 100644 --- a/src/build/stable/commands/compile/index.ts +++ b/src/build/stable/commands/compile/index.ts @@ -21,6 +21,8 @@ export async function runCommand( const javaScript = await compileJavaScript(main); + await outputFile(join(canisterPath, 'main.js'), javaScript); + const { candid, methodMeta } = await getCandidAndMethodMeta( canisterConfig.custom?.candid_gen, candidPath, @@ -29,6 +31,8 @@ export async function runCommand( wasmData ); + await outputFile(candidPath, candid); + const wasmBinary = await getWasmBinary( ioType, javaScript, @@ -36,25 +40,5 @@ export async function runCommand( methodMeta ); - await writeGeneratedFiles( - canisterPath, - candidPath, - wasmBinaryPath, - candid, - javaScript, - wasmBinary - ); -} - -export async function writeGeneratedFiles( - canisterPath: string, - candidPath: string, - wasmBinaryPath: string, - candid: string, - javaScript: string, - wasmBinary: Uint8Array -): Promise { - await outputFile(candidPath, candid); - await outputFile(join(canisterPath, 'main.js'), javaScript); await outputFile(wasmBinaryPath, wasmBinary); }