From 09c7df3c5ce612736011079ddaffa5701522d811 Mon Sep 17 00:00:00 2001 From: forehalo Date: Sat, 18 Dec 2021 14:12:46 +0800 Subject: [PATCH] fix: keep .d.ts and .js untouched if native doesn't change --- cli/src/build.ts | 7 ++++++- crates/build/src/lib.rs | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index 869dc5f6..55c7b670 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -354,6 +354,11 @@ async function processIntermediateTypeFile( .split('\n') .map((line) => line.trim()) .filter(Boolean) + + if (!lines.length) { + return idents + } + const dtsHeader = `/* eslint-disable */ export class ExternalObject { @@ -466,7 +471,7 @@ async function writeJsBinding( distFileName: string | null, idents: string[], ) { - if (distFileName) { + if (distFileName && idents.length) { const template = createJsBinding(localName, packageName) const declareCodes = `const { ${idents.join(', ')} } = nativeBinding\n` const exportsCode = idents.reduce( diff --git a/crates/build/src/lib.rs b/crates/build/src/lib.rs index 510db5c7..465a4810 100644 --- a/crates/build/src/lib.rs +++ b/crates/build/src/lib.rs @@ -2,7 +2,6 @@ mod macos; mod windows; pub fn setup() { - println!("cargo:rerun-if-env-changed=TYPE_DEF_TMP_PATH"); println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE"); match std::env::var("CARGO_CFG_TARGET_OS").as_deref() { Ok("macos") => macos::setup(),