From 233fbfb98a4bdc4445b48d3a6fedb8f7d0bc3873 Mon Sep 17 00:00:00 2001 From: aurelius0523 Date: Fri, 6 Sep 2024 21:16:59 +0800 Subject: [PATCH 1/4] Update module and moduleResolution --- docs/cli/build.md | 6 +++--- packages/skuba-dive/tsconfig.json | 4 ++-- src/cli/build/assets.int.test.ts | 20 ++++++++++---------- src/cli/buildPackage.ts | 10 +++++----- src/cli/configure/modules/package.test.ts | 6 +++--- src/cli/configure/modules/package.ts | 2 +- template/oss-npm-package/_package.json | 2 +- template/private-npm-package/_package.json | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/cli/build.md b/docs/cli/build.md index 02e12ce4d..a9310c7dc 100644 --- a/docs/cli/build.md +++ b/docs/cli/build.md @@ -66,7 +66,7 @@ With esbuild, you can supply the following options: ## skuba build-package -Compiles your project for compatibility with CommonJS and ES2015 modules. +Compiles your project for compatibility with CommonJS and ES2022 modules. This is useful for building isomorphic npm packages. @@ -75,8 +75,8 @@ skuba build-package # commonjs │ TSFILE: ... # commonjs │ tsc exited with code 0 -# es2015 │ TSFILE: ... -# es2015 │ tsc exited with code 0 +# esm │ TSFILE: ... +# esm │ tsc exited with code 0 # types │ TSFILE: ... # types │ tsc exited with code 0 ``` diff --git a/packages/skuba-dive/tsconfig.json b/packages/skuba-dive/tsconfig.json index fab0cf6f5..adb58f41f 100644 --- a/packages/skuba-dive/tsconfig.json +++ b/packages/skuba-dive/tsconfig.json @@ -3,8 +3,8 @@ "declaration": true, "incremental": true, "lib": ["ES2020"], - "module": "CommonJS", - "moduleResolution": "node", + "module": "Node16", + "moduleResolution": "Node16", "outDir": "lib", "removeComments": false, "target": "ES2020" diff --git a/src/cli/build/assets.int.test.ts b/src/cli/build/assets.int.test.ts index b3570933b..f817f23a2 100644 --- a/src/cli/build/assets.int.test.ts +++ b/src/cli/build/assets.int.test.ts @@ -76,8 +76,8 @@ describe('copyAssetsConcurrently', () => { prefixColor: 'green', }, { - outDir: 'lib-es2015', - name: 'es2015', + outDir: 'lib-esm', + name: 'esm', prefixColor: 'yellow', }, ]); @@ -88,10 +88,10 @@ describe('copyAssetsConcurrently', () => { "lib-commonjs/.vocab/translations.json": "", "lib-commonjs/other.vocab/th.translations.json": "", "lib-commonjs/other.vocab/translations.json": "", - "lib-es2015/.vocab/th.translations.json": "", - "lib-es2015/.vocab/translations.json": "", - "lib-es2015/other.vocab/th.translations.json": "", - "lib-es2015/other.vocab/translations.json": "", + "lib-esm/.vocab/th.translations.json": "", + "lib-esm/.vocab/translations.json": "", + "lib-esm/other.vocab/th.translations.json": "", + "lib-esm/other.vocab/translations.json": "", } `); expect(getStdOut()).toMatchInlineSnapshot(` @@ -99,10 +99,10 @@ describe('copyAssetsConcurrently', () => { commonjs │ Copying .vocab/translations.json commonjs │ Copying other.vocab/th.translations.json commonjs │ Copying other.vocab/translations.json - es2015 │ Copying .vocab/th.translations.json - es2015 │ Copying .vocab/translations.json - es2015 │ Copying other.vocab/th.translations.json - es2015 │ Copying other.vocab/translations.json + esm │ Copying .vocab/th.translations.json + esm │ Copying .vocab/translations.json + esm │ Copying other.vocab/th.translations.json + esm │ Copying other.vocab/translations.json `); }); }); diff --git a/src/cli/buildPackage.ts b/src/cli/buildPackage.ts index 7c9f9d5bd..698f432d0 100644 --- a/src/cli/buildPackage.ts +++ b/src/cli/buildPackage.ts @@ -8,14 +8,14 @@ export const buildPackage = async (args = process.argv.slice(2)) => { [ { command: - 'tsc --module CommonJS --outDir lib-commonjs --project tsconfig.build.json', + 'tsc --module Node16 --outDir lib-commonjs --project tsconfig.build.json', name: 'commonjs', prefixColor: 'green', }, { command: - 'tsc --module ES2015 --outDir lib-es2015 --project tsconfig.build.json', - name: 'es2015', + 'tsc --module ES2022 --outDir lib-esm --project tsconfig.build.json', + name: 'esm', prefixColor: 'yellow', }, { @@ -37,8 +37,8 @@ export const buildPackage = async (args = process.argv.slice(2)) => { prefixColor: 'green', }, { - outDir: 'lib-es2015', - name: 'es2015', + outDir: 'lib-esm', + name: 'esm', prefixColor: 'yellow', }, ]); diff --git a/src/cli/configure/modules/package.test.ts b/src/cli/configure/modules/package.test.ts index a12a7f3f4..373102e39 100644 --- a/src/cli/configure/modules/package.test.ts +++ b/src/cli/configure/modules/package.test.ts @@ -60,7 +60,7 @@ describe('packageModule', () => { ], license: 'UNLICENSED', main: './lib-commonjs/index.js', - module: './lib-es2015/index.js', + module: './lib-esm/index.js', private: false, scripts: { build: 'skuba build-package', @@ -159,7 +159,7 @@ describe('packageModule', () => { files: ['lib', 'something-else'], license: 'UNLICENSED', main: 'lib/commonjs', - module: 'lib/es2015', + module: 'lib/esm', scripts: { build: 'smt build', commit: 'smt commit', @@ -197,7 +197,7 @@ describe('packageModule', () => { ], license: 'UNLICENSED', main: './lib-commonjs/index.js', - module: './lib-es2015/index.js', + module: './lib-esm/index.js', private: false, scripts: { build: 'skuba build-package', diff --git a/src/cli/configure/modules/package.ts b/src/cli/configure/modules/package.ts index 71463c639..21be37659 100644 --- a/src/cli/configure/modules/package.ts +++ b/src/cli/configure/modules/package.ts @@ -103,7 +103,7 @@ export const packageModule = async ({ // Align with the required syntax for package.json#/paths if (outputData.scripts.build === 'skuba build-package') { outputData.main = './lib-commonjs/index.js'; - outputData.module = './lib-es2015/index.js'; + outputData.module = './lib-esm/index.js'; outputData.types = './lib-types/index.d.ts'; } else { outputData.main = './lib/index.js'; diff --git a/template/oss-npm-package/_package.json b/template/oss-npm-package/_package.json index e82d960d0..4dff2d9bd 100644 --- a/template/oss-npm-package/_package.json +++ b/template/oss-npm-package/_package.json @@ -9,7 +9,7 @@ "license": "MIT", "sideEffects": false, "main": "./lib-commonjs/index.js", - "module": "./lib-es2015/index.js", + "module": "./lib-esm/index.js", "types": "./lib-types/index.d.ts", "files": [ "lib*/**/*.d.ts", diff --git a/template/private-npm-package/_package.json b/template/private-npm-package/_package.json index 28b173f7d..bbccdd16f 100644 --- a/template/private-npm-package/_package.json +++ b/template/private-npm-package/_package.json @@ -9,7 +9,7 @@ "license": "UNLICENSED", "sideEffects": false, "main": "./lib-commonjs/index.js", - "module": "./lib-es2015/index.js", + "module": "./lib-esm/index.js", "types": "./lib-types/index.d.ts", "files": [ "lib*/**/*.d.ts", From 693faa544ff41d60dacba79b1547c99d0a2b3e0b Mon Sep 17 00:00:00 2001 From: aurelius0523 Date: Fri, 6 Sep 2024 21:33:06 +0800 Subject: [PATCH 2/4] fix test --- packages/skuba-dive/tsconfig.json | 4 ++-- src/cli/build/assets.int.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/skuba-dive/tsconfig.json b/packages/skuba-dive/tsconfig.json index adb58f41f..fab0cf6f5 100644 --- a/packages/skuba-dive/tsconfig.json +++ b/packages/skuba-dive/tsconfig.json @@ -3,8 +3,8 @@ "declaration": true, "incremental": true, "lib": ["ES2020"], - "module": "Node16", - "moduleResolution": "Node16", + "module": "CommonJS", + "moduleResolution": "node", "outDir": "lib", "removeComments": false, "target": "ES2020" diff --git a/src/cli/build/assets.int.test.ts b/src/cli/build/assets.int.test.ts index f817f23a2..9939cd95a 100644 --- a/src/cli/build/assets.int.test.ts +++ b/src/cli/build/assets.int.test.ts @@ -99,10 +99,10 @@ describe('copyAssetsConcurrently', () => { commonjs │ Copying .vocab/translations.json commonjs │ Copying other.vocab/th.translations.json commonjs │ Copying other.vocab/translations.json - esm │ Copying .vocab/th.translations.json - esm │ Copying .vocab/translations.json - esm │ Copying other.vocab/th.translations.json - esm │ Copying other.vocab/translations.json + esm │ Copying .vocab/th.translations.json + esm │ Copying .vocab/translations.json + esm │ Copying other.vocab/th.translations.json + esm │ Copying other.vocab/translations.json `); }); }); From a47ac48be47e73365fc89ad292fb3c6aee98e13a Mon Sep 17 00:00:00 2001 From: aurelius0523 Date: Fri, 6 Sep 2024 22:38:46 +0800 Subject: [PATCH 3/4] move to node16 --- config/tsconfig.json | 2 +- integration/base/fixable/tsconfig.json | 2 +- integration/base/ok/tsconfig.json | 2 +- integration/base/patch/tsconfig.json | 2 +- integration/base/unfixable/tsconfig.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/tsconfig.json b/config/tsconfig.json index f31eab441..03149d853 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "incremental": true, "isolatedModules": true, - "moduleResolution": "node", + "module": "CommonJS", "resolveJsonModule": true, "noUnusedLocals": false, "noUnusedParameters": false diff --git a/integration/base/fixable/tsconfig.json b/integration/base/fixable/tsconfig.json index abaf52a88..8b11c87d7 100644 --- a/integration/base/fixable/tsconfig.json +++ b/integration/base/fixable/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "node", + "moduleResolution": "Node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/ok/tsconfig.json b/integration/base/ok/tsconfig.json index abaf52a88..8b11c87d7 100644 --- a/integration/base/ok/tsconfig.json +++ b/integration/base/ok/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "node", + "moduleResolution": "Node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/patch/tsconfig.json b/integration/base/patch/tsconfig.json index abaf52a88..8b11c87d7 100644 --- a/integration/base/patch/tsconfig.json +++ b/integration/base/patch/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "node", + "moduleResolution": "Node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/unfixable/tsconfig.json b/integration/base/unfixable/tsconfig.json index abaf52a88..8b11c87d7 100644 --- a/integration/base/unfixable/tsconfig.json +++ b/integration/base/unfixable/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "node", + "moduleResolution": "Node", "outDir": "lib", "skipLibCheck": true }, From bfc9809c631e6b59274c669985e11ee82d3d7847 Mon Sep 17 00:00:00 2001 From: aurelius0523 Date: Fri, 6 Sep 2024 23:04:48 +0800 Subject: [PATCH 4/4] revert --- config/tsconfig.json | 2 +- integration/base/fixable/tsconfig.json | 2 +- integration/base/ok/tsconfig.json | 2 +- integration/base/patch/tsconfig.json | 2 +- integration/base/unfixable/tsconfig.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/tsconfig.json b/config/tsconfig.json index 03149d853..f31eab441 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "incremental": true, "isolatedModules": true, - "module": "CommonJS", + "moduleResolution": "node", "resolveJsonModule": true, "noUnusedLocals": false, "noUnusedParameters": false diff --git a/integration/base/fixable/tsconfig.json b/integration/base/fixable/tsconfig.json index 8b11c87d7..abaf52a88 100644 --- a/integration/base/fixable/tsconfig.json +++ b/integration/base/fixable/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "Node", + "moduleResolution": "node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/ok/tsconfig.json b/integration/base/ok/tsconfig.json index 8b11c87d7..abaf52a88 100644 --- a/integration/base/ok/tsconfig.json +++ b/integration/base/ok/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "Node", + "moduleResolution": "node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/patch/tsconfig.json b/integration/base/patch/tsconfig.json index 8b11c87d7..abaf52a88 100644 --- a/integration/base/patch/tsconfig.json +++ b/integration/base/patch/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "Node", + "moduleResolution": "node", "outDir": "lib", "skipLibCheck": true }, diff --git a/integration/base/unfixable/tsconfig.json b/integration/base/unfixable/tsconfig.json index 8b11c87d7..abaf52a88 100644 --- a/integration/base/unfixable/tsconfig.json +++ b/integration/base/unfixable/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "incremental": true, - "moduleResolution": "Node", + "moduleResolution": "node", "outDir": "lib", "skipLibCheck": true },