From be696a931ae7d87e4cd9717de4db5eb3f19dd661 Mon Sep 17 00:00:00 2001 From: Tristan Menzel Date: Thu, 8 Feb 2024 17:22:01 -0800 Subject: [PATCH] build: Use commonjs by default in package for better backward compatibility --- package.json | 4 ++-- rollup.config.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4c3214e..4dc743c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "engines": { "node": ">=19.0" }, - "type": "module", + "type": "commonjs", "scripts": { "audit": "better-npm-audit audit", "dev": "run-s dev:*", @@ -26,7 +26,7 @@ "build:2-lint": "eslint \"src/**/*.ts\" \"examples/**/*.spec.ts\" --max-warnings 0", "build:3-check-types": "tsc -p tsconfig.json", "build:4-build": "rollup -c --configPlugin typescript", - "build:5-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --input-folder ./ --output-folder ./dist --main index.cjs --types index.d.ts --custom-sections module type ", + "build:5-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json --input-folder ./ --output-folder ./dist --main index.js --types index.d.ts --custom-sections module type ", "build:6-copy-bin": "copyfiles bin/* dist/bin -f", "build:7-copy-readme": "copyfiles ./README.md ./dist", "format": "prettier --write .", diff --git a/rollup.config.ts b/rollup.config.ts index 68eb989..7242b1e 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -9,9 +9,10 @@ const config: RollupOptions = { { dir: 'dist', format: 'cjs', - entryFileNames: '[name].cjs', + entryFileNames: '[name].js', exports: 'named', preserveModules: true, + sourcemap: true, }, { dir: 'dist', @@ -19,6 +20,7 @@ const config: RollupOptions = { exports: 'named', entryFileNames: '[name].mjs', preserveModules: true, + sourcemap: true, }, ], treeshake: {