SlideShare a Scribd company logo
How Sh*t Works -
Source Maps
Adir Amsalem, Front End Developer
adiramsalem AdirAmsalem@amsalemadiradira@wix.com
Hi.
Lithuania
I am Adir Amsalem.
● Front end @ Wix
● Co-organizer @ YGLF
Ukraine
Vilnius
Kyiv
Dnipro
Wix Engineering Locations
Israel
Tel-Aviv
Be’er Sheva
AGENDA
Motivation
Introduction to Source Maps
Deep Dive
Motivation
01
Credits: https://medium.com/@withinsight1/the-front-end-spectrum-c0f30998c9f0
Let’s transpile
TypeScript to JavaScript
TypeScript
JavaScript (ES2015)
JavaScript (ES5)
Minified JavaScript
More complex example
Minified Webpack’d Output
Houston, we have a problem
OMG...
OMG...
Better, but not perfect
So...
How can we debug this code?
Introduction to
Source Maps
02
How Shit Works - Source Maps
Terminology
Original Code
The source code which has not been passed through the
compiler.
Generated Code
The code which is generated by the compiler.
Credits: https://github.com/azu/multi-stage-sourcemap
simple-greeter.js
Transpiling it with Babel
simple-greeter.js simple-greeter.es5.js simple-greeter.es5.js.map
simple-greeter.es5.js
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
simple-greeter.es5.js.map
1. Starts at the beginning of the generated file
simple-greeter.es5.js.map
1. Starts at the beginning of the file
2. Line breaks are represented by a semicolon (;)
simple-greeter.es5.js.map
1. Starts at the beginning of the file
2. Line breaks are represented by a semicolon (;)
3. Segments are represented by a base64 VLQ
simple-greeter.es5.js.map
1. Starts at the beginning of the file
2. Line breaks are represented by a semicolon (;)
3. Segments are represented by a base64 VLQ
4. Segments are separated by a comma (,)
Source Maps
1. Represented as a single JSON Object
2. Map generated code to original code
3. Can be referenced with either a directive (usually a comment) or an http header
4. Use VLQ to reduce the overall fize size (~50% smaller)
5. Widely adopted - supported by almost every major browser, transpiler,
preprocessor, build tool, etc
6. Not only for JavaScript - CSS can me mapped as well (SASS, LESS, etc)
Deep Dive
03
VLQ
(Variable-length quantity)
A universal code that uses an arbitrary number of binary
octets (eight-bit bytes) to represent an arbitrarily large
integer.
Source: https://en.wikipedia.org/wiki/Variable-length_quantity
VLQ Examples
How Shit Works - Source Maps
Segment Fields
Field number Description
1 Column index of the corresponding
line in the generated file
2 Source index in the sources list
3 Line index in the source represented
4 Column index of the line in the source
represented
Segment Fields
Are relative to the previous segment in the line
Let’s see it in action
Or visualized
Useful Links
1. Source Map Revision 3 Proposal
2. Source Map Visualization
3. Online Source Mapper
4. Webpack configuration
5. NPM package: mozilla/source-map
6. NPM package: azu/multi-stage-sourcemap
7. NPM package: evanw/node-source-map-support
Thank You
adiramsalem AdirAmsalem@amsalemadiradira@wix.com
Q&A
adiramsalem AdirAmsalem@amsalemadiradira@wix.com

More Related Content

PPTX
F# type providers
PDF
Asynchronous web-development with Python
PPTX
Swift vs Objective-C
PPTX
Demistifying the 3D Web - part 2
PDF
kranonit S05E01 Sergey Burma: Welcome to cloud!
PDF
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
PDF
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
PPTX
Intro to Github
F# type providers
Asynchronous web-development with Python
Swift vs Objective-C
Demistifying the 3D Web - part 2
kranonit S05E01 Sergey Burma: Welcome to cloud!
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
Intro to Github

Similar to How Shit Works - Source Maps (20)

PDF
A re introduction to webpack - reactfoo - mumbai
KEY
CommonJS via PINF JavaScript Loader - Introduction
PDF
React Development with the MERN Stack
PDF
Fluent14
PDF
Git Graphs, Hashes, and Compression, Oh My
PDF
Surge2012
PDF
Seaside Portability
PDF
Brand New JavaScript - ECMAScript 2015
PDF
Introduction to JavaScript
KEY
20120816 nodejsdublin
KEY
Introducing the Seneca MVP framework for Node.js
PDF
Charlas CityJS, una por una, atestiguando el crecimiento tech
PDF
Functional Programming with Streams in node.js
PDF
Practical JavaScript Programming - Session 8/8
PDF
Web (dis)assembly
PPTX
Integreation
PPTX
Node.js Web Apps @ ebay scale
PPTX
Node.js - Advanced Basics
PDF
Elm: frontend code without runtime exceptions
PDF
Angular Weekend
A re introduction to webpack - reactfoo - mumbai
CommonJS via PINF JavaScript Loader - Introduction
React Development with the MERN Stack
Fluent14
Git Graphs, Hashes, and Compression, Oh My
Surge2012
Seaside Portability
Brand New JavaScript - ECMAScript 2015
Introduction to JavaScript
20120816 nodejsdublin
Introducing the Seneca MVP framework for Node.js
Charlas CityJS, una por una, atestiguando el crecimiento tech
Functional Programming with Streams in node.js
Practical JavaScript Programming - Session 8/8
Web (dis)assembly
Integreation
Node.js Web Apps @ ebay scale
Node.js - Advanced Basics
Elm: frontend code without runtime exceptions
Angular Weekend
Ad

More from Adir Amsalem (6)

PDF
Building for the next billion users
PDF
Migrating From AngularJS To React
PDF
GraphQL @ Wix
PPTX
The only thing that matters
PPTX
BizwiZ - Automatic and Intelligent Financial Models for Startups
PPTX
Modern Front End Tools & Workflow
Building for the next billion users
Migrating From AngularJS To React
GraphQL @ Wix
The only thing that matters
BizwiZ - Automatic and Intelligent Financial Models for Startups
Modern Front End Tools & Workflow
Ad

Recently uploaded (20)

PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
Hindi spoken digit analysis for native and non-native speakers
OMC Textile Division Presentation 2021.pptx
TLE Review Electricity (Electricity).pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
cloud_computing_Infrastucture_as_cloud_p
Encapsulation theory and applications.pdf
NewMind AI Weekly Chronicles - August'25-Week II
1 - Historical Antecedents, Social Consideration.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
A novel scalable deep ensemble learning framework for big data classification...
Heart disease approach using modified random forest and particle swarm optimi...
Enhancing emotion recognition model for a student engagement use case through...
Programs and apps: productivity, graphics, security and other tools
1. Introduction to Computer Programming.pptx
Chapter 5: Probability Theory and Statistics
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
A comparative analysis of optical character recognition models for extracting...

How Shit Works - Source Maps