Skip to content

Commit

Permalink
2023-09-18T11:50:00.812Z
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Sep 18, 2023
1 parent 4f012b7 commit 60b236b
Show file tree
Hide file tree
Showing 73 changed files with 84 additions and 9 deletions.
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();
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();
4 changes: 2 additions & 2 deletions src/082-cjs-vs-esm/207-mts-files.problem/src/index.ts
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();
4 changes: 2 additions & 2 deletions src/082-cjs-vs-esm/207-mts-files.solution/src/index.ts
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 src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/package.json
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": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const hello = () => {
console.log("Hello!");
};

export default hello;
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 src/082-cjs-vs-esm/209-treat-ts-files-as-esm.problem/tsconfig.json
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 src/082-cjs-vs-esm/209-treat-ts-files-as-esm.solution/package.json
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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const hello = () => {
console.log("Hello!");
};

export default hello;
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();
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
},
}

0 comments on commit 60b236b

Please sign in to comment.