metonym / svelte-time

Svelte component and action to format a timestamp using day.js
https://metonym.github.io/svelte-time
MIT License
137 stars 8 forks source link

Cannot read properties of undefined (reading '$i') #26

Open hsb-tonmoy opened 1 year ago

hsb-tonmoy commented 1 year ago

I'm using the latest release of Sveltekit and I've installed svelte-time as a dev dependency. I'm getting this error at the most basic usage of the module:

<Time relative timestamp="2020-02-01" />

500

Cannot read properties of undefined (reading '$i')

TypeError: Cannot read properties of undefined (reading '$i')
    at Function.w.extend (\node_modules\.pnpm\dayjs@1.11.5\node_modules\dayjs\dayjs.min.js:1:6457)
    at /node_modules/.pnpm/svelte-time@0.7.1/node_modules/svelte-time/src/dayjs.js:1:26
    at async instantiateModule (/node_modules/.pnpm/vite@3.1.0-beta.2/node_modules/vite/dist/node/chunks/dep-d66eb979.js:53333:9
harvanchik commented 1 year ago

I also receive this error, and it's inconsistent. The app works fine for a few minutes, but then it suddenly breaks later when nothing changed regarding the Time.

harvanchik commented 1 year ago
9:58:22 AM [vite-plugin-svelte] ssr compile in progress ...
Internal server error: Cannot read properties of undefined (reading '$i')
      at Function.w.extend (C:\Users\Me\Websites\case-play\node_modules\.pnpm\dayjs@1.11.7\node_modules\dayjs\dayjs.min.js:1:6557)
      at eval (/node_modules/.pnpm/svelte-time@0.7.1/node_modules/svelte-time/src/dayjs.js:8:31)
      at async instantiateModule (file:///C:/Users/Me/Websites/case-play/node_modules/.pnpm/vite@4.1.1/node_modules/vite/dist/node/chunks/dep-3007b26d.js:52400:9)
TypeError: Cannot read properties of undefined (reading '$i')
    at Function.w.extend (C:\Users\Me\Websites\case-play\node_modules\.pnpm\dayjs@1.11.7\node_modules\dayjs\dayjs.min.js:1:6557)
    at /node_modules/.pnpm/svelte-time@0.7.1/node_modules/svelte-time/src/dayjs.js:4:7
    at async instantiateModule (file:///C:/Users/Me/Websites/case-play/node_modules/.pnpm/vite@4.1.1/node_modules/vite/dist/node/chunks/dep-3007b26d.js:52400:9)
9:58:23 AM [vite-plugin-svelte] ssr compile done.
saturnonearth commented 1 year ago

Any updates?

metonym commented 1 year ago

Could you provide a repo containing a minimal reproduction of the issue? Happy to take a look.

saturnonearth commented 1 year ago

It has something to do with the dayjs not being optimized on build. I could not replicate this in a Stackblitz. I fixed it buy manually installing dayjs as a dependency.

metonym commented 1 year ago

It has something to do with the dayjs not being optimized on build.

Interesting – are you also using pnpm like the OP? It might be worth specifying the docs that pnpm users must also install dayjs .

saturnonearth commented 1 year ago

It has something to do with the dayjs not being optimized on build.

Interesting – are you also using pnpm like the OP? It might be worth specifying the docs that pnpm users must also install dayjs .

Yes I am using pnpm