mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
build(bun): allow Turbopack bundler flag on Bun 1.4+ with configurable Webpack fallback (#11471)
Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (last of the Bun-native cluster; conflicted against the already-merged #11482's Dockerfile.bun hunk in the shared worktree — resolved by taking this PR's configurable ARG/ENV shape, which is exactly what it's designed to replace, and pushed the same resolution to this branch). - Focused test: resolve-next-build-bundler-flag.test.mjs — 3/3 pass, part of batch's 5/5 node:test run - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for validating with both node --test and bun test — good practice given the dual-runtime surface this touches.
This commit is contained in:
@@ -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
|
||||
|
||||
1
changelog.d/features/11471-bun-turbopack.md
Normal file
1
changelog.d/features/11471-bun-turbopack.md
Normal file
@@ -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
|
||||
@@ -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";
|
||||
|
||||
19
tests/unit/build/resolve-next-build-bundler-flag.test.mjs
Normal file
19
tests/unit/build/resolve-next-build-bundler-flag.test.mjs
Normal file
@@ -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");
|
||||
});
|
||||
Reference in New Issue
Block a user