Skip to content

Commit 2f24bff

Browse files
committed
progress
1 parent 977221a commit 2f24bff

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

examples/03-module-basics/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
const sayHi = require('./utils')
1+
// CommonJS
2+
//const sayHi = require('./utils')
23

3-
sayHi()
4+
// ESM (EcmaScript Modules)
5+
import Here from './utils.js'
6+
7+
Here()

examples/03-module-basics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "module-basics",
3-
"// type": "commonjs",
3+
"type": "module",
44
"scripts": {
55
"start": "node index.js"
66
}

examples/03-module-basics/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
function sayHi() {
2-
console.log("Hello CommonJS (Node's original module resolver)")
1+
export function sayHi() {
2+
console.log('Hello from sayHi')
33
}
44

5-
module.exports = sayHi
5+
export default function credigy() {
6+
console.log('hello from credity')
7+
}

examples/05-bundling/app/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { sayHi } from './utils.js'
1+
import { sayHi } from './utils.js';
22

3-
sayHi()
3+
sayHi();

0 commit comments

Comments
 (0)