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
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
}
],
"optionalVariants": [
{
"runtime": "bun",
"build-command": "pnpm install",
"assert-command": "pnpm test:dev",
"label": "nextjs-16 (bun, turbopack, development)"
},
{
"runtime": "cloudflare",
"build-command": "pnpm test:build-latest:cloudflare",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const getStartCommand = () => {
}

if (testEnv === 'development') {
if (getRuntime() === 'bun') {
// Use the bin name, not its path: then Bun puts its `node` shim in PATH, which the Turbopack loader processes use.
return 'bun --bun next dev -p 3030 2>&1 | tee .tmp_dev_server_logs';
}

return 'pnpm next dev -p 3030 2>&1 | tee .tmp_dev_server_logs';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ const MISSING_INSTRUMENTATION_FILE_WARNING_SHOWN = '__SENTRY_MISSING_INSTRUMENTA
* With the default `'childProcesses'`, Next.js runs Turbopack loaders in `node` processes and puts `process.execArgv`
* into their `NODE_OPTIONS`. On Bun, `execArgv` contains `--bun`, which Node.js does not accept, so the build fails or
* hangs. `withSentryConfig` always adds loaders.
*
* `next dev` keeps the Next.js default. With worker threads, the loaders run in the dev server process, and Bun caches
* that `.next/dev` has no `node_modules` folder. The server then cannot load the externals that Turbopack links into
* `.next/dev/node_modules` later.
*/
export function maybeSetTurbopackPluginRuntimeStrategyOption(
incomingUserNextConfigObject: NextConfigObject,
nextJsVersion: string | undefined,
isTurbopack: boolean,
silent?: boolean,
): void {
if (!process.versions.bun || !isTurbopack || !nextJsVersion) {
if (!process.versions.bun || !isTurbopack || !nextJsVersion || process.env.NODE_ENV === 'development') {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('maybeSetTurbopackPluginRuntimeStrategyOption', () => {
afterEach(() => {
Object.defineProperty(process, 'versions', originalVersions);
vi.restoreAllMocks();
vi.unstubAllEnvs();
});

it.each(['16.2.0', '16.3.8', '17.0.0'])(
Expand Down Expand Up @@ -46,6 +47,23 @@ describe('maybeSetTurbopackPluginRuntimeStrategyOption', () => {
expect(warnSpy).not.toHaveBeenCalled();
});

it('keeps the Next.js default in `next dev` on Bun', () => {
Object.defineProperty(process, 'versions', { ...originalVersions, value: { ...process.versions, bun: '1.4.5' } });
vi.stubEnv('NODE_ENV', 'development');
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const defaultConfig: NextConfigObject = {};
const childProcessesConfig: NextConfigObject = {
experimental: { turbopackPluginRuntimeStrategy: 'childProcesses' },
};

maybeSetTurbopackPluginRuntimeStrategyOption(defaultConfig, '16.4.6', true);
maybeSetTurbopackPluginRuntimeStrategyOption(childProcessesConfig, '16.4.6', true);

expect(defaultConfig.experimental).toBeUndefined();
expect(childProcessesConfig.experimental).toEqual({ turbopackPluginRuntimeStrategy: 'childProcesses' });
expect(warnSpy).not.toHaveBeenCalled();
});

it('does not warn about `childProcesses` on Node.js', () => {
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const config: NextConfigObject = { experimental: { turbopackPluginRuntimeStrategy: 'childProcesses' } };
Expand Down
Loading