Skip to content
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
92 changes: 43 additions & 49 deletions crates/utoo-wasm/src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,54 +68,6 @@ pub struct PackProject {
pub dev: bool,
}

impl PackProject {
pub async fn build(&self) -> Result<TurbopackResult> {
let start = Instant::now();
let turbo_tasks = self.turbo_tasks.clone();
let container = self.container;
let (entrypoints, issues, diags) = turbo_tasks
.run_once(async move {
let entrypoints_with_issues_op =
get_all_written_entrypoints_with_issues_operation(container);

let EntrypointsWithIssues {
entrypoints,
issues,
diagnostics,
effects,
} = &*entrypoints_with_issues_op
.read_strongly_consistent()
.await?;
effects.apply().await?;

Ok((entrypoints.clone(), issues.clone(), diagnostics.clone()))
})
.await?;

tracing::info!("all project entrypoints wrote to disk.");

tracing::info!(
"pack tasks with {} apps {} libraries finished in {:?}",
entrypoints
.apps
.as_ref()
.map(|apps| apps.0.len())
.unwrap_or_default(),
entrypoints
.libraries
.as_ref()
.map(|libraries| libraries.0.len())
.unwrap_or_default(),
start.elapsed()
);

Ok(TurbopackResult {
issues: issues.iter().map(|i| Issue::from(&**i)).collect(),
diagnostics: diags.iter().map(|d| Diagnostic::from(d)).collect(),
})
}
}

pub fn create_turbo_tasks() -> Result<BundlerTurboTasks> {
Ok(BundlerTurboTasks::Memory(TurboTasks::new(
turbo_tasks_backend::TurboTasksBackend::new(
Expand Down Expand Up @@ -376,7 +328,49 @@ pub async fn build() -> std::result::Result<JsValue, wasm_bindgen::JsError> {

runtime()
.spawn(async move {
let result = pack_project.build().await?;
let start = Instant::now();
let turbo_tasks = pack_project.turbo_tasks.clone();
let container = pack_project.container;
let (entrypoints, issues, diags) = turbo_tasks
.run_once(async move {
let entrypoints_with_issues_op =
get_all_written_entrypoints_with_issues_operation(container);

let EntrypointsWithIssues {
entrypoints,
issues,
diagnostics,
effects,
} = &*entrypoints_with_issues_op
.read_strongly_consistent()
.await?;
effects.apply().await?;

Ok((entrypoints.clone(), issues.clone(), diagnostics.clone()))
})
.await?;

tracing::info!("all project entrypoints wrote to disk.");

tracing::info!(
"pack tasks with {} apps {} libraries finished in {:?}",
entrypoints
.apps
.as_ref()
.map(|apps| apps.0.len())
.unwrap_or_default(),
entrypoints
.libraries
.as_ref()
.map(|libraries| libraries.0.len())
.unwrap_or_default(),
start.elapsed()
);

let result = TurbopackResult {
issues: issues.iter().map(|i| Issue::from(&**i)).collect(),
diagnostics: diags.iter().map(|d| Diagnostic::from(d)).collect(),
};
let json_str =
serde_json::to_string(&result).map_err(|e| anyhow::anyhow!(e.to_string()))?;
Ok::<String, anyhow::Error>(json_str)
Expand Down
34 changes: 17 additions & 17 deletions packages/utoo-web/src/utoo/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,6 @@ export function workerCreated(worker_id: number): void;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly __wbg_project_free: (a: number, b: number) => void;
readonly project_build: () => any;
readonly project_cwd: () => [number, number];
readonly project_deps: (a: number, b: number, c: number) => any;
readonly project_entrypointsSubscribe: (a: any) => any;
readonly project_gzip: (a: any) => any;
readonly project_hmrEvents: (a: number, b: number, c: any) => any;
readonly project_init: (a: number, b: number) => void;
readonly project_install: (a: number, b: number, c: number) => any;
readonly project_setCwd: (a: number, b: number) => void;
readonly project_sigMd5: (a: any) => any;
readonly project_updateInfoSubscribe: (a: number, b: any) => void;
readonly project_writeAllToDisk: (a: any) => void;
readonly getWasmMemory: () => any;
readonly getWasmModule: () => any;
readonly initLogFilter: (a: number, b: number) => void;
Expand Down Expand Up @@ -226,6 +213,19 @@ export interface InitOutput {
readonly fs_write: (a: number, b: number, c: any) => any;
readonly fs_writeString: (a: number, b: number, c: number, d: number) => any;
readonly fs_writeSync: (a: number, b: number, c: any) => [number, number];
readonly __wbg_project_free: (a: number, b: number) => void;
readonly project_build: () => any;
readonly project_cwd: () => [number, number];
readonly project_deps: (a: number, b: number, c: number) => any;
readonly project_entrypointsSubscribe: (a: any) => any;
readonly project_gzip: (a: any) => any;
readonly project_hmrEvents: (a: number, b: number, c: any) => any;
readonly project_init: (a: number, b: number) => void;
readonly project_install: (a: number, b: number, c: number) => any;
readonly project_setCwd: (a: number, b: number) => void;
readonly project_sigMd5: (a: any) => any;
readonly project_updateInfoSubscribe: (a: number, b: any) => void;
readonly project_writeAllToDisk: (a: any) => void;
readonly __wbg_roottask_free: (a: number, b: number) => void;
readonly registerWorkerScheduler: (a: any, b: any) => void;
readonly workerCreated: (a: number) => void;
Expand Down Expand Up @@ -253,18 +253,18 @@ export interface InitOutput {
readonly wasmtaskmessage_data: (a: number) => any;
readonly __wbg_createsyncaccesshandleoptions_free: (a: number, b: number) => void;
readonly wasm_thread_entry_point: (a: number) => void;
readonly wasm_bindgen__closure__destroy__hdc0c9a5abebea22a: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h63d5de465208a3de: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h00341c46fa27177b: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h391e6789779e56da: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h96856d441dbabdfc: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__hcd544267e9a8b41a: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h72493b8ecc7a2fa9: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h0c0bb14a934213b9: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__hb6c1c61344794a50: (a: number, b: number, c: any, d: any) => void;
readonly wasm_bindgen__convert__closures_____invoke__h1c90b71c761ed3b8: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__convert__closures_____invoke__hf447be52ec002243: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__convert__closures________invoke__h717385505976dc94: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__convert__closures_____invoke__h3d4d60f9cefb0572: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__convert__closures_____invoke__hcdaa890baa3d79c0: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__he45664fa0a7bdef9: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__convert__closures_____invoke__h8f9fd2338557149f: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h3fb07518adc4b25d: (a: number, b: number) => void;
readonly memory: WebAssembly.Memory;
readonly __wbindgen_malloc: (a: number, b: number) => number;
Expand Down
Loading