Open Bug 1808361 Opened 3 years ago Updated 5 months ago

DevTools JavaScript debugger incorrectly thinks a file is not minified and so won't pretty-print it

Categories

(DevTools :: Debugger, defect, P3)

Firefox 108
defect

Tracking

(Not tracked)

People

(Reporter: mozilla, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko/20100101 Firefox/108.0

Steps to reproduce:

  1. visit https://app.regrello.com
  2. open dev tools
  3. navigate to the debugger
  4. select the following file:
    /static/node_modules/.pnpm/react-dom@17.0.2_react@17.0.2/node_modules/react-dom/cjs/react-dom.production.min.js
  5. click the "{}" pretty-print button under the minified source code

Actual results:

The button cannot be clicked. It is disabled, and on hover, displays the following message:
"Can't pretty-print original sources, file is already readable"

Expected results:

The button should have worked and reformatted the source code.

Note: the file can still be pretty-printed by right-clicking the tab above the debugger with the filename, and then selecting "pretty-print source"

The Bugbug bot thinks this bug should belong to the 'DevTools::Debugger' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Debugger
Product: Firefox → DevTools

The message is indeed confusing. If I remember correctly the reason we disable the button is that this source is an "original" source, meaning that we retrieved it from a sourcemap. In this case the website actually uses it packaged in a bundled file called https://app.regrello.com/static/js/3.a16de4ac.chunk.js. Pretty printing an original source can confuse the debugger and create issues with breakpoints.

We should not assume that the file is "readable" and at least update the message.

Severity: -- → S3
Priority: -- → P3
Flags: needinfo?(hmanilla)

It was incorrectly assumed that original sources are always prettyfied.
In these cases we should enable pretty printing.

See Also: → 1905790
Status: UNCONFIRMED → NEW
Ever confirmed: true

If we want to support pretty-printing original files (coming from a sourcemap) then we'd probably need to merge the sourcemap that contains the original file with the one we generate for the pretty-printing step. There are several libraries that show how to do this: merge-source-map, combine-source-map (both based on our source-map library) and @ampproject/remapping.

Flags: needinfo?(hmanilla)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: