Skip to content

Sourcemaps are inaccurate #80720

Open
Open
@GuyB-Hud

Description

@GuyB-Hud

Link to the code that reproduces this issue

https://github.com/vercel/next-app-router-playground

To Reproduce

  1. Install the latest canary version in https://github.com/vercel/next-app-router-playground project.
  2. Edit next.config.ts to include sourcemaps using webpack:
  pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
  experimental: {
    inlineCss: true,
    dynamicIO: true,
    clientSegmentCache: true,
    viewTransition: true,
    prerenderEarlyExit: false,
    routerBFCache: true,
  },
  webpack: (config) => {
    config.devtool = 'source-map';
    return config;
  },
} satisfies NextConfig;
  1. Run pnpm build
  2. In .next/server/app/context you will find page.js and page.js.map
  3. Use some kind of sourcemap resolver, I used https://evanw.github.io/source-map-visualization/
  4. On line 2, column 14664 you will see the parameter named a which should be resolved to product, but it doesn't resolve to a name (it almost points to the correct location in the sourcemap, but it doesn't have a name).
Image

Current vs. Expected behavior

Most of the sourcemaps are correct, but in some cases looks like they are off a little and aren't resolving to the actual value.
In this case, the parameter should be resolved to product but it doesn't resolve to anything.
There are more cases on multiple projects I have tested on, and more scenarios other than parameters (functions, objects, etc). If it's needed I can provide more examples.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 18.20.2
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 10.11.0
Relevant Packages:
  next: 15.4.0-canary.86 // Latest available version is detected (15.4.0-canary.86).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

TypeScript

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

next build (local)

Additional context

I tried also on version 14.0.0 and still had inaccurate sourcemaps, so it's not only the latest canary version

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeScriptRelated to types with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions