02 / 03

Why would we need two multiple entry points?

Difficulty: 6/10
Code Splitting, Multi-Page Applications, Webpack Optimization

Having multiple entry points in a Webpack bundle configuration is beneficial when you want to create distinct bundles for different parts of your application. Each entry point represents a unique file or set of files that serve as the starting point for Webpack to build a bundle.

Multiple entry points allow you to create separate bundles for different sections or features of your application, such as an admin panel and a user-facing interface.
  1. 1

    Separate entry points result in smaller, more focused bundles, which can reduce load times for specific parts of your application. Users only need to download the bundle relevant to the current page or feature.

  2. 2

    If your app needs to support both legacy browsers and modern ones, you can create bundles tailored to each environment, using different entry points

  3. 3

    For applications with separate independent pages or features, you can create distinct bundles for each entry point.

  4. 4

    Isolate third-party libraries (e.g., React, lodash) into a separate bundle.

  5. 5

    Separate entry points for different sites or platforms in a multisite or cross-platform setup.

  6. 6

    Separate entry points for micro-frontend applications, where each micro-frontend represents a distinct feature or module.

  7. 7

    Applications that combine static pages with dynamic Single Page Application (SPA) features.

Scenario Questions

0-2 years experience

  1. 1Imagine we have a marketing landing page and a main React dashboard app in the same repository. The landing page needs to load instantly, so we don't want any of the heavy React dashboard code bundled with it. How would you configure Webpack to output two separate JS bundles for these pages?
  2. 2We need to build a customer support chat widget that third-party sites can embed via a script tag, alongside our main web app. How would you set up your Webpack entry configuration so that running a build generates both the main app bundle and this isolated widget bundle?

2-5 years experience

  1. 1We recently split our app into two entry points: app.js and admin.js. However, we noticed our total bundle size spiked because both bundles are now packaging their own copies of React and Lodash. How would you diagnose this, and what Webpack configuration changes would you make to ensure these shared libraries are only loaded once?
  2. 2You've configured two entry points on a single page—one for a legacy header widget and one for the new main content area. When you load the page, you get a runtime error about Webpack's global chunk loading function conflicting. What's causing this, and how do you resolve it in the Webpack config?

5-8 years experience

  1. 1We have a monorepo with 10 different internal tools, each defined as a separate Webpack entry point. As the team grows, local development startup and hot-reloading times have become painfully slow because Webpack is compiling all 10 entry points at once. How would you redesign this build setup to improve developer experience without completely splitting the repo?
  2. 2We are designing a micro-frontend-like architecture where a host shell loads several independent sub-applications. We want to use Webpack entry points to build these sub-apps separately but still share a common vendor runtime to keep initial load times low. What are the architectural tradeoffs of using multiple entry points with dependOn versus moving to Webpack Module Federation?

8+ years experience

  1. 1We are migrating a massive, 10-year-old multi-page server-rendered application with hundreds of legacy entry points to a modern single-page React architecture. We can't do it overnight. How would you design a progressive migration strategy using Webpack's entry point configuration to bridge the gap, and how would you manage the shared dependency graph across teams during this transition?
  2. 2At our scale, we have hundreds of entry points generated dynamically based on CMS pages. Our CI/CD build times are hitting 45 minutes, costing thousands of dollars. How would you architect a build pipeline that optimizes Webpack's compilation of these entry points, considering caching strategies, parallelization, or alternative bundler architectures?

Follow-up Questions

  • How does optimization.splitChunks differ from using the dependOn property in entry points?
  • What happens to the Webpack runtime chunk when you have multiple entry points on the same page?
  • If you migrate from Webpack to Vite or Esbuild, how does the handling of multiple entry points change?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.