Skip to content

Conversation

@benStre
Copy link
Member

@benStre benStre commented Nov 10, 2025

Removes Deno shims/polyfills for simpler and more stable node build that should also work in browsers.
Currently, only the websocket client interface is supported, we need to add a websocket server interface in the future.

@benStre benStre requested a review from jonasstrehle November 10, 2025 00:06
@benStre benStre self-assigned this Nov 10, 2025
@benStre benStre added the enhancement New feature or request label Nov 10, 2025
@benStre benStre changed the base branch from main to release/0.0.9 November 10, 2025 00:12
@benStre benStre force-pushed the feat/node-build-improvements branch from 6eecc5a to 78ff562 Compare November 10, 2025 00:14
Copilot AI review requested due to automatic review settings November 10, 2025 14:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Node.js runtime and implements WebAssembly instantiation across different JavaScript runtimes (Deno, Node.js, Bun, and Browser). The changes refactor the runtime detection mechanism and introduce a unified interface for runtime-specific operations.

  • Adds new NodeRuntimeInterface class to support Node.js environments
  • Introduces instantiateWebAssembly method to the runtime interface for consistent WASM loading across all runtimes
  • Updates runtime detection to use navigator.userAgent for identifying Deno, Node.js, Bun, and browser environments

Reviewed Changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/js-runtime-compat/runtimes/node.ts Introduces new NodeRuntimeInterface class (contains bugs - using Deno APIs instead of Node.js)
src/utils/js-runtime-compat/runtimes/deno.ts Adds instantiateWebAssembly method using WebAssembly.instantiateStreaming
src/utils/js-runtime-compat/runtimes/browser.ts Adds instantiateWebAssembly method using WebAssembly.instantiateStreaming
src/utils/js-runtime-compat/runtime.ts Updates runtime detection to use navigator.userAgent and adds Node.js runtime handler
src/utils/js-runtime-compat/js-runtime-interface.ts Extends interface with instantiateWebAssembly method and adds "node" and "bun" runtime types
src/datex-core/datex_core_js.js Refactors to use runtimeInterface.instantiateWebAssembly instead of inline runtime detection
scripts/build-wasm.ts Updates template to use runtimeInterface.instantiateWebAssembly
scripts/build-bundle.ts Updates regex pattern for WASM replacement (pattern is too broad)
scripts/build-npm.ts Removes dnt shims and unused entry points
src/datex-core/datex_core_js.d.ts Reorders type declarations (cosmetic changes)
deno.lock Adds @types/node dependency
Cargo.lock Updates various Rust dependency versions
Comments suppressed due to low confidence (1)

src/utils/js-runtime-compat/runtime.ts:44

  • The runtime detection logic checks for "bun" runtime, but getRuntimeInterface doesn't have a corresponding case to handle it. When Bun is detected, it will fall through to the browser runtime interface. Either add a Bun runtime implementation or remove "bun" from the JSRuntimeType and detection logic.
async function getRuntimeInterface(type: JSRuntimeType) {
    if (type === "deno") {
        const { DenoRuntimeInterface } = await import("./runtimes/deno.ts");
        return new DenoRuntimeInterface();
    } else if (type === "node") {
        const { NodeRuntimeInterface } = await import("./runtimes/node.ts");
        return new NodeRuntimeInterface();
    } else {
        const { BrowserRuntimeInterface } = await import(
            "./runtimes/browser.ts"
        );
        return new BrowserRuntimeInterface();
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benStre benStre requested a review from jonasstrehle November 10, 2025 14:46
@jonasstrehle jonasstrehle merged commit b9dde25 into release/0.0.9 Nov 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants