diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/package.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/package.json new file mode 100644 index 0000000..de3754d --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/package.json @@ -0,0 +1,12 @@ +{ + "name": "117-const-enums.explainer", + "version": "1.0.0", + "description": "", + "scripts": { + "dev": "nodemon --exec \"tsc && node dist/index.mjs\" ./src/index.mts" + }, + "keywords": [], + "author": "Matt Pocock", + "devDependencies": {}, + "type": "module" +} diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/esm-module.ts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/esm-module.ts new file mode 100644 index 0000000..ccea393 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/esm-module.ts @@ -0,0 +1,6 @@ +const hello = () => { + console.log("Hello!"); +}; + +// @ts-expect-error +export default hello; diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/index.ts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/index.ts new file mode 100644 index 0000000..4264c8e --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/src/index.ts @@ -0,0 +1,8 @@ +// @ts-expect-error +import esModule from "./esm-module.js"; + +const main = async () => { + esModule(); +}; + +main(); diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/tsconfig.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/tsconfig.json new file mode 100644 index 0000000..0401340 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.problem/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "isolatedModules": true, + "verbatimModuleSyntax": true + }, +} \ No newline at end of file diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/package.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/package.json new file mode 100644 index 0000000..be6394a --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/package.json @@ -0,0 +1,11 @@ +{ + "name": "117-const-enums.explainer", + "version": "1.0.0", + "description": "", + "scripts": { + "dev": "nodemon --exec \"tsc && node dist/index.mjs\" ./src/index.mts" + }, + "keywords": [], + "author": "Matt Pocock", + "devDependencies": {} +} diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/esm-module.ts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/esm-module.ts new file mode 100644 index 0000000..ccea393 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/esm-module.ts @@ -0,0 +1,6 @@ +const hello = () => { + console.log("Hello!"); +}; + +// @ts-expect-error +export default hello; diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/index.ts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/index.ts new file mode 100644 index 0000000..4264c8e --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/src/index.ts @@ -0,0 +1,8 @@ +// @ts-expect-error +import esModule from "./esm-module.js"; + +const main = async () => { + esModule(); +}; + +main(); diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/tsconfig.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/tsconfig.json new file mode 100644 index 0000000..0401340 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.1/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "isolatedModules": true, + "verbatimModuleSyntax": true + }, +} \ No newline at end of file diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/package.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/package.json new file mode 100644 index 0000000..de3754d --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/package.json @@ -0,0 +1,12 @@ +{ + "name": "117-const-enums.explainer", + "version": "1.0.0", + "description": "", + "scripts": { + "dev": "nodemon --exec \"tsc && node dist/index.mjs\" ./src/index.mts" + }, + "keywords": [], + "author": "Matt Pocock", + "devDependencies": {}, + "type": "module" +} diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/esm-module.cts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/esm-module.cts new file mode 100644 index 0000000..ccea393 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/esm-module.cts @@ -0,0 +1,6 @@ +const hello = () => { + console.log("Hello!"); +}; + +// @ts-expect-error +export default hello; diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/index.cts b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/index.cts new file mode 100644 index 0000000..4264c8e --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/src/index.cts @@ -0,0 +1,8 @@ +// @ts-expect-error +import esModule from "./esm-module.js"; + +const main = async () => { + esModule(); +}; + +main(); diff --git a/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/tsconfig.json b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/tsconfig.json new file mode 100644 index 0000000..0401340 --- /dev/null +++ b/src/082-cjs-vs-esm/209.5-treat-ts-files-as-cjs.solution.2/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "isolatedModules": true, + "verbatimModuleSyntax": true + }, +} \ No newline at end of file