From 4f08d8a2f774e849bf3863c3dd0790ff1575e801 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sun, 8 Dec 2024 15:44:33 -0800 Subject: [PATCH] Repackage without rollup to improve tree-shaking --- package-lock.json | 4 ++-- package.json | 13 +++++++------ rollup.config.cjs | 19 +++++++++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index f457c80..9d319c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hebcal/rest-api", - "version": "6.0.3", + "version": "6.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@hebcal/rest-api", - "version": "6.0.3", + "version": "6.1.0", "license": "BSD-2-Clause", "dependencies": { "@hebcal/core": "^5.8.3", diff --git a/package.json b/package.json index 4d34003..81e4220 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hebcal/rest-api", - "version": "6.0.3", + "version": "6.1.0", "author": "Michael J. Radwin (https://github.com/mjradwin)", "keywords": [ "hebcal" @@ -9,14 +9,15 @@ "engines": { "node": ">= 18.0.0" }, - "module": "./dist/index.mjs", + "module": "./dist/esm/index.js", + "typings": "dist/esm/index.d.ts", "type": "module", - "typings": "./dist/index.d.ts", "exports": { ".": { - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" - } + "import": "./dist/esm/index.js", + "types": "./dist/esm/index.d.ts" + }, + "./dist/esm/*": "./dist/esm/*.js" }, "files": [ "dist" diff --git a/rollup.config.cjs b/rollup.config.cjs index 3162c45..cd3943d 100644 --- a/rollup.config.cjs +++ b/rollup.config.cjs @@ -4,6 +4,7 @@ const json = require('@rollup/plugin-json'); const terser = require('@rollup/plugin-terser'); const typescript = require('@rollup/plugin-typescript'); const pkg = require('./package.json'); +const {defineConfig} = require('rollup'); const banner = '/*! ' + pkg.name + ' v' + pkg.version + ' */'; @@ -30,13 +31,23 @@ const iifeGlobals = { '@hebcal/triennial': 'hebcal__triennial', }; -module.exports = [ +const tsOptions = {rootDir: './src'}; +module.exports = defineConfig([ { input: 'src/index.ts', - output: [{file: pkg.module, format: 'es', name: pkg.name, banner}], + output: [ + { + dir: 'dist/esm', + format: 'es', + preserveModules: true, + preserveModulesRoot: 'src', + name: pkg.name, + banner, + }, + ], plugins: [ json({compact: true, preferConst: true}), - typescript(), + typescript({...tsOptions, outDir: 'dist/esm'}), nodeResolve(), commonjs(), ], @@ -98,4 +109,4 @@ module.exports = [ ], external: [/@hebcal/], }, -]; +]);