Skip to content

Next.js 16 App Router source maps integration fails #144

@rybon

Description

@rybon

The CLI assumes the following convention:
some-file-xyz.js matches some-file-xyz.js.map

As of Next.js 16, using Turbopack builds, this convention no longer holds. JS files and source map files won't always have the same file name and in certain cases there's a many-to-one relationship between a JS file and its corresponding source map file.

See: vercel/next.js#85471

When running:

splunk-rum sourcemaps inject --path ./.next
splunk-rum sourcemaps upload --realm $SPLUNK_REALM --token $SPLUNK_ACCESS_TOKEN --app-name $APP_NAME --app-version $APP_VERSION --path ./.next

The CLI fails to find JS files to process.

Workaround to restore the old behavior, which is matching JS and source map file names, is to revert back to Webpack instead of Turbopack for builds: "build": "next build --webpack"

Now, the CLI will find JS files to process.

But, to fix this issue properly, the CLI needs to stop relying on matching file name conventions and instead scan JS files in the directory passed in via --path and look for //# sourceMappingURL=some-file-xyz.js.map directives. Then, it needs to build up a mapping between source map files and one-or-many JS files to know which JS files require which window.sourceMapIds[s] = 'abc-123'; injections. This means multiple JS files may require the same injection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions