nextjs - 💡(How to fix) Fix Next16 turbopack rules cannot match .next/static/trunks js [3 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86328Fetched 2026-04-08 02:11:29
View on GitHub
Comments
3
Participants
4
Timeline
8
Reactions
0
Timeline (top)
commented ×3labeled ×2closed ×1issue_type_added ×1

Code Example

module.exports = function bannerLoader(content) {
  const banner = `/*! 
 * Application: My App
 * Build Date: ${new Date().toISOString()}
 * Environment: ${process.env.NODE_ENV}
 */\n\n`;

  return banner + content;
};

---

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  reactStrictMode: false,
  turbopack: {
    rules: {
      // 或者只应用到特定路径
      "**/*.js": [
        {
          loader: "./banner-loader.js",
        },
      ],
    },
  },
};

export default nextConfig;

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0
Binaries:
  Node: 22.17.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.10.0
Relevant Packages:
  next: 16.0.0
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.6.2
Next.js Config:
  output: N/A

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  reactStrictMode: false,
  turbopack: {
    rules: {
      // 或者只应用到特定路径
      "**/*.js": [
        {
          loader: "./banner-loader.js",
        },
      ],
    },
  },
};

export default nextConfig;
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/Uni-Commerce/uni-storefront-google-next-capture

To Reproduce

// turbopack-banner-loader.js

module.exports = function bannerLoader(content) {
  const banner = `/*! 
 * Application: My App
 * Build Date: ${new Date().toISOString()}
 * Environment: ${process.env.NODE_ENV}
 */\n\n`;

  return banner + content;
};
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  reactStrictMode: false,
  turbopack: {
    rules: {
      // 或者只应用到特定路径
      "**/*.js": [
        {
          loader: "./banner-loader.js",
        },
      ],
    },
  },
};

export default nextConfig;

Current vs. Expected behavior

<img width="457" height="178" alt="Image" src="https://github.com/user-attachments/assets/f6d24e75-0a7b-4ebc-9f6a-483567b172e4" />

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0
Binaries:
  Node: 22.17.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.10.0
Relevant Packages:
  next: 16.0.0
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.6.2
Next.js Config:
  output: N/A

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
  reactStrictMode: false,
  turbopack: {
    rules: {
      // 或者只应用到特定路径
      "**/*.js": [
        {
          loader: "./banner-loader.js",
        },
      ],
    },
  },
};

export default nextConfig;

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

extent analysis

TL;DR

  • The issue with Turbopack in Next.js might be resolved by adjusting the loader configuration or the banner loader script to handle JavaScript files correctly.

Guidance

  • Verify that the banner-loader.js script is correctly handling the JavaScript files by checking the file paths and the content being processed.
  • Ensure that the turbopack configuration in nextConfig is correctly set up to apply the loader to the desired JavaScript files.
  • Check the Node and Next.js versions for any known issues related to Turbopack and loader configurations.
  • Test the build process with a minimal configuration to isolate the issue.

Example

  • No specific code example can be provided without more context, but reviewing the bannerLoader function in turbopack-banner-loader.js for any potential issues with string concatenation or environment variable access might be helpful.

Notes

  • The provided information does not specify the exact error or behavior, making it challenging to provide a precise solution.
  • The issue might be related to the specific versions of Node, Next.js, or other dependencies, so checking the documentation for those versions could provide more insight.

Recommendation

  • Apply workaround: Adjust the turbopack configuration and the banner-loader.js script to ensure they are compatible with the current Next.js and Node versions, as the exact fix is unclear without more specific error information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Next16 turbopack rules cannot match .next/static/trunks js [3 comments, 4 participants]