[x] I have checked the open Issues to see if this has already been raised
[x] I have searched the closed Issues to see if a similar bug has been fixed in the past
Description
This bug affects:
[ ] GitHub workflows
[x] Component
[ ] Config
[ ] Performance
[ ] Tooling / Frameworks
[ ] Documentation
[x] Something else
Steps to Reproduce
Have a project with date-fns 3.x installed
Install Canopy 11.14.1
Import and use beforeDateValidator or afterDateValidator on a form control with a null/undefined value. (i.e. make it so that control.value === null)
Run the app
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:
[x] Occurs every time
[ ] Occurs intermittently
[ ] Unsure
Package version
[ ] This problem started happening recently
[ ] This problem started happening a while ago
[x] Unsure
Configuration and environment
[x] This pertains to local development
[x] 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.
Prerequisites
Description
This bug affects:
Steps to Reproduce
date-fns
3.x installedbeforeDateValidator
orafterDateValidator
on a form control with anull
/undefined
value. (i.e. make it so thatcontrol.value
===null
)TypeError: Cannot read properties of null (reading 'split')
forparseISO
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:
Package version
Configuration and environment
Additional Information
I think the solution may be to move
date-fns
frompeerDependencies
inprojects/canopy/package.json
todependencies
. Having tried this change locally, when runningnpm run build
, I get this error/warning: