Skip to content

Commit

Permalink
chore(*): Drop default exports
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkl committed Nov 16, 2023
1 parent 5471c7e commit e957eca
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 48 deletions.
16 changes: 16 additions & 0 deletions .changeset/clever-scissors-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@clerk/chrome-extension': major
'@clerk/clerk-js': major
'@clerk/clerk-sdk-node': major
'@clerk/backend': major
'@clerk/clerk-react': major
'@clerk/clerk-expo': major
---

Drop default exports from all packages. Migration guide:
- use `import { Clerk } from '@clerk/backend';`
- use `import { clerkInstance } from '@clerk/clerk-sdk-node';`
- use `import { Clerk } from '@clerk/clerk-sdk-node';`
- use `import { Clerk } from '@clerk/clerk-js';`
- use `import { Clerk } from '@clerk/clerk-js/headless';`
- use `import { IsomorphicClerk } from '@clerk/clerk-react'`
2 changes: 1 addition & 1 deletion packages/backend/src/api/endpoints/InvitationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type GetInvitationListParams = {
* @example
* get all revoked invitations
*
* import Clerk from '@clerk/backend';
* import { Clerk } from '@clerk/backend';
* const clerkClient = Clerk(...)
* await clerkClient.invitations.getInvitationList({ status: 'revoked })
*
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome-extension/src/ClerkProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clerk from '@clerk/clerk-js';
import { Clerk } from '@clerk/clerk-js';
import type { ClerkProp, ClerkProviderProps as ClerkReactProviderProps } from '@clerk/clerk-react';
import { __internal__setErrorThrowerOptions, ClerkProvider as ClerkReactProvider } from '@clerk/clerk-react';
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/chrome-extension/src/singleton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clerk from '@clerk/clerk-js';
import { Clerk } from '@clerk/clerk-js';
import type { ClerkProp } from '@clerk/clerk-react';

import type { TokenCache } from './cache';
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/headless/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clerk from '../dist/types/index.headless';
import { Clerk } from '../dist/types/index.headless';

export default Clerk;
export * from '../dist/types/index.headless';
18 changes: 10 additions & 8 deletions packages/clerk-js/src/core/clerk.redirects.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clerk from './clerk';
import { Clerk } from './clerk';
import type { AuthConfig, DisplayConfig } from './resources/internal';
import { Client, Environment } from './resources/internal';

Expand All @@ -10,13 +10,15 @@ jest.mock('./resources/Client');
jest.mock('./resources/Environment');

// Because Jest, don't ask me why...
jest.mock('./devBrowserHandler', () => () => ({
clear: jest.fn(),
setup: jest.fn(),
getDevBrowserJWT: jest.fn(() => 'deadbeef'),
setDevBrowserJWT: jest.fn(),
removeDevBrowserJWT: jest.fn(),
usesUrlBasedSessionSync: mockUsesUrlBasedSessionSync,
jest.mock('./devBrowserHandler', () => ({
createDevBrowserHandler: () => ({
clear: jest.fn(),
setup: jest.fn(),
getDevBrowserJWT: jest.fn(() => 'deadbeef'),
setDevBrowserJWT: jest.fn(),
removeDevBrowserJWT: jest.fn(),
usesUrlBasedSessionSync: mockUsesUrlBasedSessionSync,
}),
}));

Client.getInstance = jest.fn().mockImplementation(() => {
Expand Down
18 changes: 10 additions & 8 deletions packages/clerk-js/src/core/clerk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ActiveSessionResource, SignInJSON, SignUpJSON, TokenResource } fro
import { waitFor } from '@testing-library/dom';

import { mockNativeRuntime } from '../testUtils';
import Clerk from './clerk';
import { Clerk } from './clerk';
import { eventBus, events } from './events';
import type { AuthConfig, DisplayConfig, Organization } from './resources/internal';
import { BaseResource, Client, EmailLinkErrorCode, Environment, SignIn, SignUp } from './resources/internal';
Expand All @@ -17,13 +17,15 @@ jest.mock('./resources/Client');
jest.mock('./resources/Environment');

// Because Jest, don't ask me why...
jest.mock('./devBrowserHandler', () => () => ({
clear: jest.fn(),
setup: jest.fn(),
getDevBrowserJWT: jest.fn(() => 'deadbeef'),
setDevBrowserJWT: jest.fn(),
removeDevBrowserJWT: jest.fn(),
usesUrlBasedSessionSync: mockUsesUrlBasedSessionSync,
jest.mock('./devBrowserHandler', () => ({
createDevBrowserHandler: () => ({
clear: jest.fn(),
setup: jest.fn(),
getDevBrowserJWT: jest.fn(() => 'deadbeef'),
setDevBrowserJWT: jest.fn(),
removeDevBrowserJWT: jest.fn(),
usesUrlBasedSessionSync: mockUsesUrlBasedSessionSync,
}),
}));

Client.getInstance = jest.fn().mockImplementation(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import {
import { memoizeListenerCallback } from '../utils/memoizeStateListenerCallback';
import { CLERK_SATELLITE_URL, CLERK_SYNCED, ERROR_CODES } from './constants';
import type { DevBrowserHandler } from './devBrowserHandler';
import createDevBrowserHandler from './devBrowserHandler';
import { createDevBrowserHandler } from './devBrowserHandler';
import {
clerkErrorInitFailed,
clerkInvalidSignInUrlFormat,
Expand All @@ -98,7 +98,7 @@ import {
clerkRedirectUrlIsMissingScheme,
} from './errors';
import type { FapiClient, FapiRequestCallback } from './fapiClient';
import createFapiClient from './fapiClient';
import { createFapiClient } from './fapiClient';
import {
BaseResource,
Client,
Expand Down Expand Up @@ -134,7 +134,7 @@ const defaultOptions: ClerkOptions = {
isInterstitial: false,
};

export default class Clerk implements ClerkInterface {
export class Clerk implements ClerkInterface {
public static mountComponentRenderer?: MountComponentRenderer;

public static version: string = __PKG_VERSION__;
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/devBrowserHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CreateDevBrowserHandlerOptions } from './devBrowserHandler';
import createDevBrowserHandler from './devBrowserHandler';
import { createDevBrowserHandler } from './devBrowserHandler';

describe('detBrowserHandler', () => {
const { getDevBrowserJWT, setDevBrowserJWT, removeDevBrowserJWT } = createDevBrowserHandler(
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/devBrowserHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CreateDevBrowserHandlerOptions = {
};

// export type DevBrowserHandler = ReturnType<typeof createDevBrowserHandler>;
export default function createDevBrowserHandler({
export function createDevBrowserHandler({
frontendApi,
fapiClient,
}: CreateDevBrowserHandlerOptions): DevBrowserHandler {
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/fapiClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Clerk } from '@clerk/types';

import createFapiClient from './fapiClient';
import { createFapiClient } from './fapiClient';

const mockedClerkInstance = {
frontendApi: 'clerk.example.com',
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/fapiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface FapiClient {
request<T>(requestInit: FapiRequestInit): Promise<FapiResponse<T>>;
}

export default function createFapiClient(clerkInstance: Clerk): FapiClient {
export function createFapiClient(clerkInstance: Clerk): FapiClient {
const onBeforeRequestCallbacks: Array<FapiRequestCallback<unknown>> = [];
const onAfterResponseCallbacks: Array<FapiRequestCallback<unknown>> = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/resources/internal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { default as Clerk } from '../clerk';
export type { Clerk } from '../clerk';
export * from './Base';
export * from './UserSettings';
export * from './AuthConfig';
Expand Down
3 changes: 1 addition & 2 deletions packages/clerk-js/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import './utils/setWebpackChunkPublicPath';

import 'regenerator-runtime/runtime';

import Clerk from './core/clerk';
import { Clerk } from './core/clerk';

// eslint-disable-next-line import/no-unresolved -- this is a webpack alias
import { mountComponentRenderer } from '~ui/Components';

Clerk.mountComponentRenderer = mountComponentRenderer;
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/index.headless.browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'regenerator-runtime/runtime';

import Clerk from './core/clerk';
import { Clerk } from './core/clerk';

const publishableKey =
document.querySelector('script[data-clerk-publishable-key]')?.getAttribute('data-clerk-publishable-key') ||
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/index.headless.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'regenerator-runtime/runtime';

import Clerk from './core/clerk';
import { Clerk } from './core/clerk';

export * from './core/resources/Error';

export default Clerk;
export { Clerk };

if (module.hot) {
module.hot.accept();
Expand Down
5 changes: 2 additions & 3 deletions packages/clerk-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'regenerator-runtime/runtime';

// eslint-disable-next-line import/no-unresolved -- this is a webpack alias
import { mountComponentRenderer } from '~ui/Components';

import Clerk from './core/clerk';
import { Clerk } from './core/clerk';

export * from './core/resources/Error';

Clerk.mountComponentRenderer = mountComponentRenderer;
export default Clerk;
export { Clerk };

if (module.hot) {
module.hot.accept();
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/utils/test/createFixtures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ClerkOptions, ClientJSON, EnvironmentJSON, LoadedClerk } from '@cl
import { jest } from '@jest/globals';
import React from 'react';

import { default as ClerkCtor } from '../../../core/clerk';
import { Clerk as ClerkCtor } from '../../../core/clerk';
import { Client, Environment } from '../../../core/resources';
import { ComponentContext, CoreClerkContextWrapper, EnvironmentProvider, OptionsProvider } from '../../contexts';
import { AppearanceProvider } from '../../customizables';
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/utils/retrieveCaptchaInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Clerk from '../core/clerk';
import createFapiClient from '../core/fapiClient';
import type { Clerk } from '../core/clerk';
import { createFapiClient } from '../core/fapiClient';

export const retrieveCaptchaInfo = (clerk: Clerk) => {
const _environment = clerk.__unstable__environment;
Expand Down
2 changes: 1 addition & 1 deletion packages/expo/src/singleton.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FapiRequestInit, FapiResponse } from '@clerk/clerk-js/dist/types/core/fapiClient';
import Clerk from '@clerk/clerk-js/headless';
import { Clerk } from '@clerk/clerk-js/headless';
import type { HeadlessBrowserClerk } from '@clerk/clerk-react';

import type { TokenCache } from './cache';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/contexts/ClerkContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ClientResource, InitialState, Resources } from '@clerk/types';
import React from 'react';

import IsomorphicClerk from '../isomorphicClerk';
import { IsomorphicClerk } from '../isomorphicClerk';
import type { IsomorphicClerkOptions } from '../types';
import { deriveState } from '../utils/deriveState';
import { AuthContext } from './AuthContext';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useCallback } from 'react';
import { useAuthContext } from '../contexts/AuthContext';
import { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';
import { invalidStateError } from '../errors';
import type IsomorphicClerk from '../isomorphicClerk';
import type { IsomorphicClerk } from '../isomorphicClerk';
import { errorThrower } from '../utils';
import { createGetToken, createSignOut } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type IsomorphicClerk from '../isomorphicClerk';
import type { IsomorphicClerk } from '../isomorphicClerk';

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type MethodName<T> = {

type MethodCallback = () => Promise<unknown> | unknown;

export default class IsomorphicClerk {
export class IsomorphicClerk {
private readonly mode: 'browser' | 'server';
private readonly publishableKey?: string;
private readonly options: IsomorphicClerkOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ exports[`module exports should not change unless explicitly set 1`] = `
"createIsomorphicRequest",
"debugRequestState",
"decodeJwt",
"default",
"deserialize",
"domains",
"emailAddresses",
Expand Down
2 changes: 0 additions & 2 deletions packages/sdk-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export {
users,
};

export default clerkClient;

export type { ClerkMiddleware, ClerkMiddlewareOptions, LooseAuthProp, RequireAuthProp, StrictAuthProp, WithAuthProp };

export { createClerkExpressRequireAuth, createClerkExpressWithAuth };
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-node/src/instance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Clerk } from './clerkClient';

export default Clerk;
export { Clerk };

export type { WithAuthProp, RequireAuthProp } from './types';

Expand Down

0 comments on commit e957eca

Please sign in to comment.