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

Can't import date-fns format #10098

Open
GeorchW opened this issue Feb 28, 2025 · 0 comments
Open

Can't import date-fns format #10098

GeorchW opened this issue Feb 28, 2025 · 0 comments

Comments

@GeorchW
Copy link

GeorchW commented Feb 28, 2025

I think this is very similar to #9676, but I'm not 100% sure if it's the same (different error message, different versions etc) and I want to make a clean issue with a simple reproduction.

🐛 bug report

// test.js
import { format } from "date-fns";
format(new Date(), "dd.MM.yyyy");

Building this in watch mode with parcel test.js works, but running parcel build test.js will result in this error:

@parcel/core: node_modules/date-fns/index.js does not export 'format'

  test.js:1:10
  > 1 | import { format } from "date-fns";
  >   |          ^^^^^^
    2 | format(new Date(), "dd.MM.yyyy");

Adding --no-scope-hoist makes it work again, but that's quite a big thing.

🎛 Configuration (.babelrc, package.json, cli command)

Here's the package.json:

{
  "dependencies": {
    "date-fns": "^4.1.0",
    "parcel": "^2.13.3"
  },
  "type": "module"
}

🔦 Context

I've recently upgraded react-datepicker, which depends on date-fns. This issue is breaking the build for me, and I can't easily replace react-datepicker right now.

The --no-scope-hoist fix is not really an option I'd say. For now, I can hold back the upgrade, but if I don't find another solution, I might need to switch to another bundler -- at least for production.

🌍 Your Environment

Software Version(s)
Parcel 2.13.3
Node 20.18.3
npm/Yarn yarn 1.22.19
Operating System Ubuntu
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

1 participant