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

fix: date-fns import and esm output for react-core #12

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

connorlindsey
Copy link
Contributor

@connorlindsey connorlindsey commented Jan 16, 2024

  1. Fixes dependencies by moving zustand and date-fns to react-core
  2. Adds babel-plugin-date-fns for compatibility with @knocklabs/react-notification-feed
  3. Updates react-core to output .js files for the esm build and updates the exports to fix an issue with Webpack 5. Before these changes, using the react packages in a CRA app would cause the following error:
BREAKING CHANGE: The request 'date-fns/locale' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

For some background, here's an example of the same issue in React Spring: pmndrs/react-spring#2101

Copy link

linear bot commented Jan 16, 2024

KNO-4992 Fix date-fns/locale import issue

Affects CRA using knocklabs/react

Module not found: Error: Can't resolve 'date-fns/locale' in '/Users/connor/Dev/knock/test/cra-install-test/node_modules/knocklabs/react-core/dist/esm/modules/core/context'
Did you mean 'index.js'?
BREAKING CHANGE: The request 'date-fns/locale' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

react-notification-feed uses "babel-plugin-date-fns"

Copy link

changeset-bot bot commented Jan 16, 2024

🦋 Changeset detected

Latest commit: 1af536b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@knocklabs/react-core Patch
@knocklabs/react Patch
nextjs-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@cjbell cjbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🖖

@connorlindsey connorlindsey merged commit 8988230 into main Jan 16, 2024
@connorlindsey connorlindsey deleted the connor-kno-4992-fix-date-fnslocale-import-issue branch January 16, 2024 21:07
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

Successfully merging this pull request may close these issues.

2 participants