Learn JavaScript

Lesson 3 of 9 · Modules: import, export and How Files Find Each Other

Module 11 · Modules: import, export and How Files Find Each Other

Full Programs: a Calculator, a Barrel File, a Circular Import and a Plugin Loader

Free with an accountReading

Knowing the rules is not the same as splitting a real program well. This lesson builds six complete programs, each made of a few modules. Every program reads its input in main.js, hands the work to its modules, and prints the result.

Checking what this lesson needs for you…

What is inside Full Programs: a Calculator, a Barrel File, a Circular Import and a Plugin Loader

  1. The shape every program here shares
  2. Program 1: a two-file calculator
  3. Program 2: a utilities module with a default export
  4. Program 3: a circular import, broken and fixed
  5. Program 4: a barrel file for a component folder
  6. Program 5: a plugin loader with import()
  7. Program 6: a shared store in CommonJS