Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: esm first #365

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
}
}
]
],
"plugins": [
"@babel/plugin-syntax-import-attributes"
]
}
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6"
"target": "NodeNext"
},
"exclude": ["node_modules"]
}
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
"Danny Sadinoff (https://github.com/dsadinoff)"
"Danny Sadinoff (https://github.com/dsadinoff)",
"Benny Powers (https://github.com/bennypowers)"
],
"keywords": [
"hebcal",
Expand All @@ -20,11 +21,16 @@
"zmanim"
],
"description": "A perpetual Jewish Calendar API",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"type": "module",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"typings": "hebcal.d.ts",
"engines": {
"node": ">= 16.0.0"
"node": ">= 20.0.0"
},
"repository": {
"type": "git",
Expand All @@ -42,7 +48,7 @@
"build:rollup": "rollup -c",
"build": "npm run po2json && npm run build:rollup",
"prepublish": "npm run build",
"po2json": "node ./po2json.js po/*.po",
"po2json": "node ./po2json.cjs po/*.po",
"readme": "npx -p jsdoc-to-markdown jsdoc2md dist/index.js",
"pretest": "npm run build",
"lint": "eslint src",
Expand Down
File renamed without changes.
21 changes: 11 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const {nodeResolve} = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const babel = require('@rollup/plugin-babel');
const json = require('@rollup/plugin-json');
const terser = require('@rollup/plugin-terser');
const pkg = require('./package.json');
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
import MANIFEST from './package.json' with { type: 'json' };
const {name, version, main, module} = MANIFEST;

const banner = '/*! ' + pkg.name + ' v' + pkg.version + ' */';
const banner = `/*! ${name} v${version} */`;

const TARGET_NODE_VER = '16.0.0';
const TARGETS_BROWSER = {
Expand All @@ -15,11 +16,11 @@ const TARGETS_BROWSER = {
safari: '15.6',
};

module.exports = [
export default [
{
input: 'src/index.js',
output: [
{file: pkg.main, format: 'cjs', name: pkg.name, banner,
{file: main, format: 'cjs', name, banner,
inlineDynamicImports: true,
globals: {
'temporal-polyfill': 'Temporal',
Expand Down Expand Up @@ -48,7 +49,7 @@ module.exports = [
{
input: 'src/index.js',
output: [
{file: pkg.module, format: 'es', name: pkg.name, banner,
{file: module, format: 'es', name, banner,
inlineDynamicImports: true,
globals: {
'temporal-polyfill': 'Temporal',
Expand Down
8 changes: 4 additions & 4 deletions src/HebrewDateEvent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Event, flags} from './event';
import {months} from './hdate';
import {gematriya} from './gematriya';
import {Locale} from './locale';
import {Event, flags} from './event.js';
import {months} from './hdate.js';
import {gematriya} from './gematriya.js';
import {Locale} from './locale.js';

/** Daily Hebrew date ("11th of Sivan, 5780") */
export class HebrewDateEvent extends Event {
Expand Down
6 changes: 3 additions & 3 deletions src/HebrewDateEvent.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import {HDate} from './hdate';
import {HebrewDateEvent} from './HebrewDateEvent';
import './locale-he';
import {HDate} from './hdate.js';
import {HebrewDateEvent} from './HebrewDateEvent.js';
import './locale-he.js';

test('render', (t) => {
const elul29 = new HDate(29, 'Elul', 5779);
Expand Down
4 changes: 2 additions & 2 deletions src/ParshaEvent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Locale} from './locale';
import {Event, flags} from './event';
import {Locale} from './locale.js';
import {Event, flags} from './event.js';

/**
* Represents one of 54 weekly Torah portions, always on a Saturday
Expand Down
8 changes: 4 additions & 4 deletions src/ParshaEvent.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';
import {HDate} from './hdate';
import {Locale} from './locale';
import {ParshaEvent} from './ParshaEvent';
import './locale-he';
import {HDate} from './hdate.js';
import {Locale} from './locale.js';
import {ParshaEvent} from './ParshaEvent.js';
import './locale-he.js';

test('ParshaEvent-url', (t) => {
const ev1 = new ParshaEvent(new HDate(new Date(2020, 4, 16)), ['Behar', 'Bechukotai'], false, [32, 33]);
Expand Down
4 changes: 2 additions & 2 deletions src/anniversary.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import test from 'ava';
import {HDate} from './hdate';
import {HebrewCalendar} from './hebcal';
import {HDate} from './hdate.js';
import {HebrewCalendar} from './hebcal.js';

test('yahrzeit', (t) => {
// Gregorian YYYY, MM, DD
Expand Down
6 changes: 3 additions & 3 deletions src/candles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import {Locale} from './locale';
import {flags, Event} from './event';
import {Zmanim} from './zmanim';
import {Locale} from './locale.js';
import {flags, Event} from './event.js';
import {Zmanim} from './zmanim.js';
import {months} from '@hebcal/hdate';

const days = {
Expand Down
14 changes: 7 additions & 7 deletions src/candles.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test from 'ava';
import {Location} from './location';
import {Location} from './location.js';
import {makeCandleEvent, CandleLightingEvent, HavdalahEvent, TimedEvent,
makeFastStartEnd} from './candles';
import {HolidayEvent} from './holidays';
import {HDate} from './hdate';
import {flags} from './event';
import {HebrewCalendar} from './hebcal';
import {Zmanim} from './zmanim';
makeFastStartEnd} from './candles.js';
import {HolidayEvent} from './holidays.js';
import {HDate} from './hdate.js';
import {flags} from './event.js';
import {HebrewCalendar} from './hebcal.js';
import {Zmanim} from './zmanim.js';

// eslint-disable-next-line require-jsdoc
function eventDateDesc(ev) {
Expand Down
2 changes: 1 addition & 1 deletion src/event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Locale} from './locale';
import {Locale} from './locale.js';

/**
* Holiday flags for Event
Expand Down
4 changes: 2 additions & 2 deletions src/event.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import {HDate} from './hdate';
import {Event, flags} from './event';
import {HDate} from './hdate.js';
import {Event, flags} from './event.js';

const hd = new HDate(23, 'Sivan', 5735);
const ev = new Event(hd, 'Foo Bar', flags.USER_EVENT | flags.CHUL_ONLY, {quux: 123});
Expand Down
2 changes: 1 addition & 1 deletion src/gematriya.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import {gematriya, gematriyaStrToNum} from './gematriya';
import {gematriya, gematriyaStrToNum} from './gematriya.js';

test('gematriya', (t) => {
t.is(gematriya(5749), 'תשמ״ט');
Expand Down
2 changes: 1 addition & 1 deletion src/getTimezoneOffset.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import {getPseudoISO} from './getTimezoneOffset';
import {getPseudoISO} from './getTimezoneOffset.js';

test('getPseudoISO-2021', (t) => {
const dt = new Date(Date.UTC(2021, 0, 31, 7, 30, 50, 551));
Expand Down
4 changes: 2 additions & 2 deletions src/hallel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {flags} from './event';
import {months} from './hdate';
import {flags} from './event.js';
import {months} from './hdate.js';

const NONE = 0;
const HALF = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/hallel.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import {HDate, months} from './hdate';
import {HebrewCalendar} from './hebcal';
import {hallel_} from './hallel';
import {HDate, months} from './hdate.js';
import {HebrewCalendar} from './hebcal.js';
import {hallel_} from './hallel.js';

test('hallel', (t) => {
const ev1 = HebrewCalendar.getHolidaysForYearArray(5781, false);
Expand Down
18 changes: 9 additions & 9 deletions src/hdate-index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export {gematriya} from './gematriya';
import {greg} from '@hebcal/hdate';
export {greg};
import {Locale} from './locale';
export {gematriya} from './gematriya.js';
export {greg} from '@hebcal/hdate';
import {Locale} from './locale.js';
export {Locale};
export {HDate, months} from './hdate';
export {getYahrzeit_ as getYahrzeit} from './anniversary';
export {getBirthdayOrAnniversary_ as getBirthdayOrAnniversary} from './anniversary';
export {version} from '../package.json';
export {HDate, months} from './hdate.js';
export {getYahrzeit_ as getYahrzeit} from './anniversary.js';
export {getBirthdayOrAnniversary_ as getBirthdayOrAnniversary} from './anniversary.js';
import manifest from '../package.json' with { type: 'json' };
export const {version} = manifest;

import poHeMin from './he.min.po.json';
import poHeMin from './he.min.po.json' with { type: 'json' };
Locale.addLocale('he', poHeMin);
Locale.addLocale('h', poHeMin);

Expand Down
6 changes: 3 additions & 3 deletions src/hdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import {greg, abs2hebrew, daysInMonth, daysInYear, getMonthName,
hebrew2abs, isLeapYear, longCheshvan, months, monthFromName,
monthsInYear, shortKislev} from '@hebcal/hdate';
import {gematriya, gematriyaStrToNum} from './gematriya';
import {Locale} from './locale';
import {throwTypeError} from './throwTypeError';
import {gematriya, gematriyaStrToNum} from './gematriya.js';
import {Locale} from './locale.js';
import {throwTypeError} from './throwTypeError.js';
export {months};

// eslint-disable-next-line require-jsdoc
Expand Down
6 changes: 3 additions & 3 deletions src/hdate.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import {HDate, months} from './hdate';
import './locale-he';
import './locale-ashkenazi';
import {HDate, months} from './hdate.js';
import './locale-he.js';
import './locale-ashkenazi.js';

const NISAN = months.NISAN;
const IYYAR = months.IYYAR;
Expand Down
35 changes: 18 additions & 17 deletions src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Locale} from './locale';
import {HDate, months} from './hdate';
import {HebrewDateEvent} from './HebrewDateEvent';
import {MoladEvent} from './molad';
import {HolidayEvent, getHolidaysForYear_, getSedra_} from './holidays';
import {flags} from './event';
import {OmerEvent} from './omer';
import {ParshaEvent} from './ParshaEvent';
import {Locale} from './locale.js';
import {HDate, months} from './hdate.js';
import {HebrewDateEvent} from './HebrewDateEvent.js';
import {MoladEvent} from './molad.js';
import {HolidayEvent, getHolidaysForYear_, getSedra_} from './holidays.js';
import {flags} from './event.js';
import {OmerEvent} from './omer.js';
import {ParshaEvent} from './ParshaEvent.js';
import {greg, getYahrzeitHD, getBirthdayHD} from '@hebcal/hdate';
import {DailyLearning} from './DailyLearning';
import {Location} from './location';
import {DailyLearning} from './DailyLearning.js';
import {Location} from './location.js';
import {makeCandleEvent, HavdalahEvent, makeFastStartEnd,
makeWeekdayChanukahCandleLighting} from './candles';
import {version as pkgVersion} from '../package.json';
import './locale-ashkenazi';
import './locale-he';
import {Zmanim} from './zmanim';
import {hallel_} from './hallel';
import {tachanun_} from './tachanun';
makeWeekdayChanukahCandleLighting} from './candles.js';
import manifest from '../package.json' with { type: 'json' };
const {version: pkgVersion} = manifest;
import './locale-ashkenazi.js';
import './locale-he.js';
import {Zmanim} from './zmanim.js';
import {hallel_} from './hallel.js';
import {tachanun_} from './tachanun.js';

const FRI = 5;
const SAT = 6;
Expand Down
8 changes: 4 additions & 4 deletions src/hebcal.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';
import {HebrewCalendar, getStartAndEnd} from './hebcal';
import {HDate, months} from './hdate';
import {flags} from './event';
import {Location} from './location';
import {HebrewCalendar, getStartAndEnd} from './hebcal.js';
import {HDate, months} from './hdate.js';
import {flags} from './event.js';
import {Location} from './location.js';

/**
* @param {Event} ev
Expand Down
14 changes: 7 additions & 7 deletions src/holidays.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {Locale} from './locale';
import {HDate, months} from './hdate';
import {Event, flags} from './event';
import {MoladEvent} from './molad';
import {Sedra} from './sedra';
import {dateYomHaZikaron, dateYomHaShoah} from './modern';
import {staticHolidays, staticModernHolidays} from './staticHolidays';
import {Locale} from './locale.js';
import {HDate, months} from './hdate.js';
import {Event, flags} from './event.js';
import {MoladEvent} from './molad.js';
import {Sedra} from './sedra.js';
import {dateYomHaZikaron, dateYomHaShoah} from './modern.js';
import {staticHolidays, staticModernHolidays} from './staticHolidays.js';

/** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
export class HolidayEvent extends Event {
Expand Down
8 changes: 4 additions & 4 deletions src/holidays.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';
import {HolidayEvent, RoshChodeshEvent, MevarchimChodeshEvent} from './holidays';
import {HebrewCalendar} from './hebcal';
import {HDate, months} from './hdate';
import {flags, Event} from './event';
import {HolidayEvent, RoshChodeshEvent, MevarchimChodeshEvent} from './holidays.js';
import {HebrewCalendar} from './hebcal.js';
import {HDate, months} from './hdate.js';
import {flags, Event} from './event.js';

test('basename-and-url', (t) => {
const ev = new HolidayEvent(new HDate(18, months.NISAN, 5763),
Expand Down
Loading