0
Answered

Hebcal core on react app not working

davidamiga14 8 months ago updated 5 days ago 10

Hi

I tried using the @hebcal/core library on a react project, but it gives me this error when launching the app


./node_modules/@hebcal/core/dist/index.mjs 6243:10
Module parse failed: Unexpected token (6243:10)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| * @private
| */
> latitude;
| /**
| * @private

Can someone help me with this?

Thanks

Answer

Answer
Answered

By the way, we can get your app to work just fine if you make the following changes:

index 64e508a..db6d809 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
     "@capacitor/device": "^5.0.0",
     "@capacitor/ios": "^5.0.0",
     "@capacitor/network": "^5.0.0",
-    "@hebcal/core": "^5.3.3",
+    "@hebcal/core": "^5.8.6",
+    "@hebcal/locales": "^6.0.1",
     "@ionic-native/core": "^5.36.0",
     "@ionic-native/geolocation": "^5.36.0",
     "@ionic/react": "^5.5.0",
diff --git a/src/components/Cal.jsx b/src/components/Cal.jsx
index 0529921..09204b7 100644
--- a/src/components/Cal.jsx
+++ b/src/components/Cal.jsx
@@ -4,7 +4,7 @@ import React, { useEffect, useState, useLayoutEffect } from 'react'
 import { IonText, IonIcon, IonButton, IonPopover, useIonViewWillEnter, IonPage, IonContent } from '@ionic/react';
 import { chevronBackOutline, chevronForwardOutline } from "ionicons/icons"
 import { HebrewCalendar, Location, GeoLocation, Zmanim, HDate } from '@hebcal/core';
-// import '@hebcal/locales';
+import '@hebcal/locales';
 import axios from 'axios'
 import add from 'date-fns/add'
 import sub from 'date-fns/sub'

Please post a link to your code (github repo, codepen, jsfiddle, etc). We can't help much without more details.

The latest release of @hebcal/core is now 5.8.3 - there have been many changes in the past 8 months. You also might try simply refreshing your dependencies.

Hi
were you able to look into this?

hi, your package.json file says Hebcal/core 5.3.3

In our previous message we pointed out that this dependency is more than 8 months out of date.

Please try updating to a newer version of Hebcal/core? 

I also tried installing the newest version but it still crashes.

If I create a new ioinic app with react then the new version of Hebcal works, but I can't get it to work on my existing project

Sorry to hear that. We can't help much when you just keep saying "it crashes" but you don't post detailed log messages. Your repo still shows you using an old version of Hebcal/core so it's especially hard for us to help you isolate your problem. Are you really sure you updated to a new version of our library?

The fact that you can get it to work fine with the latest version of our library in a new app suggests that our library is working just fine.  Perhaps the problem is with your existing app and not with Hebcal?

Answer
Answered

By the way, we can get your app to work just fine if you make the following changes:

index 64e508a..db6d809 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
     "@capacitor/device": "^5.0.0",
     "@capacitor/ios": "^5.0.0",
     "@capacitor/network": "^5.0.0",
-    "@hebcal/core": "^5.3.3",
+    "@hebcal/core": "^5.8.6",
+    "@hebcal/locales": "^6.0.1",
     "@ionic-native/core": "^5.36.0",
     "@ionic-native/geolocation": "^5.36.0",
     "@ionic/react": "^5.5.0",
diff --git a/src/components/Cal.jsx b/src/components/Cal.jsx
index 0529921..09204b7 100644
--- a/src/components/Cal.jsx
+++ b/src/components/Cal.jsx
@@ -4,7 +4,7 @@ import React, { useEffect, useState, useLayoutEffect } from 'react'
 import { IonText, IonIcon, IonButton, IonPopover, useIonViewWillEnter, IonPage, IonContent } from '@ionic/react';
 import { chevronBackOutline, chevronForwardOutline } from "ionicons/icons"
 import { HebrewCalendar, Location, GeoLocation, Zmanim, HDate } from '@hebcal/core';
-// import '@hebcal/locales';
+import '@hebcal/locales';
 import axios from 'axios'
 import add from 'date-fns/add'
 import sub from 'date-fns/sub'

Thank you so much!

So saved me hours of recoding my entire app

I also tried installing the newest version but it still crashes

Here is my code. Check the Cal.jsx component, thats where I wan to use the library, but just importing it gives me that error
https://github.com/damiga14/CalFront

Under review

Looks like an issue with you using an older version of Node.js


Try using @hebcal/core version 5.3.3 and see if that fixes the problem for you?

https://github.com/hebcal/hebcal-es6/releases/tag/v5.3.3

Hi
I was using that version, but now I'm getting this error

./node_modules/@hebcal/noaa/dist/index.mjs
Attempted import error: 'Temporal' is not exported from 'temporal-polyfill'.