bytebox - v1.0.0
    Preparing search index...

    Function teavmStubs

    • Stubs the Node-only imports inside TeaVM's generated runtime.

      The runtime reads a module off disk with import('node:fs/promises') on a branch bytebox never takes, since it drives defaults and never the generated load. esbuild resolves a dynamic import's literal specifier whether the branch can run or not, so a Workers target with no Node builtins fails the whole bundle on unreachable code.

      Only imports made by the runtime itself are stubbed, so a project that does use nodejs_compat keeps its own Node imports.

      Returns Plugin

      import { teavmStubs } from 'bytebox/bundler';
      import { build } from 'esbuild';

      await build({
      entryPoints: ['src/index.ts'],
      outfile: 'dist/index.mjs',
      bundle: true,
      format: 'esm',
      external: ['*.wasm'],
      plugins: [teavmStubs()]
      });