Skip to content

Commit

Permalink
Remove dependency on Babel, publish as an ES module
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 18, 2023
1 parent a377374 commit c79657a
Show file tree
Hide file tree
Showing 9 changed files with 1,421 additions and 1,270 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A package should not include its node_modules folder in the repo; applications should
node_modules
dist
src/*.po.json
src/*.po.js
17 changes: 0 additions & 17 deletions babel.config.json

This file was deleted.

2,565 changes: 1,389 additions & 1,176 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 15 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"name": "@hebcal/locales",
"version": "5.0.0",
"version": "5.0.1",
"description": "Translations for Hebcal events in multiple languages",
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"type": "module",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hebcal/hebcal-locales.git"
Expand All @@ -15,35 +20,26 @@
},
"homepage": "https://github.com/hebcal/hebcal-locales#readme",
"dependencies": {
"@hebcal/core": "^5.0.0-rc2"
"@hebcal/core": "^5.0.3"
},
"files": [
"dist"
],
"scripts": {
"build:rollup": "rollup -c",
"po2json": "node ./po2json.js po/*.po",
"po2golang": "node ./po2golang.js ../hebcal-es6/po/ashkenazi.po ../hebcal-es6/po/he.po ../hebcal-learning/po/*.po po/*.po",
"po2json": "node ./po2json.cjs po/*.po",
"po2golang": "node ./po2golang.cjs ../hebcal-es6/po/ashkenazi.po ../hebcal-es6/po/he.po ../hebcal-learning/po/*.po po/*.po",
"build": "npm run po2json && npm run build:rollup",
"prepublish": "npm run build",
"test": "ava"
},
"ava": {
"require": [
"@babel/register"
]
},
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@babel/register": "^7.22.15",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-terser": "^0.4.4",
"ava": "^5.3.1",
"eslint": "^8.54.0",
"ava": "^6.0.1",
"eslint": "^8.56.0",
"eslint-config-google": "^0.14.0",
"rollup": "^4.5.1",
"ttag-cli": "^1.10.9"
"rollup": "^4.9.1",
"ttag-cli": "^1.10.10"
}
}
File renamed without changes.
3 changes: 2 additions & 1 deletion po2json.js → po2json.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const parser = require('ttag-cli/dist/src/lib/parser');
const utils = require('ttag-cli/dist/src/lib/utils');

for (const arg of process.argv.slice(2)) {
const outpath = './src/' + path.basename(arg) + '.json';
const outpath = './src/' + path.basename(arg) + '.js';
console.log(`${arg} => ${outpath}`);
writePoFile(arg, outpath, false);
}
Expand All @@ -23,6 +23,7 @@ function writePoFile(inpath, outpath, nostrip) {
}
}
const outstream = fs.createWriteStream(outpath, {flags: 'w'});
outstream.write('export default ');
outstream.write(JSON.stringify(utils.convert2Compact(poData), null, 0));
outstream.end();
}
42 changes: 0 additions & 42 deletions rollup.config.js → rollup.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const babel = require('@rollup/plugin-babel');
const json = require('@rollup/plugin-json');
const terser = require('@rollup/plugin-terser');
const pkg = require('./package.json');
Expand All @@ -13,18 +12,6 @@ module.exports = [
],
plugins: [
json({compact: true, preferConst: true}),
babel({
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {
modules: false,
targets: {
node: '16.0.0',
},
}],
],
exclude: ['node_modules/**'],
}),
],
external: ['@hebcal/core'],
},
Expand All @@ -35,18 +22,6 @@ module.exports = [
],
plugins: [
json({compact: true, preferConst: true}),
babel({
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {
modules: false,
targets: {
node: '16.0.0',
},
}],
],
exclude: ['node_modules/**'],
}),
],
external: ['@hebcal/core'],
},
Expand Down Expand Up @@ -74,23 +49,6 @@ module.exports = [
],
plugins: [
json({compact: true, preferConst: true}),
babel({
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', {
modules: false,
targets: {
chrome: '103',
firefox: '91',
edge: '84',
safari: '15.6',
},
useBuiltIns: 'usage',
corejs: 3,
}],
],
exclude: ['node_modules/**'],
}),
],
external: ['@hebcal/core'],
},
Expand Down
26 changes: 13 additions & 13 deletions src/locale.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable camelcase */
import {Locale} from '@hebcal/core';
import po_de from './de.po.json';
import po_es from './es.po.json';
import po_fi from './fi.po.json';
import po_fr from './fr.po.json';
import po_hu from './hu.po.json';
import po_pl from './pl.po.json';
import po_ru from './ru.po.json';
import po_ro from './ro.po.json';
import po_uk from './uk.po.json';
import po_ashkenazi_litvish from './ashkenazi_litvish.po.json';
import po_ashkenazi_poylish from './ashkenazi_poylish.po.json';
import po_ashkenazi_standard from './ashkenazi_standard.po.json';
import po_ashkenazi_romanian from './ashkenazi_romanian.po.json';
import po_de from './de.po.js';
import po_es from './es.po.js';
import po_fi from './fi.po.js';
import po_fr from './fr.po.js';
import po_hu from './hu.po.js';
import po_pl from './pl.po.js';
import po_ru from './ru.po.js';
import po_ro from './ro.po.js';
import po_uk from './uk.po.js';
import po_ashkenazi_litvish from './ashkenazi_litvish.po.js';
import po_ashkenazi_poylish from './ashkenazi_poylish.po.js';
import po_ashkenazi_standard from './ashkenazi_standard.po.js';
import po_ashkenazi_romanian from './ashkenazi_romanian.po.js';

Locale.addLocale('de', po_de);
Locale.addLocale('es', po_es);
Expand Down
2 changes: 1 addition & 1 deletion src/locale.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import {HebrewCalendar, Location} from '@hebcal/core';
import './locale';
import './locale.js';

test('locale-ru', (t) => {
const options = {year: 2020, month: 4, locale: 'ru'};
Expand Down

0 comments on commit c79657a

Please sign in to comment.