Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile.bun
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ RUN bun -e "import { Database } from 'bun:sqlite'; const db = new Database(':mem

COPY . .

# Disable Turbopack for Bun builder stage (Turbopack V8 internal worker bindings require Node)
ENV OMNIROUTE_USE_TURBOPACK=0
# Turbopack is supported on Bun 1.4 + Next 16.3; override via --build-arg OMNIROUTE_USE_TURBOPACK=0 if needed
ARG OMNIROUTE_USE_TURBOPACK=1
ENV OMNIROUTE_USE_TURBOPACK=${OMNIROUTE_USE_TURBOPACK}

ARG OMNIROUTE_BASE_PATH=""
ENV OMNIROUTE_BASE_PATH=$OMNIROUTE_BASE_PATH
Expand Down
1 change: 1 addition & 0 deletions changelog.d/features/11471-bun-turbopack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **build(bun):** allow Turbopack bundler flag on Bun 1.4+ with configurable Webpack fallback ([#11471](https://github.com/diegosouzapw/OmniRoute/pull/11471)) — thanks @TheDemonTuan
6 changes: 3 additions & 3 deletions scripts/build/build-next-isolated.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ function runNextBuild() {
}

export function resolveNextBuildBundlerFlag(baseEnv = process.env) {
// Turbopack is the default on Node.js; on Bun or when explicitly disabled (=0),
// use Webpack (--webpack) to avoid Turbopack V8 internal worker API mismatches.
if (process.versions.bun || baseEnv.OMNIROUTE_USE_TURBOPACK === "0") {
// Turbopack is the default (on Node.js and Bun 1.4+).
// When explicitly disabled (OMNIROUTE_USE_TURBOPACK=0), use Webpack (--webpack) as fallback.
if (baseEnv.OMNIROUTE_USE_TURBOPACK === "0") {
return "--webpack";
}
return "--turbopack";
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/build/resolve-next-build-bundler-flag.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test } from "node:test";
import assert from "node:assert/strict";

import { resolveNextBuildBundlerFlag } from "../../../scripts/build/build-next-isolated.mjs";

test("resolveNextBuildBundlerFlag returns --turbopack by default", () => {
const flag = resolveNextBuildBundlerFlag({});
assert.equal(flag, "--turbopack");
});

test("resolveNextBuildBundlerFlag returns --webpack when OMNIROUTE_USE_TURBOPACK is '0'", () => {
const flag = resolveNextBuildBundlerFlag({ OMNIROUTE_USE_TURBOPACK: "0" });
assert.equal(flag, "--webpack");
});

test("resolveNextBuildBundlerFlag returns --turbopack when OMNIROUTE_USE_TURBOPACK is '1'", () => {
const flag = resolveNextBuildBundlerFlag({ OMNIROUTE_USE_TURBOPACK: "1" });
assert.equal(flag, "--turbopack");
});
Loading