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

Possible temp solution for dayjs import #61

Open
Its-Just-Nans opened this issue Aug 29, 2022 · 1 comment
Open

Possible temp solution for dayjs import #61

Its-Just-Nans opened this issue Aug 29, 2022 · 1 comment

Comments

@Its-Just-Nans
Copy link

Its-Just-Nans commented Aug 29, 2022

Hello,
Here is a solution to using this library with vitejs as a bundler
working with "vite": "^3.0.7"

Step by step

install @rollup/plugin-replace

npm install @rollup/plugin-replace

change your vite.config.js

import { defineConfig } from "vite";
import relace from "@rollup/plugin-replace";
import { svelte } from "@sveltejs/vite-plugin-svelte";

export default defineConfig({
    plugins: [
        relace({
            preventAssignment: true,
            values: {
                "from 'dayjs": "from 'dayjs/esm",
            },
        }),
        svelte(),
    ],
});

Now you can use the DatePicker

<script>
import DatePicker from "@beyonk/svelte-datepicker/src/components/DatePicker.svelte";
</script>
@antony
Copy link
Member

antony commented Apr 10, 2023

The issue with using dayjs/esm is that it breaks in SSR mode. It's a complex problem to fix.

Where have you experienced this failing?

My thoughts at the moment are to rip out dayjs entirely and use date-fns, since I think dayjs has a fair amount of esm issues.

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

2 participants