From da1c4ee9e41a69de96e867e69e644f18339e45b6 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 2 Oct 2021 23:28:07 -0400 Subject: [PATCH] use pkg.exports; reorganize files --- .gitignore | 3 ++- {types => dist}/index.d.ts | 0 package.json | 18 +++++++++++++----- rollup.config.js | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) rename {types => dist}/index.d.ts (100%) diff --git a/.gitignore b/.gitignore index 74c19c9..bc3561e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/dist/ +/dist/* +!/dist/*.d.ts /node_modules/ /package-lock.json /pnpm-lock.yaml diff --git a/types/index.d.ts b/dist/index.d.ts similarity index 100% rename from types/index.d.ts rename to dist/index.d.ts diff --git a/package.json b/package.json index 495faa1..586c385 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,20 @@ "keywords": [ "cache" ], - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "types": "types/index.d.ts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", "files": [ - "dist", - "types" + "*.md", + "dist" ], "engines": { "node": ">=12" diff --git a/rollup.config.js b/rollup.config.js index 7636b08..846818f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,7 +5,7 @@ export default { external: name => /^[a-z]/.test(name), plugins: [cheap_ts()], output: [ - { file: 'dist/index.cjs.js', format: 'cjs', sourcemap: true, interop: false, preferConst: true }, - { file: 'dist/index.esm.js', format: 'esm', sourcemap: true, preferConst: true }, + { file: './dist/index.cjs', format: 'cjs', sourcemap: true, interop: false, preferConst: true }, + { file: './dist/index.mjs', format: 'esm', sourcemap: true, preferConst: true }, ], };