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/src/cli/build/assets.int.test.ts b/src/cli/build/assets.int.test.ts index b3570933b..9939cd95a 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",