Debugging Modern Web Applications

Building and debugging modern JavaScript applications in Firefox DevTools simply took a mess leap forward. In cooperation with Logan Smyth , Tech Lead to get Babel , we leveled up the debugger’ t source map support to allow you to inspect the code that you really wrote. Combined with the ongoing initiative to provide first-class JS framework support throughout all our devtools, this will increase productivity for modern web application developers.

Modern JS frameworks and build tools play a vital role today. Frameworks like React , Angular , plus Ember let developers build declarative user interfaces with JSX, directions, and templates. Tools like Webpack , Babel , plus PostCSS let developers use brand new JS and CSS features prior to they are supported by browser suppliers. These tools help developers write easier code, but generate more complicated program code to debug.

Within the example below, we use Webpack and Babel to compile SERA Modules and async functions in to vanilla JS, which can run in different browser. The original code on the still left is pretty simple. The generated, browser-compatible code on the right is much more complex.

In the example below, we make use of Webpack and Babel to put together ES Modules and async features into vanilla JS. The original program code on the left is pretty simple. The particular generated, browser-compatible code on the correct is much more complicated.
Figure 1 . Original file in the left, generated file on the correct.

When the debugger pauses, it uses source maps in order to navigate from line 13 within the generated code to line four in the original code. Unfortunately, since pausing actually happens on line thirteen, it can be difficult for the user to determine what the value of dancer are at that time. Moving the mouse on the variable dancer returns undefined as well as the only way to find the scope associated with dancer is to open every six of the available scopes within the Scopes pane followed by expanding the particular _emojis object! This difficult and frustrating process is why lots of people opt to disable source maps.

A view of the disconnect between your original code file and the created code, which opens multiple scopes
Figure 2 . Value of dancer will be undefined, six separate scopes within the Scopes pane.

To address this problem we teamed up along with Logan Smyth to see if it had been possible to make the interaction feel a lot more natural, as if you were debugging your own original code. The result is a brand new engine that maps source roadmaps data with Babel’ s format tree to show the variables you anticipate to see the way you want to see all of them.

Now the panel shows the correct value of dancer, and the Scopes pane shows one scope
Number 3. Correct value of dancer is definitely displayed, Scopes pane shows 1 scope.

These types of improvements were first implemented designed for Babel and Webpack, and we’ re currently adding support regarding TypeScript, Angular, Vue, Ember, and many more. If your project already generates resource maps there is a good chance this particular feature will work for you out of the package.

To try it out there, just head over and download Firefox Developer Model . You can help us simply by testing this against your own task and confirming any issues. In order to follow along, say hello, or even contribute, you can also find us on the devtools channel Github or Mozilla Discourse or in the devtools Slack !

Our 2018 goal is to enhance the lives of web developers who are creating modern apps using the latest frameworks, build tools and best practices. Repairing variables is just the beginning. The future is usually bright!

Staff Engineer upon Firefox Developer Tools devving the particular DevTools and debugging the debugger.

More articles by jlaster…

Guiding Firefox’s Devtools and Performance work. Come hangout with the DevTools team !

More articles simply by Harald Kirschner…

If you liked Debugging Modern Web Applications by Then you'll love Web Design Agency Miami

Add a Comment

Your email address will not be published. Required fields are marked *