Chrome does no apply mappings from SourceMap to console output

Viewed 13

I have a project set up using webpack that includes an inline sourcemap (including sources) in the generated bundle during development. The bundle runs as a plugin to an electron app (Electron 18.0.4, Chrome 98.0.4758.109). Everything shows up in the 'sources' panel in chrome and when testing the sourcemap using the source-map package, everything also maps correctly.

Despite this the console output only links to line 10000-something in the bundled output file.

tsconfig.json

{
  "compilerOptions": {
    "types": ["node"],
    "target": "ES6",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "sourceMap": true,
    "inlineSources": true
  },
  "include": ["src", "declaration.d.ts"]
}

webpack.config.js

import { fileURLToPath, URL } from "url";
import pkg from "webpack";
const { DefinePlugin, EnvironmentPlugin } = pkg;

export default async function (env) {
  const mode = env.mode || "development";
  const prod = mode == "production";

  return {
    mode: prod ? "production" : "development",
    entry: "./src/main.ts",
    devtool: mode === "development" ? "inline-source-map" : "source-map",
    performance: {
      hints: false, // ignore size since the bundle is run locally
    },
    module: {
      rules: [
        {
          test: /\.ts$/,
          exclude: /node_modules/,
          use: {
            loader: "ts-loader",
          },
        }
      ],
    },
    ignoreWarnings: [/Failed to parse source map/],
    plugins: [
      new EnvironmentPlugin({
        SENTRY_DSN: "",
      }),
      new DefinePlugin({
        __SENTRY_DEBUG__: !prod,
      }),
    ],
    resolve: {
      extensions: [".ts", ".js"],
    },
    externals: {
      obsidian: "commonjs obsidian",
    },
    output: {
      path: fileURLToPath(new URL(".", import.meta.url)),
      filename: "main.js",
      libraryTarget: "commonjs",
    },
  };
}

The sources content:

the sources tab in chrome devtools

The console errors:

the errors in the devtools console

Could this be a bug in chrome? Seems kinda hard to mess up imo

0 Answers
Related