-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f012b7
commit 60b236b
Showing
73 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/082-cjs-vs-esm/206-cant-import-esm-into-cjs.problem/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const esmModule = require("./esm-module.js"); // cjs require | ||
const esModule = require("./esm-module.js"); // cjs require | ||
|
||
const main = async () => { | ||
esmModule.default(); | ||
esModule.default(); | ||
}; | ||
|
||
main(); |
6 changes: 3 additions & 3 deletions
6
src/082-cjs-vs-esm/206-cant-import-esm-into-cjs.solution/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// const esmModule = require("./esm-module.mjs"); // cjs require | ||
// const esModule = require("./esm-module.mjs"); // cjs require | ||
|
||
const main = async () => { | ||
const esmModule = await import("./esm-module.mjs"); // Dynamic import | ||
const esModule = await import("./esm-module.mjs"); // Dynamic import | ||
|
||
esmModule.default(); | ||
esModule.default(); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const main = async () => { | ||
const esmModule = await import("./esm-module.js"); // Dynamic import | ||
const esModule = await import("./esm-module.js"); // Dynamic import | ||
|
||
esmModule.default(); | ||
esModule.default(); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const main = async () => { | ||
const esmModule = await import("./esm-module.mjs"); // Dynamic import | ||
const esModule = await import("./esm-module.mjs"); // Dynamic import | ||
|
||
esmModule.default(); | ||
esModule.default(); | ||
}; | ||
|
||
main(); |
12 changes: 12 additions & 0 deletions
12
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "117-const-enums.explainer", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "nodemon --exec \"tsc && node dist/index.js\" ./src/index.ts" | ||
}, | ||
"keywords": [], | ||
"author": "Matt Pocock", | ||
"devDependencies": {} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/src/esm-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const hello = () => { | ||
console.log("Hello!"); | ||
}; | ||
|
||
export default hello; |
7 changes: 7 additions & 0 deletions
7
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import esModule from "./esm-module"; | ||
|
||
const main = async () => { | ||
esModule(); | ||
}; | ||
|
||
main(); |
13 changes: 13 additions & 0 deletions
13
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"outDir": "dist", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"isolatedModules": true, | ||
"verbatimModuleSyntax": true | ||
}, | ||
} |
13 changes: 13 additions & 0 deletions
13
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.solution/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "117-const-enums.explainer", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "nodemon --exec \"tsc && node dist/index.js\" ./src/index.ts" | ||
}, | ||
"keywords": [], | ||
"author": "Matt Pocock", | ||
"devDependencies": {}, | ||
"type": "module" | ||
} |
5 changes: 5 additions & 0 deletions
5
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.solution/src/esm-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const hello = () => { | ||
console.log("Hello!"); | ||
}; | ||
|
||
export default hello; |
7 changes: 7 additions & 0 deletions
7
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.solution/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import esModule from "./esm-module.js"; | ||
|
||
const main = async () => { | ||
esModule(); | ||
}; | ||
|
||
main(); |
13 changes: 13 additions & 0 deletions
13
src/082-cjs-vs-esm/209-treat-ts-files-as-esm.solution/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"outDir": "dist", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"isolatedModules": true, | ||
"verbatimModuleSyntax": true | ||
}, | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.