Skip to content

feat(elements): Update exports and prep for public builds#2676

Merged
LekoArts merged 15 commits into
mainfrom
tm.elements/react-components
Jan 30, 2024
Merged

feat(elements): Update exports and prep for public builds#2676
LekoArts merged 15 commits into
mainfrom
tm.elements/react-components

Conversation

@tmilewski

@tmilewski tmilewski commented Jan 29, 2024

Copy link
Copy Markdown
Member

Description

95% of this PR is simply moving components out of single index.tsx files and updating imports and the specific imported component names.

Adding comments to call-out specific points of interest.

  • Splits out components into their respective files from one large index.tsx.
  • Enable export subpaths for:
    • /common
    • /sign-in
    • /sign-up
  • Enable the ability to publish builds.
  • Rename component exports to better handle the case where we don't want to use import * as ___ from ___
  • Adds analysis capabilites via npm run build:analyze

Components can now be imported into applications using the following structures:

import { GlobalError, Submit } from '@clerk/elements/common';
import { Continue, Factor, SignIn, SocialProvider, Start, Verification } from '@clerk/elements/sign-in';
import * as Clerk from '@clerk/elements/common';
import * as SignIn from '@clerk/elements/sign-in';

Note: Root also maps to SignIn allowing for SignIn.Root rather than SignIn.SignIn

Screenshot 2024-01-29 at 4 40 10 PM

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@tmilewski tmilewski self-assigned this Jan 29, 2024
@changeset-bot

changeset-bot Bot commented Jan 29, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30f98f8

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

"app:e2e": "(cd examples/nextjs && npm run e2e)",
"app:lint": "(cd examples/nextjs && npm run lint)",
"build": "tsup",
"build:analyze": "tsup --metafile; open https://esbuild.github.io/analyze/",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Enables easy analysis of generated packages.

Comment thread packages/elements/src/index.ts Outdated
export { useSignUpFlow, useSignUpFlowSelector } from '~/internals/machines/sign-up/sign-up.context';
export { useSignInFlow, useSignInFlowSelector } from '~/internals/machines/sign-in/sign-in.context';
export { useNextRouter };
throw new Error('Please import specific subpaths instead. See documentation for more details: https://clerk.com/docs/'); // TODO: Add link to docs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As-is, we don't need to make anything available at the top-level of the package.

index: 'src/index.ts',
'react/common/index': 'src/react/common/index.ts',
'react/sign-in/index': 'src/react/sign-in/index.ts',
'react/sign-up/index': 'src/react/sign-up/index.ts',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Create specific entrypoints

"author": "Clerk",
"sideEffects": false,
"exports": {
"./*": {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All React-specific code is contained within dist/react but available at the top-level by default, per previous conversations.

}
: {
className: 'bg-tertiary rounded-sm px-2 py-1 border border-foreground data-[invalid]:border-red-500',
ref: forwardedRef,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

forwardedRef only applies to the non-otp input at this point.

@tmilewski tmilewski changed the title chore(elements): Update imports and prep for public builds chore(elements): Update exports and prep for public builds Jan 29, 2024
"@radix-ui/react-slot": "^1.0.2",
"@statelyai/inspect": "^0.1.0",
"@xstate/react": "^4.0.2",
"clsx": "^2.1.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Wasn't used.

@tmilewski tmilewski force-pushed the tm.elements/react-components branch from cf43412 to e81605b Compare January 29, 2024 21:19
@tmilewski tmilewski changed the title chore(elements): Update exports and prep for public builds feat(elements): Update exports and prep for public builds Jan 29, 2024
@tmilewski

Copy link
Copy Markdown
Member Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @tmilewski - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 1.0.1-snapshot.v59b1e3b
@clerk/chrome-extension 1.0.1-snapshot.v59b1e3b
@clerk/clerk-js 5.0.1-snapshot.v59b1e3b
@clerk/elements 0.0.2-snapshot.v59b1e3b
@clerk/clerk-expo 1.0.1-snapshot.v59b1e3b
@clerk/fastify 1.0.1-snapshot.v59b1e3b
gatsby-plugin-clerk 5.0.1-snapshot.v59b1e3b
@clerk/localizations 2.0.1-snapshot.v59b1e3b
@clerk/nextjs 5.0.1-snapshot.v59b1e3b
@clerk/clerk-react 5.0.1-snapshot.v59b1e3b
@clerk/remix 4.0.1-snapshot.v59b1e3b
@clerk/clerk-sdk-node 5.0.1-snapshot.v59b1e3b
@clerk/shared 2.0.1-snapshot.v59b1e3b
@clerk/themes 2.0.1-snapshot.v59b1e3b
@clerk/types 4.0.1-snapshot.v59b1e3b

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/backend

npm i @clerk/backend@1.0.1-snapshot.v59b1e3b --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.1-snapshot.v59b1e3b --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.0.1-snapshot.v59b1e3b --save-exact

@clerk/elements

npm i @clerk/elements@0.0.2-snapshot.v59b1e3b --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.0.1-snapshot.v59b1e3b --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.1-snapshot.v59b1e3b --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.1-snapshot.v59b1e3b --save-exact

@clerk/localizations

npm i @clerk/localizations@2.0.1-snapshot.v59b1e3b --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.1-snapshot.v59b1e3b --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.1-snapshot.v59b1e3b --save-exact

@clerk/remix

npm i @clerk/remix@4.0.1-snapshot.v59b1e3b --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.1-snapshot.v59b1e3b --save-exact

@clerk/shared

npm i @clerk/shared@2.0.1-snapshot.v59b1e3b --save-exact

@clerk/themes

npm i @clerk/themes@2.0.1-snapshot.v59b1e3b --save-exact

@clerk/types

npm i @clerk/types@4.0.1-snapshot.v59b1e3b --save-exact

Comment thread packages/elements/package.json Outdated
"files": [
"dist"
"dist",
"!dist/metafile-*.json",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Generated for bundle analysis and unable to configure where they're generated. This ensures we don't include them in the resulting package.

@tmilewski tmilewski requested a review from LekoArts January 29, 2024 22:03
}

const Comp = asChild ? Slot : 'button';
const defaultProps = asChild ? {} : { type: 'button' as const };

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

When encapsulated in form elements, buttons without a type default to submit causing issues when hitting enter.

@LekoArts LekoArts enabled auto-merge January 30, 2024 10:52
@LekoArts LekoArts added this pull request to the merge queue Jan 30, 2024
Merged via the queue into main with commit 25a8ff7 Jan 30, 2024
@LekoArts LekoArts deleted the tm.elements/react-components branch January 30, 2024 11:02
@LekoArts LekoArts added this to the @clerk/elements (Alpha) milestone Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants