From ce28c77f3e24f8a80d31cc585171062ca331cba1 Mon Sep 17 00:00:00 2001
From: cjyuan
Date: Mon, 4 Aug 2025 22:13:33 +0100
Subject: [PATCH 1/7] Add initial implementation
---
Sprint-3/todo-list/00-what_is_ES_modules.md | 16 ++
.../01-using_esm_with_nodejs_and_jest.md | 47 +++++
.../todo-list/02-guide_to_modularize_code.md | 40 +++++
Sprint-3/todo-list/README.md | 74 +++-----
Sprint-3/todo-list/assets/world.jpg | Bin 74308 -> 0 bytes
Sprint-3/todo-list/index.html | 61 ++++---
Sprint-3/todo-list/package.json | 8 +-
Sprint-3/todo-list/package.json-windows | 21 +++
Sprint-3/todo-list/script.js | 25 ---
Sprint-3/todo-list/script.mjs | 69 ++++++++
Sprint-3/todo-list/script.test.js | 162 ------------------
Sprint-3/todo-list/style.css | 106 ++++++++++++
Sprint-3/todo-list/todos.mjs | 27 +++
Sprint-3/todo-list/todos.test.mjs | 134 +++++++++++++++
14 files changed, 531 insertions(+), 259 deletions(-)
create mode 100644 Sprint-3/todo-list/00-what_is_ES_modules.md
create mode 100644 Sprint-3/todo-list/01-using_esm_with_nodejs_and_jest.md
create mode 100644 Sprint-3/todo-list/02-guide_to_modularize_code.md
delete mode 100644 Sprint-3/todo-list/assets/world.jpg
create mode 100644 Sprint-3/todo-list/package.json-windows
delete mode 100644 Sprint-3/todo-list/script.js
create mode 100644 Sprint-3/todo-list/script.mjs
delete mode 100644 Sprint-3/todo-list/script.test.js
create mode 100644 Sprint-3/todo-list/todos.mjs
create mode 100644 Sprint-3/todo-list/todos.test.mjs
diff --git a/Sprint-3/todo-list/00-what_is_ES_modules.md b/Sprint-3/todo-list/00-what_is_ES_modules.md
new file mode 100644
index 000000000..c10214863
--- /dev/null
+++ b/Sprint-3/todo-list/00-what_is_ES_modules.md
@@ -0,0 +1,16 @@
+# What is JavaScript Modules?
+JavaScript modules let us organize code into separate files, making the code easier to manage and reuse. We can export parts of one file (like functions or variables) and import them into another to keep our code clean and modular.
+
+## Different Module Systems
+
+JavaScript has two main ways to handle modules:
+
+- **CommonJS** is the older format used mostly in Node.js. It uses `require` and `module.exports`.
+
+- **ES Modules** (ESM) are the modern, standard way for browsers and Node.js. They use `import` and `export`.
+
+They are **not** fully compatible.
+
+## Where can I learn ESM?
+- [Modules, introduction](https://javascript.info/modules-intro)
+- [JavaScript modules -- JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
\ No newline at end of file
diff --git a/Sprint-3/todo-list/01-using_esm_with_nodejs_and_jest.md b/Sprint-3/todo-list/01-using_esm_with_nodejs_and_jest.md
new file mode 100644
index 000000000..3f1090ab8
--- /dev/null
+++ b/Sprint-3/todo-list/01-using_esm_with_nodejs_and_jest.md
@@ -0,0 +1,47 @@
+# Using ESM with Node.js, Jest, and `jsdom`
+
+## Node.js
+
+Node.js supports both CommonJS and ESM, with CommonJS being the default module system.
+
+To use ESM, we can add `"type": "module"` to `package.json`, or we can name the JS script files with `.mjs` file extension.
+
+**Important**:
+- Avoid mixing CommonJS and ESM in the same project unless you know what you're doing.
+
+
+## Jest
+
+[Jest’s support for ESM](https://jestjs.io/docs/ecmascript-modules) is still experimental, and may require additional configuration to work correctly.
+
+One way to execute Jest test script that uses ESM is to
+
+1. **Update the custom `test` script in `package.json`**:
+```javascript
+"scripts": {
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest"
+}
+```
+
+**Note**: On Windows, use **`set`** instead
+```javascript
+"scripts": {
+ "test": "set NODE_OPTIONS=--experimental-vm-modules && jest"
+}
+```
+
+
+2. **Run a specific Jest test script using**:
+
+```
+npm test --
+```
+
+**Note**: The `--` is optional if you do not have arguments to be forwarded to the underlying jest command.
+
+
+## `jsdom`
+
+[**`jsdom`**](https://github.com/jsdom/jsdom), a pure-JavaScript implementation of DOM for use with Node.js, **does not yet support** `
-