question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve source map quality for development

See original GitHub issue

Feature Description

Source maps let us inspect the original source files from JS modules that have been bundled together (for us, using Webpack). Webpack exposes quite a few options for different source map strategies via the devtool configuration option which have different costs in terms of the quality of the information included and the time it adds to the build.

We currently use the cheap-source-map option as part of our build script: https://github.com/google/site-kit-wp/blob/6123efaea980ad2c4179a2995b1d7c6178b010da/package.json#L9

This option has good performance for the initial build but slow rebuilds. It also only provides transformed (i.e. transpiled) code, which can make it difficult to track down the real source code. For example, in React all JSX would be shown as React.createElement calls, which is not ideal.

We should consider changing our source map configuration used for development, which provides the original source, rather than transformed lines. In initial testing cheap-module-eval-source-map seems like a good option without too much additional overhead in the initial build, and is faster that what we have now for rebuilds.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The default options used for the development build should be updated to generate a higher quality source map that provides original source (can be lines only)
    • E.g. for React, the source map should show the source JSX rather than createElement calls
  • A sensible default should be chosen to minimize the impact on build and rebuild times (see the table here for a full comparison) – we can always override this as part of the build command with a different value that does not require code changes

Implementation Brief

Test Coverage

  • N/A

Visual Regression Changes

  • N/A

QA Brief

  • Build development assets and verify that you can see the original sources when you open a script in the “Sources” tab of the developer tools:

2021-09-07_18-08

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
johnPhillipscommented, Sep 16, 2021

QA ✅

I used a diffing tool to verify that the source code in dev tools was identical to the original source files.

0reactions
aaemnnosttvcommented, Sep 8, 2021

IB ✅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source Maps - SurviveJS
Source maps can be convenient during development. They provide better means to debug applications as you can still examine the original code over...
Read more >
Quick guide to webpack source map options - Scott Logic Blog
A quick guide to the available source map options in webpack, and the considerations for choosing one in different scenarios.
Read more >
Improving Development with Source Maps for Debugging
The DevTools of all modern browsers offer built-in source maps. These source maps enable DevTools functionality like debugging with breakpoints ...
Read more >
Source maps and how it works - Ehsan Gazar
Source maps can be convenient during development. They provide better means to debug applications as you can still examine the original code ......
Read more >
Devtool - webpack
devtool performance production quality (none) build: fastest rebuild: fastest yes bundle eval build: fast rebuild: fastest no generated eval‑cheap‑source‑map build: ok rebuild: fast no transformed
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found