Understand build inputs and the module graph
Quick answer
A module graph connects entry modules to the modules they import. A bundler walks this graph and generates browser-consumable output, potentially rewriting imports and transforming assets.
Tooling examples
Example 1. Context: projects/build-lab. Run in a fresh prepared fixture copy; see its README. Local check available; consult validation evidence for what was asserted.
node main.mjsExpected observation: Total: 12
Example 2. Context: projects/build-lab. Run in a fresh prepared fixture copy; see its README. Save as example.mjs in that folder; run node example.mjs. Local check available; consult validation evidence for what was asserted.
import { price } from "./price.mjs";console.log(price(5, 3));Expected observation: 15
How the tooling works
The supplied build-lab has a main.mjs entry and two small native modules. Relative paths are resolved relative to the importing module, not the shell working directory. A browser normally needs URLs or an import map to resolve bare package specifiers; a bundler can resolve package dependencies and rewrite references. A build output can contain multiple chunks and assets, not necessarily a single JavaScript file. Node running a native module validates language behavior only, not bundler output.
Common mistakes
Do not assume a successful Node import proves that every bare specifier works in the browser.
Practice
Draw the static edge from main.mjs to price.mjs; then draw a possible dynamic edge from an optional report entry to report.mjs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Understand build inputs and the module graph — Knowledge Check
Assess tooling contracts, diagnostic reasoning and transfer to a project.
What is an entry module in a build graph?
How is a relative import normally resolved in an ES module?
Does a production bundle have to be a single JavaScript file?
In Understand build inputs and the module graph, what is the expected observation for example 1 in its documented setup? node main.mjs
In Understand build inputs and the module graph, what is the expected observation for example 2 in its documented setup? import { price } from "./price.mjs"; console.log(price(5, 3));