From 2940c18d513ebfe2942e3425d8a574df6915205a Mon Sep 17 00:00:00 2001 From: Valentin Hervieu Date: Wed, 3 Apr 2024 23:23:57 +0200 Subject: [PATCH 1/3] chore: improve package exports --- bili.config.ts | 2 +- scripts/copy-build-files.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bili.config.ts b/bili.config.ts index e3dca62..5f2dae9 100644 --- a/bili.config.ts +++ b/bili.config.ts @@ -23,7 +23,7 @@ const config: Config = { config.output.fileName = 'umd/react-easy-crop[min].js' } if (format === 'esm') { - config.output.fileName = '[name].module.js' + config.output.fileName = '[name].module.mjs' } return config }, diff --git a/scripts/copy-build-files.js b/scripts/copy-build-files.js index 46e96a1..c8c444e 100644 --- a/scripts/copy-build-files.js +++ b/scripts/copy-build-files.js @@ -17,18 +17,18 @@ async function createPackageFile() { jest: undefined, 'lint-staged': undefined, main: './index.js', - 'umd:main': './umd/react-easy-crop.js', - unpkg: './umd/react-easy-crop.js', - jsdelivr: './umd/react-easy-crop.js', - module: './index.module.js', - 'jsnext:main': './index.module.js', - 'react-native': './index.module.js', + module: './index.module.mjs', types: './index.d.ts', exports: { '.': { - import: './index.module.js', - require: './index.js', - types: './index.d.ts', + import: { + types: './index.d.ts', + default: './index.module.mjs', + }, + require: { + types: './index.d.ts', + default: './index.js', + }, }, './react-easy-crop.css': { import: './react-easy-crop.css', @@ -50,6 +50,7 @@ async function run() { { from: './README.md' }, { from: './LICENSE' }, { from: './src/styles.css', to: 'react-easy-crop.css' }, + { from: './dist/index.d.ts', to: './dist/index.module.d.mts' }, ].map((file) => copyFile(file)) ) await createPackageFile() From 82deecfcb8b3a82ff5b31e814abc0f282c01f53a Mon Sep 17 00:00:00 2001 From: Valentin Hervieu Date: Thu, 4 Apr 2024 16:15:41 +0200 Subject: [PATCH 2/3] actually use the mts file --- scripts/copy-build-files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/copy-build-files.js b/scripts/copy-build-files.js index c8c444e..dd6eb6e 100644 --- a/scripts/copy-build-files.js +++ b/scripts/copy-build-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { exports: { '.': { import: { - types: './index.d.ts', + types: './index.d.mts', default: './index.module.mjs', }, require: { From 1aad632c8ecae17844d1cc261c87e74811d03837 Mon Sep 17 00:00:00 2001 From: Valentin Hervieu Date: Thu, 4 Apr 2024 16:41:47 +0200 Subject: [PATCH 3/3] please send help --- scripts/copy-build-files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/copy-build-files.js b/scripts/copy-build-files.js index dd6eb6e..c4831d5 100644 --- a/scripts/copy-build-files.js +++ b/scripts/copy-build-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { exports: { '.': { import: { - types: './index.d.mts', + types: './index.module.d.mts', default: './index.module.mjs', }, require: {