The Anatomy of Webpack: A Deep Dive Into Its Architecture

This ad is not shown to multipass and full ticket holders
React Advanced
React Advanced 2026
October 23 - 26, 2026
London, UK & Online
Upcoming event
React Advanced 2026
React Advanced 2026
October 23 - 26, 2026. London, UK & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Webpack is a powerful tool for building modern JavaScript applications, but its architecture can be complex and daunting for developers who are new to it. In this talk, we will dive into the inner workings of Webpack and explore how its various components work together to create a bundle.

By the end of this talk, you will have a comprehensive understanding of Webpack's architecture and its plugin system. You will be equipped with the knowledge to build complex applications using Webpack confidently.

This talk has been presented at React Day Berlin 2023, check out the latest edition of this React Conference.

FAQ

A Webpack configuration file specifies how Webpack should behave when it runs. It includes options such as entry points, output directory, plugins, loaders, and optimizations.

Loaders in Webpack are used to transform code into different modules. For example, loaders can be used to parse non-JavaScript files like CSS or PNG files.

Plugins in Webpack enhance the functionality of Webpack by allowing users to tap into various hooks. More than 80% of Webpack's codebase is built on its own plugin architecture, which is facilitated by the Tappable library.

Tappable is a library that creates hooks for plugins in Webpack. It is the backbone of the Webpack plugin system and allows users to get notified of important events and run custom code when those events occur.

Hooks in Webpack allow users to get notified of important events and run custom code. You can create hooks using Tappable and tap into them using the tap method. Hooks are used extensively in Webpack's plugin system.

The compiler is the top-level central dispatch for Webpack. It starts and stops Webpack processes and is accessed through the Node API. The compiler creates a compilation, which kicks off the process of building the dependency graph and generating the final bundle.

The compilation object, created by the compiler, is known as the dependency graph. It is where Webpack starts building the graph, seals it, and renders it into bundles. The compilation object manages the entire build process.

The resolver in Webpack checks if the required paths in the codebase exist. It handles resolving paths for import and require statements and ensures that the appropriate loaders are applied for non-JavaScript files.

Webpack is a module bundler that allows you to write modules that work in the browser. It takes code that is easy for developers to write and converts it into a format that is optimized for browsers to read.

You can use Webpack via configuration by defining a configuration object with entry and output points. It can also be used through its command line interface (CLI) by passing the entry file and output file name. Additionally, Webpack can be used with Webpack server to spin up a local development server or directly via the Node API.

Nitin Kumar
Nitin Kumar
15 min
12 Dec, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
The video talk dives into the architecture of Webpack, a module bundler that transforms code into browser-compatible formats. It explains the role of the compiler as the central dispatch, managing the dependency graph and the build process. The talk highlights the importance of Webpack's plugin architecture, facilitated by Tappable, which allows developers to tap into hooks like compilation.hooks.SEAL and compilation.hooks.optimized. These hooks notify users of important events, enabling them to run custom code. The resolver in Webpack checks if the required paths exist and applies loaders, such as CSS loaders, to transform non-JavaScript files. The talk also covers how to use Webpack via configuration, command line interface, or Node API, starting with a configuration file to create a dependency graph. Finally, it showcases the creation of a basic plugin using the HelloCompilationPlugin class, illustrating how custom plugins can enhance Webpack's functionality.

1. Introduction to Webpack

Short description:

Hello everyone, welcome to my talk on the anatomy of Webpack. Webpack is a module bundler that allows you to write modules for the browser. It takes your code and converts it into a format that browsers can read. You can use Webpack via configuration, command line interface, or the Node API. Webpack starts with a configuration file, reads your entry files, and creates a dependency graph. It then applies loaders to transform the code.

Hello everyone, welcome to my talk, the anatomy of Webpack a deep dive into its architecture. So a little bit about me that I'm a front end engineer at Razorpay and I love open source. I've been involved in open source for almost three years and I've been helping in the maintenance and development of ESLint and Webpack ecosystems. I'm also a big fan of animes particularly One Piece and you can find me on internet as at snitin315.

So let's dive into our talk. So let's start with what is Webpack. So as we all know that Webpack is a module bundler. Another way of explaining Webpack is like it lets you write modules that works in the browser. So what does that mean is we write stuff that is nice for us to write and then Webpack takes all that code and converts into stuff that is nice for browsers to read. So what does that mean? So nice for you to write means easy for developers to read, can be separated into multiple files, multiple repositories. Might be in a language that browsers can't understand, ES6, TypeScript, etc. What would be nice for browsers to read would be ES5, frequent requests, smaller responses.

So how do we use Webpack? So you can use Webpack via configuration. You can define a configuration object with entry and output. And you can also use Webpack via its command line interface. You can just, on CLI, you can just pass Webpack, hyphen, hyphen entry, part to your entry file and then hyphen, hyphen output, hyphen file name, the file name of your bundle. You can also use Webpack server command which will spin up a local development server for you. Or you can directly use the Node API and you can just require Webpack from your Node modules and pass two arguments. First argument is the configuration objects, second is a callback.

So let's see the broad overview of how things work for Webpack over the hood. So we start with a Webpack configuration file. This is where you specify how Webpack should behave when it runs, including options such as entry points, output, directory, plugins, loaders, everything, optimizations, then Webpack read your entry files. And these are the files that Webpack uses to start building your dependency graph. Webpack will analyze the code in these files and follow any dependencies it finds to other files in your applications. Then it creates the dependency graph, which is nothing but just analyzes which module is mapped to another module. Relationships, basically relationships between each modules. Then it applies the loaders and transforms. So Webpack uses loaders to transform the code into each module. For example, there is a non-javascript file which you want to parse through Webpack. You will have to use a loader.

2. Webpack Plugin Architecture and Tappable

Short description:

Webpack handles compiled output by creating a bundle file. Webpack's plugin architecture, built with Tappable, allows users to tap into hooks that notify and execute code for important events. Hooks can be created with Tappable by importing a sync hook and defining them in the constructor. Tapping into hooks is done using the tap method, with the plugin name and a callback function as arguments.

It could be a CSS file, it could be a PNG file. Then, when everything is compiled, it creates a compiled output. So, after Webpack has processed all the modules, it produces a single file which is called a bundle. And then, as per the output management, we configure how we want Webpack to handle this bundle file. Like where on disk we want to write this file.

So in Webpack, everything is a plugin. So what does that mean is more than 80% of Webpack's codebase is built of its own plugin architecture. But before we learn more about plugins, we need to know about Tappable. So what is Tappable? Tappable is a library that creates hooks for plugins. It is created and maintained by the Webpack team only. And it is the backbone of the Webpack plugin system.

So what are hooks? Hooks allow other users to get notified of important events and run the other user's code when any important event happens. For example, browser exposes many hooks for us to tap into. For example, this is a basic hook, document.addEventListener on click. So whenever a user clicks on the screen, a message is printed to the console. So similarly, Webpack exposes many hooks which you can tap into. And how do we create hooks with Tappable? So you can simply import a sync hook from Tappable and in the constructor of your class, you can define a This.hooks property in which you redefine all the hooks.

So how to create hooks with Tappable? Yeah, so that's how we create a hook. So for example, in this example, we have a class Car in which we have a constructor in where we have defined our hooks via This.hooks. We have two hooks one is CarStarted and radioChanged hook. So whenever we want to call this hook, we can just run its call method. For example, we have a turn on method where we can do This.hooks.carStarted.call and whenever we call the turn on hook, this CarStarted hook will be triggered. Yeah, but how do we tap into hook. So to tap into hook we run its tap method. So for example, in the earlier example, we initialized a new instance of myCar. Now we can do myCar.hooks.CarStarted.tap and the first argument is the name of the plugin and this name is used for debugging purposes. And the second argument is a callback function. This is called when your hook is called. So whenever you will do, you will run myCar.turnOn it will print CarStarted. Similarly you can also pass options to your plugins.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Thinking Like an Architect
Node Congress 2025Node Congress 2025
31 min
Thinking Like an Architect
Top Content
In modern software development, architecture is more than just selecting the right tech stack; it involves decision-making, trade-offs, and considering the context of the business and organization. Understanding the problem space and focusing on users' needs are essential. Architectural flexibility is key, adapting the level of granularity and choosing between different approaches. Holistic thinking, long-term vision, and domain understanding are crucial for making better decisions. Effective communication, inclusion, and documentation are core skills for architects. Democratizing communication, prioritizing value, and embracing adaptive architectures are key to success.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Dark Side of Micro-Frontends
React Advanced 2025React Advanced 2025
29 min
The Dark Side of Micro-Frontends
In the Talk, various key points were discussed regarding micro-front-end architecture. These included challenges with micro-intents, common mistakes in system design, the differences between micro-intents and components, granularity in software architecture, optimizing micro-front-end architecture, efficient routing and deployment strategies, edge computing strategies, global state and data sharing optimization, managing data context, governance and fitness functions, architectural testing, adaptive growth, value of micro-frontends, repository selection, repo structures, and web component usage.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
AI Coding Summit 2025AI Coding Summit 2025
86 min
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
Workshop
Stepan Suvorov
Stepan Suvorov
Join a focused 2-hour session covering MCP's purpose, architecture, hands-on server implementation, and future directions. Designed for developers and system architects aiming to integrate contextual data with ML models effectively. Agenda:- Introduction & Why MCP? Key challenges MCP solves and core benefits.- Architecture Deep Dive: components, interactions, scalability principles. - Building Your Own MCP Server: guided walkthrough with code snippets and best practices; live demo or code review.- Future of MCP Developments: potential enhancements, emerging trends, real-world scenarios.
Key Takeaways:- Clear understanding of MCP's rationale.- Insight into design patterns and scaling considerations.- Practical steps to implement a prototype server.- Awareness of upcoming trends and how to apply MCP in projects. 
From Async Chaos to Deterministic React: Hands-On State Machine Architecture for Real-Time Systems
React Summit 2026React Summit 2026
86 min
From Async Chaos to Deterministic React: Hands-On State Machine Architecture for Real-Time Systems
Workshop
Rajni Gediya
Rajni Gediya
Mentorship available
As React apps move into real-time systems — streaming data, AI workflows, hardware devices — async complexity grows quickly. Reducers and scattered async handlers often work at first, but once concurrency and lifecycle interruptions enter the picture, things start to break in subtle ways.
In this hands-on workshop, we’ll take a fragile async React setup and redesign it into a deterministic, state-machine-driven architecture. The goal isn’t to teach a specific library, but to show how explicit state modeling makes complex systems easier to reason about and more reliable in production.
Node's Concurrency With the Strength of a Bull With BullMQ
Node Congress 2026Node Congress 2026
95 min
Node's Concurrency With the Strength of a Bull With BullMQ
Workshop
Edy Silva
Douglas Marques
2 authors
Node's concurrent nature is powerful already, but often we need to push work out of the main server for several reasons. In this work, we will explore a few scenarios in which work is cleverly pushed to another Node process to resolve.
Once we use a queue to distribute workloads, we need to identify the nature of the work to be done. For either I/O- or CPU-intensive work, the first is already perfectly covered by a single Node.js process; we will need to tweak the worker setup to match the available resources and throughput.