liveBook · Manning

Dependency graph

As explained in Secrets of the JavaScript Ninja, Third Edition

A graph representing dependencies among components of a software project.

A dependency graph makes explicit what each piece of code needs. Build tools can use those dependencies to infer load order, detect missing or circular dependencies at build time, and avoid loading unused dependencies. section 13.1

<script src="ninja-library.js"></script>
<script src="ninja-app.js"></script>

Serial script tags rely on manually specified load order, unlike explicit dependencies that let tools infer it. section 13.1

ECMAScript modules also let tools identify and prune unused code within a module through tree-shaking. section 13.1

How Secrets of the JavaScript Ninja, Third Edition covers it

How deep it goes
Explains build-time benefits and tree-shaking, but does not detail graph construction.
Examples
Contrasts serial script tags and global-variable dependencies with explicit module dependencies.
What you can do after
Understand how explicit dependencies support inferred ordering, build-time error detection, and unused-code pruning.
How it connects
Connects ECMAScript modules with circular dependencies, deferred loading, and tree-shaking.

Also explained in

Compare how 9 books explain dependency graph →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Third Edition. The section links point to the parts of the book it draws on.