Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.22 KB

README.md

File metadata and controls

41 lines (26 loc) · 1.22 KB

42. Import export design

Create clear module boundaries.

Learn

  • named exports
  • default exports
  • dependency graph

How it works

Named exports make the public surface of a module explicit. Import only what a consumer needs, and avoid circular dependencies where modules require each other's initialization. A module boundary should group related behavior, not just split a file by line count.

Common mistake

Re-exporting everything from every file hides dependencies and makes changes hard to trace.

Guided challenge

Create one module for calculations and another for display, then document each exported function.

Run the example

Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.

Completion check

  • Explain the core idea in your own words without reading the code.
  • Change one input and predict the output before running it.
  • Test one boundary or failure case, then record what you changed.

Local server

Run python3 -m http.server 8000 from the JavaScripts folder, then open this lesson through http://localhost:8000/. Fetch, modules, storage, history, and workers can behave differently or fail under file URLs.