awesome-everything RU
↑ Back to the climb

Frontend Architecture

Build pipelines: config and snippet reading

Crux Read real build configs and a package.json field, predict the bundler behaviour, and pick the highest-leverage fix for tree-shaking, mode, source maps, and env inlining.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Build problems are diagnosed in the config and the package manifest, not in the running app. Read each snippet, predict what the bundler does with it, and choose the fix a senior would make first.

Goal

Practise the loop you run on every build regression: read the config, predict where bytes leak or where dev and prod diverge, and reach for the precise field — sideEffects, mode, sourcemap, manualChunks, env — that fixes the root cause.

Snippet 1 — the sideEffects declaration

{
  "name": "@acme/ui",
  "module": "dist/index.js",
  "sideEffects": false,
  "exports": { ".": "./dist/index.js" }
}

The package ships a dist/styles.css that components import for their styling, e.g. import "./button.css" at the top of Button.js.

Quiz

A consumer reports that some component styles vanish in their production build. What does this sideEffects value cause, and what is the fix?

Snippet 2 — dev vs prod mode and NODE_ENV

// webpack.config.js
module.exports = {
  mode: "development",
  // ...loaders, plugins...
};

The team runs this exact config in CI to produce the artifact they deploy to production.

Quiz

The deployed bundle is ~3× larger than expected and React logs development warnings in prod. What is wrong, and what is the highest-leverage fix?

Snippet 3 — source maps in production

// vite.config.js
export default {
  build: {
    sourcemap: false,
  },
};

Production throws an error and the stack trace reads index-a1b2c3.js:1:88431. The error tracker shows the same unreadable frame.

Quiz

You need readable prod stack traces in your error tracker without exposing source to the public. What is the right setting?

Snippet 4 — manualChunks and env inlining

// vite.config.js
export default {
  build: {
    rollupOptions: {
      output: {
        manualChunks: { vendor: ["react", "react-dom"] },
      },
    },
  },
};

A reviewer also notices a client component reads process.env.API_SECRET to call an internal API.

Quiz

Which statement about this config is correct?

Recap

Every build regression is read in the config: sideEffects: false must list genuinely impure files (like CSS) or the bundler drops them; production must build with production mode so minification and NODE_ENV-gated dead-code-elimination run; source maps belong in ‘hidden’ mode so the error tracker gets readability without public exposure; vendor deserves its own manualChunks chunk for cache stability; and any env value referenced in client code is inlined at build time, so secrets never touch the client. Read the field, predict the output, fix the root cause.

Continue the climb ↑Build pipelines: audit and harden a real build
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.