Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progressive writing #2252

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/build/experimental/commands/compile/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -40,21 +43,16 @@ export async function runCommand(
wasmData
);

await outputFile(candidPath, candid);

const wasmBinary = await getWasmBinary(
ioType,
javaScript,
wasmData,
methodMeta
);

await writeGeneratedFiles(
canisterPath,
candidPath,
wasmBinaryPath,
candid,
javaScript,
wasmBinary
);
await outputFile(wasmBinaryPath, wasmBinary);

buildAssets(canisterConfig, ioType);

Expand Down
24 changes: 4 additions & 20 deletions src/build/stable/commands/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,32 +31,14 @@ export async function runCommand(
wasmData
);

await outputFile(candidPath, candid);

const wasmBinary = await getWasmBinary(
ioType,
javaScript,
wasmData,
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<void> {
await outputFile(candidPath, candid);
await outputFile(join(canisterPath, 'main.js'), javaScript);
await outputFile(wasmBinaryPath, wasmBinary);
}
Loading