From 3ac00fe454cd94d568f3f674198cf3e52f5057f0 Mon Sep 17 00:00:00 2001 From: Lars Hagen Date: Fri, 12 Sep 2025 18:06:22 +0200 Subject: [PATCH] fix(turbopack): restrict pattern to app directory to prevent middleware crashes --- demos/turbopack-next15/package.json | 28 ++++++++++++------------ demos/turbopack-next15/src/middleware.ts | 15 +++++++++++++ packages/turbopack/src/index.ts | 2 +- 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 demos/turbopack-next15/src/middleware.ts diff --git a/demos/turbopack-next15/package.json b/demos/turbopack-next15/package.json index bb2e0ee..3a3b75b 100644 --- a/demos/turbopack-next15/package.json +++ b/demos/turbopack-next15/package.json @@ -9,22 +9,22 @@ "lint": "next lint" }, "dependencies": { - "react": "19.1.0", - "react-dom": "19.1.0", - "next": "15.4.4" + "next": "15.5.3", + "react": "19.1.1", + "react-dom": "19.1.1" }, "devDependencies": { - "typescript": "^5", - "@types/node": "^20", - "@types/react": "^19", - "@types/react-dom": "^19", - "@tailwindcss/postcss": "^4", - "tailwindcss": "^4", - "eslint": "^9", - "eslint-config-next": "15.4.4", - "@eslint/eslintrc": "^3", + "@eslint/eslintrc": "^3.3.1", + "@mdx-js/loader": "^3.1.1", + "@next/mdx": "15.5.3", + "@tailwindcss/postcss": "^4.1.13", + "@types/node": "^24.3.1", + "@types/react": "^19.1.12", + "@types/react-dom": "^19.1.9", "code-inspector-plugin": "workspace:^", - "@next/mdx": "15.4.4", - "@mdx-js/loader": "^3.1.0" + "eslint": "^9.35.0", + "eslint-config-next": "15.5.3", + "tailwindcss": "^4.1.13", + "typescript": "^5.9.2" } } diff --git a/demos/turbopack-next15/src/middleware.ts b/demos/turbopack-next15/src/middleware.ts new file mode 100644 index 0000000..916561c --- /dev/null +++ b/demos/turbopack-next15/src/middleware.ts @@ -0,0 +1,15 @@ +// Middleware file to verify turbopack compatibility +// +// ⚠️ This file should be REMOVED once Turbopack fixes the middleware issue ⚠️ +// +// With the improved pattern '**/app/**/*.{jsx,tsx,js,ts,mjs,mts}' in the turbopack plugin, +// code-inspector only processes files in app directories, naturally excluding middleware files. +// This prevents the Turbopack crash issue by default. +// +// This is still a workaround. Track the issues for removal: +// - https://github.com/vercel/next.js/issues/79592 +// - https://github.com/zh-lx/code-inspector/issues/357 + +export function middleware() { + // Empty middleware - its presence is enough to test the workaround +} \ No newline at end of file diff --git a/packages/turbopack/src/index.ts b/packages/turbopack/src/index.ts index ee38809..201088f 100644 --- a/packages/turbopack/src/index.ts +++ b/packages/turbopack/src/index.ts @@ -36,7 +36,7 @@ export function TurbopackCodeInspectorPlugin( const WebpackDistDir = path.resolve(WebpackEntry, '..'); return { - '**/*.{jsx,tsx,js,ts,mjs,mts}': { + '**/app/**/*.{jsx,tsx,js,ts,mjs,mts}': { loaders: [ { loader: `${WebpackDistDir}/loader.js`,