From ecb7495938a91388ab41838422d409802178b28f Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 8 Mar 2023 03:40:08 +0100 Subject: [PATCH] fix: Set file extensions for package entry files If the package type is CommonJS all `.js` files will be handled as if they are CommonJS, even if exports is set to module. Same if type is set to ESM, then all `.js` files are handled as if they are modules. So the file extension has to be set to the explicit type. Signed-off-by: Ferdinand Thiessen --- package.json | 9 +++++---- rollup.config.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fb89477..d9fe6d8 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,13 @@ "name": "@nextcloud/initial-state", "version": "2.0.0", "description": "Access data from the nextcloud server-side initial state API within apps.", - "main": "dist/index.js", - "module": "dist/index.esm.js", + "type": "module", + "main": "dist/index.cjs", "types": "dist/index.d.ts", "exports": { - "import": "./dist/index.esm.js", - "require": "./dist/index.js" + "import": "./dist/index.es.mjs", + "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" }, "files": [ "dist/" diff --git a/rollup.config.js b/rollup.config.js index f170c65..229af97 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,7 +11,7 @@ export default [ ], output: [ { - dir: 'dist', + file: 'dist/index.cjs', format: 'cjs', sourcemap: true, }, @@ -22,7 +22,7 @@ export default [ plugins: [typescript()], output: [ { - file: 'dist/index.esm.js', + file: 'dist/index.es.mjs', format: 'esm', sourcemap: true, },