From 763d027dbb69df91aa1de2c11e94f6d7617b81c5 Mon Sep 17 00:00:00 2001 From: Noah Klayman Date: Thu, 11 Feb 2021 13:41:03 -0800 Subject: [PATCH] fix(tauri/examples): fix build errors (#1218) --- tauri/examples/api/public/index.html | 2 +- tauri/examples/api/rollup.config.js | 32 +++++++++++++----------- tauri/examples/api/src-tauri/Cargo.lock | 10 ++++---- tauri/examples/api/src-tauri/src/main.rs | 2 +- tauri/examples/api/src/App.svelte | 4 +-- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/tauri/examples/api/public/index.html b/tauri/examples/api/public/index.html index 0497e2596..0f9945386 100644 --- a/tauri/examples/api/public/index.html +++ b/tauri/examples/api/public/index.html @@ -9,7 +9,7 @@ - + diff --git a/tauri/examples/api/rollup.config.js b/tauri/examples/api/rollup.config.js index ce3c9ebab..05434087b 100644 --- a/tauri/examples/api/rollup.config.js +++ b/tauri/examples/api/rollup.config.js @@ -16,13 +16,11 @@ export default { }, plugins: [ svelte({ - // enable run-time checks when not in production - dev: !production, - // we'll extract any component CSS out into - // a separate file - better for performance - css: css => { - css.write('public/build/bundle.css'); - } + compilerOptions: { + // enable run-time checks when not in production + dev: !production + }, + emitCss: false }), // If you have external dependencies installed from @@ -54,18 +52,22 @@ export default { }; function serve() { - let started = false; + let server; + + function toExit() { + if (server) server.kill(0); + } return { writeBundle() { - if (!started) { - started = true; + if (server) return; + server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { + stdio: ['ignore', 'inherit', 'inherit'], + shell: true + }); - require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { - stdio: ['ignore', 'inherit', 'inherit'], - shell: true - }); - } + process.on('SIGTERM', toExit); + process.on('exit', toExit); } }; } diff --git a/tauri/examples/api/src-tauri/Cargo.lock b/tauri/examples/api/src-tauri/Cargo.lock index 8bb6e2be2..4170460e7 100644 --- a/tauri/examples/api/src-tauri/Cargo.lock +++ b/tauri/examples/api/src-tauri/Cargo.lock @@ -2374,7 +2374,6 @@ dependencies = [ name = "tauri" version = "0.11.1" dependencies = [ - "anyhow", "async-trait", "base64", "cfg_aliases", @@ -2398,7 +2397,6 @@ dependencies = [ name = "tauri-api" version = "0.7.5" dependencies = [ - "anyhow", "attohttpc", "clap", "dirs-next", @@ -2408,7 +2406,6 @@ dependencies = [ "nfd", "notify-rust", "once_cell", - "phf", "rand 0.8.3", "semver", "serde", @@ -2451,7 +2448,7 @@ dependencies = [ "serde", "serde_json", "syn 1.0.60", - "tauri-api", + "tauri-utils", "walkdir", ] @@ -2459,7 +2456,10 @@ dependencies = [ name = "tauri-utils" version = "0.5.1" dependencies = [ - "anyhow", + "flate2", + "phf", + "serde", + "serde_json", "sysinfo", "thiserror", ] diff --git a/tauri/examples/api/src-tauri/src/main.rs b/tauri/examples/api/src-tauri/src/main.rs index 451aa1225..2c4aa046a 100644 --- a/tauri/examples/api/src-tauri/src/main.rs +++ b/tauri/examples/api/src-tauri/src/main.rs @@ -47,7 +47,7 @@ fn main() { // tauri::execute_promise is a helper for APIs that uses the tauri.promisified JS function // so you can easily communicate between JS and Rust with promises tauri::execute_promise( - &mut webview, + &mut dispatcher, async move { println!("{} {:?}", endpoint, body); // perform an async operation here diff --git a/tauri/examples/api/src/App.svelte b/tauri/examples/api/src/App.svelte index dcc473596..445cb8d6a 100644 --- a/tauri/examples/api/src/App.svelte +++ b/tauri/examples/api/src/App.svelte @@ -59,8 +59,8 @@
{#each views as view}
- - + +