diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 80811338d7d..f282be5f3db 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,39 +93,39 @@ jobs: - name: Run Test run: just test-rust - # node-test: - # name: Node Test - # runs-on: buildjet-2vcpu-ubuntu-2204 - # timeout-minutes: 30 - # strategy: - # fail-fast: false - # matrix: - # os: - # - ubuntu-latest - # # - windows-latest - # # - macos-latest - # steps: - # - uses: actions/checkout@v4 - # with: - # submodules: true # Pull submodules for additional files - - # - name: Install Rust - # uses: moonrepo/setup-rust@v1 - # with: - # bins: just - # cache-base: main - - # - name: Install node - # uses: actions/setup-node@v4 - # with: - # node-version: 20 - # cache: yarn - - # - name: Install dependencies - # run: yarn install - - # - name: Test - # run: just test-node + node-test: + name: Node Test + runs-on: buildjet-2vcpu-ubuntu-2204 + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + # - windows-latest + # - macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true # Pull submodules for additional files + + - name: Install Rust + uses: moonrepo/setup-rust@v1 + with: + bins: just + cache-base: main + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + + - name: Install dependencies + run: yarn install + + - name: Test + run: just test-node node-format: name: Node Format diff --git a/crates/rolldown/src/bundler.rs b/crates/rolldown/src/bundler.rs index f83c0d478a2..fadc895a52f 100644 --- a/crates/rolldown/src/bundler.rs +++ b/crates/rolldown/src/bundler.rs @@ -102,13 +102,18 @@ impl Bundler { let ret = self.scan_inner().await; - self.call_build_end_hook(ret.err()).await?; + self.call_build_end_hook(&ret).await?; + + ret?; Ok(()) } - async fn call_build_end_hook(&mut self, ret: Option) -> BatchedResult<()> { - if let Some(e) = ret { + async fn call_build_end_hook( + &mut self, + ret: &Result, + ) -> BatchedResult<()> { + if let Err(e) = ret { let error = e.get().expect("should have a error"); self .plugin_driver @@ -117,12 +122,12 @@ impl Bundler { error: error.to_string(), })) .await?; - return Err(e); - } + Ok(()) + } else { + self.plugin_driver.build_end(None).await?; - self.plugin_driver.build_end(None).await?; - - Ok(()) + Ok(()) + } } async fn scan_inner(&mut self) -> BatchedResult { @@ -138,10 +143,15 @@ impl Bundler { #[tracing::instrument(skip_all)] async fn try_build(&mut self) -> BatchedResult { - let build_info = self.scan_inner().await?; + self.plugin_driver.build_start().await?; - let link_stage = LinkStage::new(build_info, &self.input_options); + let scan_ret = self.scan_inner().await; + + self.call_build_end_hook(&scan_ret).await?; + let build_info = scan_ret?; + + let link_stage = LinkStage::new(build_info, &self.input_options); Ok(link_stage.link()) } diff --git a/crates/rolldown_binding/index.d.ts b/crates/rolldown_binding/index.d.ts index 61a1e7f6939..865a71fcd43 100644 --- a/crates/rolldown_binding/index.d.ts +++ b/crates/rolldown_binding/index.d.ts @@ -19,11 +19,13 @@ export interface ResolveOptions { symlinks?: boolean } export interface InputOptions { - external?: ( - source: string, - importer?: string, - isResolved?: boolean, - ) => boolean + external?: + | undefined + | (( + source: string, + importer: string | undefined, + isResolved: boolean, + ) => boolean) input: Array plugins: Array resolve?: ResolveOptions diff --git a/crates/rolldown_binding/index.js b/crates/rolldown_binding/index.js index e03e2ef3911..54a8c48e1f3 100644 --- a/crates/rolldown_binding/index.js +++ b/crates/rolldown_binding/index.js @@ -248,6 +248,49 @@ switch (platform) { loadError = e } break + case 'riscv64': + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'rolldown.linux-riscv64-musl.node'), + ) + try { + if (localFileExisted) { + nativeBinding = require('./rolldown.linux-riscv64-musl.node') + } else { + nativeBinding = require('@rolldown/node-binding-linux-riscv64-musl') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'rolldown.linux-riscv64-gnu.node'), + ) + try { + if (localFileExisted) { + nativeBinding = require('./rolldown.linux-riscv64-gnu.node') + } else { + nativeBinding = require('@rolldown/node-binding-linux-riscv64-gnu') + } + } catch (e) { + loadError = e + } + } + break + case 's390x': + localFileExisted = existsSync( + join(__dirname, 'rolldown.linux-s390x-gnu.node'), + ) + try { + if (localFileExisted) { + nativeBinding = require('./rolldown.linux-s390x-gnu.node') + } else { + nativeBinding = require('@rolldown/node-binding-linux-s390x-gnu') + } + } catch (e) { + loadError = e + } + break default: throw new Error(`Unsupported architecture on Linux: ${arch}`) } diff --git a/crates/rolldown_binding/src/options/input_options/mod.rs b/crates/rolldown_binding/src/options/input_options/mod.rs index 0fb8997f8aa..6fd1572b34a 100644 --- a/crates/rolldown_binding/src/options/input_options/mod.rs +++ b/crates/rolldown_binding/src/options/input_options/mod.rs @@ -75,7 +75,9 @@ pub struct InputOptions { // experimentalCacheExpiry?: number; #[derivative(Debug = "ignore")] #[serde(skip_deserializing)] - #[napi(ts_type = "(source: string, importer?: string, isResolved?: boolean) => boolean")] + #[napi( + ts_type = "undefined | ((source: string, importer: string | undefined, isResolved: boolean) => boolean)" + )] pub external: Option, pub input: Vec, // makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource'; diff --git a/justfile b/justfile index c67cef3c140..62bf7a29c62 100644 --- a/justfile +++ b/justfile @@ -47,7 +47,7 @@ test-rust: cargo test --no-fail-fast test-node: - yarn build --no-wasm + yarn build:node yarn test test: @@ -89,6 +89,15 @@ smoke-rust: just check-rust just lint-rust +smoke-node: + just test-node + just check-node + just lint-node + +smoke: + just smoke-rust + just smoke-node + # BENCHING