knocklabs / javascript

Official JavaScript packages for interacting with Knock
https://knock.app/
MIT License
11 stars 2 forks source link

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

Closed connorlindsey closed 6 months ago

connorlindsey commented 6 months ago
  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: https://github.com/pmndrs/react-spring/pull/2101

linear[bot] commented 6 months ago
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"`

changeset-bot[bot] commented 6 months ago

🦋 Changeset detected

Latest commit: 1af536be44a3b52d588092e4354bd43e2ddcdf4e

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