Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Incorrect sourceMappingURL path #146

Description

@jarrodpayne
  • Operating System: macOS 11.2.3
  • Node Version: 14.16.0
  • NPM Version: 6.14.11
  • yarn version: 1.22.10
  • webpack Version: 5.31.0
  • source-map-loader Version: 2.0.1

Expected Behavior

Breakpoint should be bound in vscode debugger without sourceMapPathOverrides hacks.

Actual Behavior

Breakpoint is not bound.

Code

// apps/app/next.config.js
module.exports = {
  future: {
    webpack5: true,
  },
  webpack: (config) => {
    config.module.rules.push({
      test: /\.js$/,
      enforce: "pre",
      use: ["source-map-loader"],
    });
    config.ignoreWarnings = [/Failed to parse source map/];

    return config;
  },
};
// .vscode/launch.json
{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "pwa-chrome",
      "request": "launch",
      "name": "Launch Chrome",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}/apps/app",
      "trace": true,
      "sourceMapPathOverrides": {
        // This seems fine, perhaps necessary
        "webpack://_N_E/*": "${webRoot}/*",
        // This is addressing a bug where sourceMappingURL only
        // has has `../` instead of `../../`
        "webpack://_N_E/../libs/*": "${webRoot}/../../libs/*"
      }
    }
  ]
}

How Do We Reproduce?

Clone and install

Start the app

  • Run yarn dev from the root

Debug the app in vscode

  • Run the Launch Chrome debug configuration in vscode
    image
  • Set a breakpoint on line 4 of libs/ui/src/Box.tsx
    import React from "react";
    
    export const Box: React.FC = (props) => {
      return <div className="box">{props.children}</div>;
    }
  • This breakpoint will only be hit with the launch.json hack where I map a single ../ to what it should be, ../../. Comment out line 16 or launch.json and restart the debugger to reproduce the problem.
    { "webpack://_N_E/../libs/*": "${webRoot}/../../libs/*" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions