Giter Site home page Giter Site logo

Comments (29)

LukasTy avatar LukasTy commented on June 21, 2024 24

The support for date-fns@v3 has been released in versions 6.19.0 and 7.0.0-alpha.8.
Feel free to change the import:

- import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
+ import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';

and use at least version 3.2.0 of the date-fns package.

from mui-x.

jinsley8 avatar jinsley8 commented on June 21, 2024 19

I have a similar issue related to the date-fns v3 import changes.

./node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js:59:0

Module not found: Package path ./_lib/format/longFormatters is not exported from package /app/node_modules/date-fns (see exports field in /app/node_modules/date-fns/package.json)

from mui-x.

flaviendelangle avatar flaviendelangle commented on June 21, 2024 8

We are in good shape to have an update pretty soon 👌

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024 6

No, I don't think that the problem has been tackled, because we still can not successfully support date-fns@v3 at this moment, even with the new Adapter there are importing problems depending on the runtime environment.

from mui-x.

Nefcanto avatar Nefcanto commented on June 21, 2024 6

@LukasTy, my bad. The node_modules was linked to another directory and when I used npm list date-fns it found a mismatch. I had to change it to @mui/x-date-pickers/AdapterDateFnsV3 as you mentioned.

We use jalali to support jalali calendar.

from mui-x.

michelengelen avatar michelengelen commented on June 21, 2024 4

Hey @Studio384
We are currently only supporting date-fns between version 2.25.0 and 2.30.0 which is indicated by this line in the package.json

"date-fns": "^2.25.0",

I am not sure if we are planning to support [email protected] with the new major.
Are there plans to adopt the new major of date-fns @LukasTy?

from mui-x.

michelengelen avatar michelengelen commented on June 21, 2024 4

The opening question seems to have been tackled. Can we close this now @LukasTy?
If this issue is really pressing for you @aemonm feel free to open a separate ticket so we can track this more efficiently! 🙇🏼

from mui-x.

flaviendelangle avatar flaviendelangle commented on June 21, 2024 2

[email protected] was released yesterday so we did not discuss it yet tbh 😆

Looks like we won't be able to support both v2 and v3 because they changes the import strategy.

from mui-x.

vishal-kadmos avatar vishal-kadmos commented on June 21, 2024 2

Observed same issue while updating date-fns to v3.1.0. Looking forward for a fix from community.

from mui-x.

PzYon avatar PzYon commented on June 21, 2024 2

I'm sorry, I missed that. Now it works, thank you very much!

import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFnsV3";
import { de } from "date-fns/locale/de";

export const DemoComponent: React.FC = () => {
  return (
    <LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={de}>
    </LocalizationProvider>
  );
};

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024 1

Looks like we won't be able to support both v2 and v3 because they changes the import strategy.

Have you tested it?
I'm going through the blog post and it seems that they have a fallback of exporting the default. 🤔

from mui-x.

aemonm avatar aemonm commented on June 21, 2024 1

@LukasTy does the alpha version ("https://pkg.csb.dev/mui/mui-x/commit/b12bff5a/@mui/x-date-pickers") address the issue with the longFormatters export not being found by mui?

from mui-x.

PzYon avatar PzYon commented on June 21, 2024 1

Thanks for the update. I tried AdapterDateFnsV3 with following dependencies:

"@mui/x-date-pickers": "6.19.0",
"date-fns": "3.2.0",

and following component:

import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFnsV3";
import de from "date-fns/locale/de";

export const DemoComponent: React.FC = () => {
  return (
    <LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={de}>
    </LocalizationProvider>
  );
};

This now leads to following error:

Type 'typeof import("D:/Repos/engraved/app/node_modules/date-fns/locale/de")' is missing the following properties from type 'Locale': code, formatDistance, formatRelative, localize, and 2 more.

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024 1

@PzYon Please update the date-fns/locale import as well.
date-fns has changed all exports to named ones instead of default in v3.
You can find more information about the different usage at v6 or v7 docs.

from mui-x.

michelengelen avatar michelengelen commented on June 21, 2024

[email protected] was released yesterday so we did not discuss it yet tbh 😆

Oh, I did not check the release date ... I suspected it to be fairly new, since it's just the 3.0.0 version available! :D

from mui-x.

flaviendelangle avatar flaviendelangle commented on June 21, 2024

it seems that they have a fallback of exporting the default.

I spoke too fast then sorry

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

I spoke too fast then sorry

Same here. 🙈
I spoke too soon.
I created a draft PR with all the necessary changes and we also have a problem because the package is now whitelisting exports, hence, the following import: https://github.com/mui/mui-x/pull/11462/files#diff-608b4c43a8da0d50431753876af1e8ba8a104e7d7b71d2aea9b9a597556fd398R46 no longer works. 🙈

from mui-x.

flaviendelangle avatar flaviendelangle commented on June 21, 2024

😬 We may need to ask date-fns maintainer a was to access this variable

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

Hello.
If anyone is eager to experiment with date-fns v3 and is already on v7 alpha of @mui/x-date-pickers, feel free to try out this build: https://pkg.csb.dev/mui/mui-x/commit/b12bff5a/@mui/x-date-pickers (put it instead of your current package version):

- "@mui/x-date-pickers": "^7.0.0-alpha.6",
+ "@mui/x-date-pickers": "https://pkg.csb.dev/mui/mui-x/commit/b12bff5a/@mui/x-date-pickers"

You can find usage instructions here.

from mui-x.

Nefcanto avatar Nefcanto commented on June 21, 2024

For me, I get this error. I run my code inside a docker container:

DockerContainer | /Infra/Infra/node_modules/esbuild/lib/main.js:1651
DockerContainer |   let error = new Error(text);
DockerContainer |               ^
DockerContainer | 
DockerContainer | Error: Build failed with 1 error:
DockerContainer | node_modules/@mui/x-date-pickers/AdapterDateFns/AdapterDateFns.js:59:27: ERROR: [plugin: vite:dep-pre-bundle] Missing "./_lib/format/longFormatters" specifier in "date-fns" package
DockerContainer |     at failureErrorWithLog (/Infra/Infra/node_modules/esbuild/lib/main.js:1651:15)
DockerContainer |     at /Infra/Infra/node_modules/esbuild/lib/main.js:1059:25
DockerContainer |     at /Infra/Infra/node_modules/esbuild/lib/main.js:1527:9
DockerContainer |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
DockerContainer |   errors: [Getter/Setter],
DockerContainer |   warnings: [Getter/Setter]
DockerContainer | }
DockerContainer | 
DockerContainer | Node.js v20.9.0

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

For me, I get this error. I run my code inside a docker container:

Which version of date-fns are you using? 🤔
Did you try the latest (at the moment) v3.0.6?

from mui-x.

ruiaraujo012 avatar ruiaraujo012 commented on June 21, 2024

Same here with the latest version of date-fns

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

Thank you for letting us know about it. 👍

from mui-x.

Nefcanto avatar Nefcanto commented on June 21, 2024

@LukasTy, I'm using 3.0.6. The latest now.

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

does the alpha version ("https://pkg.csb.dev/mui/mui-x/commit/b12bff5a/@mui/x-date-pickers") address the issue with the longFormatters export not being found by mui?

Depends. It does seem to work in our codesandboxes (using react-create-app), but using it within a vite + next app produces the mentioned error.
We'll investigate the possible solutions for that specific problem. 👍

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

Getting back to confirm that there does not seem to be any workaround except for basically copy-pasting the logic in date-fns/_lib/format/longFormatters.
Will ask if they'd be willing to export it or we'll need to look for other options. 🤔

from mui-x.

valourus avatar valourus commented on June 21, 2024

I would also love to see a update to ^3.0.0

from mui-x.

Nefcanto avatar Nefcanto commented on June 21, 2024

@LukasTy, I updated to version 6.19.0 and it worked without changing anything in my code. How could it be?

These are my imports in the main.jsx:

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'
import { AdapterDateFnsJalali } from '@mui/x-date-pickers/AdapterDateFnsJalali'
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'
import { ThemeProvider } from '@mui/material/styles'
import { createTheme } from '@mui/material/styles'
import { BrowserRouter } from 'react-router-dom'
import rtlPlugin from 'stylis-plugin-rtl'
import { CacheProvider } from '@emotion/react'
import createCache from '@emotion/cache'
import { prefixer } from 'stylis'

from mui-x.

LukasTy avatar LukasTy commented on June 21, 2024

@Nefcanto Did you also update to date-fns v3?
If not, then you should not need to make any changes. 👌

Question out of curiosity: what is the reason that you are importing the jalali adapter besides the regular one? 🤔

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.