Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pretty printing #348

Merged
merged 3 commits into from
Feb 25, 2020
Merged

feat: pretty printing #348

merged 3 commits into from
Feb 25, 2020

Conversation

connor4312
Copy link
Member

This kind of existed before, but it broke a while ago and had some
limitations and bugs for a while. This commit improves the experience,
makes it work pretty well for me locally:

  • Only show the pretty print command when a printable file is open in
    a js-debug session.
  • Previously, we only suggested printing ephemeral files. Now we run the
    minified check on files that are in the stacktrace when the user
    opens them, which I think is a good compromise between being apparent
    and being too annoying.
  • The ability to turn off pretty print suggestions is now a user setting.
  • Previously if you were on a breakpoint and then pretty-printed a file,
    continuing to step through would return to the original file, and
    any breakpoints in the minified file would not be updated. We fix that
    by moving the "original location" of breakpoints into the beauitified
    file.
  • Added tests for pretty printing.
  • There were several edge cases around how we handled pretty print
    commands for file on disk and for multiple debug sessions,
    those should be fixed here.

Something that doesn't work yet is the preservation of breakpoints in
beauitified sources on reload. To do this, I think we need to have some
extra logic to watch for breakpoints set in *-pretty.js files, and then
generate the beautified source automatically when we see a source
matching those breakpoints. For a followup PR.

Demo: https://memes.peet.io/img/bc0c485e-323b-44a7-bc2d-bd274ba2344c.mp4

This kind of existed before, but it broke a while ago and had some
limitations and bugs for a while. This commit improves the experience,
makes it work pretty well for me locally:

- Only show the pretty print command when a printable file is open in
  a js-debug session.
- Previously, we only suggested printing ephemeral files. Now we run the
  minified check on files that are in the stacktrace when the user
  opens them, which I think is a good compromise between being apparent
  and being too annoying.
- The ability to turn off pretty print suggestions is now a user setting.
- Previously if you were on a breakpoint and then pretty-printed a file,
  continuing to step through would return to the original file, and
  any breakpoints in the minified file would not be updated. We fix that
  by moving the "original location" of breakpoints into the beauitified
  file.
- Added tests for pretty printing.
- There were several edge cases around how we handled pretty print
  commands for file on disk and for multiple debug sessions,
  those should be fixed here.

Something that doesn't work yet is the preservation of breakpoints in
beauitified sources on reload. To do this, I think we need to have some
extra logic to watch for breakpoints set in *-pretty.js files, and then
generate the beautified source automatically when we see a source
matching those breakpoints. For a followup PR.
package.json Show resolved Hide resolved
src/test/sources/pretty-print.test.ts Outdated Show resolved Hide resolved
@connor4312 connor4312 merged commit 8c822e3 into master Feb 25, 2020
@connor4312 connor4312 deleted the feat/prettiest-printing branch February 25, 2020 19:40
@connor4312 connor4312 added this to the February 2020 milestone Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants