-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING(shared): Revamp package to use subpaths (#1898)
* chore(shared): Smaller package.json maintenance * chore(repo): Remove testUtils from shared pkg * chore(shared): Update package.json more * chore(shared): Jest cleanup * chore(shared): Move noop to root * chore(shared): Move browser and remove duplicate inClientSide helper * chore(shared): Move method helpers into "underscore" file * chore(shared): Move url to root * chore(shared): Fix jest testRegex * chore(shared): Tsup updates * chore(shared): Move color into single file * chore(shared): Move proxy to root * chore(shared): Move error stuff into error dir * chore(shared): Move date to root * chore(shared): Move keys to root * chore(shared): Move deprecated to root * chore(shared): Move isomorphicAtob to root * chore(shared): Move cookie to folder * chore(shared): Move workerTimers * chore(shared): Move file and remove mimeTypeExtensions * chore(shared): Move cookie and globs * chore(shared): Tsup ignore test files * chore(shared): Move rest of files to root * chore(shared): Re-organize hooks folder * chore(shared): Correct tsup output + exports map * chore(shared): Add minimal README * fix(backend): Update imports * chore(shared): Put error into one file + add react & react/hooks subpath * fix(clerk-js): Update imports * fix(clerk-expo): Updat imports * fix(fastify): Update imports * fix(gatsby): Update imports * fix(next): Update imports * fix(react): Update imports * fix(remix): Update imports * chore(shared): Rename and move multiDomain * fix(sdk-node): Use new imports * update lock file * fix(clerk-js): Adjust webpack config * chore(repo): Make TS compilation work with TS 5 * fix(clerk-sdk-node): Remove incorrect type key in package.json * chore(backend): Fix tests * chore(shared): Provide better backwards comp * Create wild-carrots-reply.md * chore(clerk-js): Typo fix * lol * chore(shared): Use "bundle: true" * chore(repo): Update lock file * chore(shared): Move react/hooks into react * Update wild-carrots-reply.md * fix(shared): Use correct entries for tsup * chore(repo): Add changelog entry * chore(clerk-js): Add comment
- Loading branch information
Showing
164 changed files
with
676 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
"@clerk/shared": major | ||
--- | ||
|
||
The package was reworked to allow for better isomorphic use cases and ESM support, resulting in some breaking changes. It now allows for [subpath exports](https://nodejs.org/api/packages.html#subpath-exports) and restricts some imports to specific subpaths. | ||
|
||
Instead of importing from the root `@clerk/shared` import you can now use subpaths for most things: | ||
|
||
```diff | ||
- import { deprecated, OrganizationProvider } from "@clerk/shared" | ||
+ import { deprecated } from "@clerk/shared/deprecated" | ||
+ import { OrganizationProvider } from "@clerk/shared/react" | ||
``` | ||
|
||
By using subpaths you can tell bundlers to only bundle specific parts, potentially helping with tree-shaking. It also mitigates issues where e.g. modules only relevant for React where picked up in Node.js-only environments. | ||
|
||
If you're not using `@clerk/shared` directly (only by proxy through e.g. `@clerk/clerk-react`) you don't need to do anything. If you are relying on `@clerk/shared`, please read through the breaking changes below and change your code accordingly. You can rely on your IDE to give you hints on which exports are available at `@clerk/shared` and `@clerk/shared/<name>` subpaths. | ||
|
||
**Breaking Changes** | ||
|
||
- `@clerk/shared` was and still is a dual CJS/ESM package. The ESM files provided by `@clerk/shared` now use `.mjs` file extensions and also define them in their import paths, following the ESM spec. Your bundler should handle this for you. | ||
- Some imports where moved from the root `@clerk/shared` import to isolated subpaths. | ||
- Helper utils for cookies and globs: | ||
|
||
```diff | ||
- import { createCookieHandler, globs } from "@clerk/shared" | ||
+ import { createCookieHandler } from "@clerk/shared/cookie" | ||
+ import { globs } from "@clerk/shared/globs" | ||
``` | ||
- Everything related to React. Below is a small example and the full list of exports: | ||
|
||
```diff | ||
- import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared" | ||
+ import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared/react" | ||
``` | ||
|
||
Full list of exports moved to `@clerk/shared/react`: | ||
|
||
```ts | ||
export { | ||
ClerkInstanceContext, | ||
ClientContext, | ||
OrganizationContext, | ||
OrganizationProvider, | ||
SessionContext, | ||
UserContext, | ||
assertContextExists, | ||
createContextAndHook, | ||
useClerkInstanceContext, | ||
useClientContext, | ||
useOrganization, | ||
useOrganizationContext, | ||
useOrganizationList, | ||
useOrganizations, | ||
useSafeLayoutEffect, | ||
useSessionContext, | ||
useUserContext | ||
} | ||
``` | ||
|
||
If you run into an issues that might be a bug, please [open a bug report](https://github.com/clerkinc/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml) with a minimal reproduction. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.