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

Canopy and date-fns #1432

Open
8 of 18 tasks
Xinchro opened this issue Jul 18, 2024 · 0 comments
Open
8 of 18 tasks

Canopy and date-fns #1432

Xinchro opened this issue Jul 18, 2024 · 0 comments

Comments

@Xinchro
Copy link
Contributor

Xinchro commented Jul 18, 2024

Prerequisites

  • I have checked the open Issues to see if this has already been raised
  • I have searched the closed Issues to see if a similar bug has been fixed in the past

Description

This bug affects:

  • GitHub workflows
  • Component
  • Config
  • Performance
  • Tooling / Frameworks
  • Documentation
  • Something else

Steps to Reproduce

  1. Have a project with date-fns 3.x installed
  2. Install Canopy 11.14.1
  3. Import and use beforeDateValidator or afterDateValidator on a form control with a null/undefined value. (i.e. make it so that control.value === null)
  4. Run the app
  5. Note it errors with TypeError: Cannot read properties of null (reading 'split') for parseISO

Expected behaviour:

Canopy should be using its own version of date-fns it relies on to run, when installed, and not the project's version of the dependency.

Actual behaviour:

Canopy uses the project's version of date-fns (3.x, in this case)

Recurrence frequency:

  • Occurs every time
  • Occurs intermittently
  • Unsure

Package version

  • This problem started happening recently
  • This problem started happening a while ago
  • Unsure

Configuration and environment

  • This pertains to local development
  • This pertains to the CI
  • This pertains to Storybook

Additional Information

I think the solution may be to move date-fns from peerDependencies in projects/canopy/package.json to dependencies.
Having tried this change locally, when running npm run build, I get this error/warning:

⚠ Distributing npm packages with 'dependencies' is not recommended. Please consider adding date-fns to 'peerDependencies' or remove it from 'dependencies'.
✖ Writing package manifest
Dependency date-fns must be explicitly allowed using the "allowedNonPeerDependencies" option.
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