Skip to content

Commit

Permalink
BREAKING CHANGE: drop CommonJS module
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 8, 2024
1 parent 75cf426 commit 075e0cb
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 94 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export default {
verbose: true,
testEnvironment: 'node',
transformIgnorePatterns: [],
};
94 changes: 49 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"name": "@hebcal/rest-api",
"version": "5.2.0",
"version": "6.0.0",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
],
"description": "Jewish holidays and Hebrew calendar as plain JSON objects and CSV export",
"engines": {
"node": ">= 16.0.0"
"node": ">= 18.0.0"
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"type": "module",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/module.d.ts"
},
"typings": "dist/module.d.ts",
Expand All @@ -29,9 +27,9 @@
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
},
"dependencies": {
"@hebcal/core": "^5.7.1",
"@hebcal/hdate": "^0.11.5",
"@hebcal/leyning": "^8.2.9",
"@hebcal/core": "^5.7.7",
"@hebcal/hdate": "^0.12.0",
"@hebcal/leyning": "^9.0.1",
"@hebcal/triennial": "^5.1.3"
},
"scripts": {
Expand Down Expand Up @@ -60,8 +58,7 @@
"@types/jest": "^29.5.14",
"gts": "^5.3.1",
"jest": "^29.7.0",
"rollup": "^4.24.3",
"rollup-plugin-dts": "^6.1.1",
"rollup": "^4.24.4",
"ts-jest": "^29.2.5",
"typedoc": "^0.26.11",
"typescript": "^5.6.3"
Expand Down
29 changes: 6 additions & 23 deletions rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,26 @@ const commonjs = require('@rollup/plugin-commonjs');
const json = require('@rollup/plugin-json');
const terser = require('@rollup/plugin-terser');
const typescript = require('@rollup/plugin-typescript');
const {dts} = require('rollup-plugin-dts');
const pkg = require('./package.json');

const banner = '/*! ' + pkg.name + ' v' + pkg.version + ' */';

module.exports = [
{
input: 'src/index.ts',
output: [
{file: pkg.main, format: 'cjs', name: pkg.name, banner},
],
output: [{file: pkg.module, format: 'es', name: pkg.name, banner}],
plugins: [
json({compact: true, preferConst: true}),
typescript(),
nodeResolve(),
commonjs(),
],
external: ['@hebcal/core', '@hebcal/leyning', '@hebcal/triennial'],
},
{
input: 'src/index.ts',
output: [
{file: pkg.module, format: 'es', name: pkg.name, banner},
],
plugins: [
json({compact: true, preferConst: true}),
typescript(),
nodeResolve(),
commonjs(),
external: [
'@hebcal/core',
'@hebcal/hdate',
/@hebcal\/leyning/,
'@hebcal/triennial',
],
external: ['@hebcal/core', '@hebcal/leyning', '@hebcal/triennial'],
},
{
input: 'src/index.ts',
Expand Down Expand Up @@ -105,10 +94,4 @@ module.exports = [
],
external: ['@hebcal/core', '@hebcal/leyning'],
},
{
input: 'dist/index.d.ts',
output: [{file: 'dist/module.d.ts', format: 'es'}],
external: ['node:fs'],
plugins: [dts()],
},
];
12 changes: 4 additions & 8 deletions src/classic-rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ import {
version,
} from '@hebcal/core';
import {isoDateString} from '@hebcal/hdate';
import {
AliyotMap,
Leyning,
StringMap,
formatAliyahWithBook,
getLeyningForHoliday,
getLeyningForParshaHaShavua,
} from '@hebcal/leyning';
import {AliyotMap, Leyning, StringMap} from '@hebcal/leyning/dist/esm/types';
import {formatAliyahWithBook} from '@hebcal/leyning/dist/esm/common';
import {getLeyningForParshaHaShavua} from '@hebcal/leyning/dist/esm/leyning';
import {getLeyningForHoliday} from '@hebcal/leyning/dist/esm/getLeyningForHoliday';
import {getTriennialForParshaHaShavua} from '@hebcal/triennial';
import {
RestApiOptions,
Expand Down
6 changes: 2 additions & 4 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
flags,
} from '@hebcal/core';
import {isoDateString} from '@hebcal/hdate';
import {
getLeyningForHoliday,
getLeyningForParshaHaShavua,
} from '@hebcal/leyning';
import {getLeyningForParshaHaShavua} from '@hebcal/leyning/dist/esm/leyning';
import {getLeyningForHoliday} from '@hebcal/leyning/dist/esm/getLeyningForHoliday';
import countryNames0 from './countryNames.json';
import holidayDescription0 from './holidays.json';
import {shortenSedrotUrl} from './shorten';
Expand Down
11 changes: 6 additions & 5 deletions test/common.spec.js → test/common.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {getDownloadFilename, getCalendarTitle, makeTorahMemoText, getEventCategories,
import {RestApiOptions,
getDownloadFilename, getCalendarTitle, makeTorahMemoText, getEventCategories,
getHolidayDescription,
appendIsraelAndTracking, locationToPlainObj, shouldRenderBrief} from '../src/common';
import {HebrewCalendar, Location, Event, HDate, flags, HolidayEvent,
Expand All @@ -8,7 +9,7 @@ import {DafYomiEvent} from '@hebcal/learning';
test('getDownloadFilename', () => {
const location = new Location(38.672294, -90.533239, false, 'America/Chicago',
'Chesterfield, MO 63017', 'US', '63017');
const options = {
const options: RestApiOptions = {
year: 2018,
sedrot: true,
candlelighting: true,
Expand Down Expand Up @@ -50,7 +51,7 @@ test('getDownloadFilename', () => {
test('getCalendarTitle', () => {
const location = new Location(38.672294, -90.533239, false, 'America/Chicago',
'Chesterfield, MO 63017', 'US', '63017');
let options = {
let options: RestApiOptions = {
year: 2018,
sedrot: true,
candlelighting: true,
Expand All @@ -75,7 +76,7 @@ test('getCalendarTitle', () => {
});

test('getCalendarTitle2', () => {
const options = {year: 2017};
const options: RestApiOptions = {year: 2017};
const events = HebrewCalendar.calendar(options);
expect(getCalendarTitle(events, options)).toBe('Hebcal Diaspora 2017');

Expand All @@ -96,7 +97,7 @@ test('getCalendarTitle asciiname', () => {
loc.asciiname = 'Congregacion Ortiz';
loc.admin1 = 'Chihuahua';
loc.population = 2620;
const options = {location: loc, year: 2021};
const options: RestApiOptions = {location: loc, year: 2021};
expect(getCalendarTitle([], options)).toBe('Hebcal Congregación Ortíz 2021');
options.preferAsciiName = true;
expect(getCalendarTitle([], options)).toBe('Hebcal Congregacion Ortiz 2021');
Expand Down

0 comments on commit 075e0cb

Please sign in to comment.