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

dayjs default import results in error #704

Closed
macmillen opened this issue Mar 26, 2021 · 2 comments
Closed

dayjs default import results in error #704

macmillen opened this issue Mar 26, 2021 · 2 comments

Comments

@macmillen
Copy link

Describe the bug
When using the dayjs library i get an error: __vite_ssr_import_1__.default is not a function

Logs

500
__vite_ssr_import_1__.default is not a function

TypeError: __vite_ssr_import_1__.default is not a function
    at eval (/home/milln/projects/kit-temp/src/routes/index.svelte:11:44)
    at Object.$$render (/home/milln/projects/kit-temp/node_modules/svelte/internal/index.js:1369:22)
    at Object.default (root.svelte:46:46)
    at /home/milln/projects/kit-temp/.svelte/dev/components/layout.svelte:5:41
    at Object.$$render (/home/milln/projects/kit-temp/node_modules/svelte/internal/index.js:1369:22)
    at root.svelte:42:13
    at $$render (/home/milln/projects/kit-temp/node_modules/svelte/internal/index.js:1369:22)
    at Object.render (/home/milln/projects/kit-temp/node_modules/svelte/internal/index.js:1377:26)
    at get_response (file:///home/milln/projects/kit-temp/node_modules/@sveltejs/kit/dist/ssr.js:2326:27)
    at async render_page (file:///home/milln/projects/kit-temp/node_modules/@sveltejs/kit/dist/ssr.js:2440:19)

To Reproduce

// src/routes/index.svelte
<script lang="ts">
    import dayjs from "dayjs";

    const time = dayjs();
</script>

Expected behavior
the default import should work as expected

Severity
medium, i could use a different date library but i found this one is a really small and nice one

Additional context
I don't know if this issue is svelte kit related vite related.
I also turned on "allowSyntheticDefaultImports": true in tsconfig.json

@Conduitry
Copy link
Member

See #699.

@autr
Copy link

autr commented Jul 15, 2021

import dayjsCJS from 'dayjs'
import dayjsESM from 'dayjs/esm'

let dayjs = !dayjsCJS ? dayjsESM : dayjsCJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants