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 CLERK_RETHEME build issue on clerk-js #2127

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/chilly-donuts-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion packages/clerk-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build": "npm run build:bundle && npm run build:declarations",
"build:analyze": "webpack-bundle-analyzer stats.json dist/",
"build:bundle": "npm run clean && webpack --config webpack.config.js --env production",
"build:declarations": "tsc -p tsconfig.declarations.json",
"build:declarations": "if [ \"$CLERK_RETHEME\" = \"true\" ] || [ \"$CLERK_RETHEME\" = \"1\" ]; then tsc -p tsconfig.declarations.retheme.json; else tsc -p tsconfig.declarations.json; fi",
"build:stats": "webpack --config webpack.config.js --env production --json=stats.json --env variant=\"clerk.browser\"",
"bundlewatch": "npx bundlewatch --config bundlewatch.config.json",
"clean": "rimraf ./dist",
Expand Down
3 changes: 2 additions & 1 deletion packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ import type {
UserResource,
} from '@clerk/types';

import type { MountComponentRenderer } from '../ui/Components';
import type { MountComponentRenderer } from '~ui/Components';

import {
appendAsQueryParams,
buildURL,
Expand Down
4 changes: 3 additions & 1 deletion packages/clerk-js/src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import './utils/setWebpackChunkPublicPath';
import 'regenerator-runtime/runtime';

import Clerk from './core/clerk';
import { mountComponentRenderer } from './ui/Components';

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

Clerk.mountComponentRenderer = mountComponentRenderer;

Expand Down
4 changes: 3 additions & 1 deletion packages/clerk-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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 { mountComponentRenderer } from './ui/Components';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import type { ComponentType } from 'react';
import React from 'react';

import { warnings } from '../../core/warnings';
import type { AvailableComponentProps } from '../../ui/types';
import type { ComponentGuard } from '../../utils';
import { noOrganizationExists, noUserExists, sessionExistsAndSingleSessionModeEnabled } from '../../utils';
import { useCoreClerk, useEnvironment, useOptions } from '../contexts';
import { useRouter } from '../router';
import type { AvailableComponentProps } from '../types';

function withRedirectToHome<P extends AvailableComponentProps>(
Component: ComponentType<P>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRouter } from '../../../ui/router';
import { runIfFunctionOrReturn } from '../../../utils';
import { AlertIcon, Flex, Link, Text } from '../../customizables';
import { useRouter } from '../../router';

Copy link
Member

Choose a reason for hiding this comment

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

Now that we have the alias isn't it better to do from '~ui/router' ?

export const BillingWidget = ({
__unstable_manageBillingUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from '../../../ui/router';
import { runIfFunctionOrReturn } from '../../../utils';
import { useCoreOrganization, useOrganizationProfileContext } from '../../contexts';
import { Col, Flex, Link, Text } from '../../customizables';
import { useRouter } from '../../router';

export const MembershipWidget = () => {
const { organization } = useCoreOrganization();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';

import { Plus } from '../../../ui/icons';
import { useCoreUser } from '../../contexts';
import { descriptors, localizationKeys } from '../../customizables';
import { Action, SecondaryActions } from '../../elements';
import { Plus } from '../../icons';
import { UserInvitationSuggestionList } from './UserInvitationSuggestionList';
import type { UserMembershipListProps } from './UserMembershipList';
import { UserMembershipList } from './UserMembershipList';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([
'socialButtonsProviderIcon',

'enterpriseButtonsProviderIcon',

'alternativeMethods',
'alternativeMethodsBlockButton',
'alternativeMethodsBlockButtonText',
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui.retheme/elements/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { SelectId } from '@clerk/types';
import type { PropsWithChildren, ReactElement } from 'react';
import React, { useState } from 'react';

import { usePopover, useSearchInput } from '../../ui/hooks';
import { Button, descriptors, Flex, Icon, Text } from '../customizables';
import { usePopover, useSearchInput } from '../hooks';
import { Caret, MagnifyingGlass } from '../icons';
import type { PropsOfComponent, ThemableCssProp } from '../styledSystem';
import { animations, common } from '../styledSystem';
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui.retheme/router/Route.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { LoadedClerk } from '@clerk/types';
import React from 'react';

import { useCoreClerk } from '../../ui/contexts';
import { pathFromFullPath, trimTrailingSlash } from '../../utils';
import { useCoreClerk } from '../contexts';
import { useNavigateToFlowStart } from '../hooks';
import { newPaths } from './newPaths';
import { match } from './pathToRegexp';
Expand Down
8 changes: 8 additions & 0 deletions packages/clerk-js/tsconfig.declarations.retheme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.declarations.json",
"compilerOptions": {
"paths": {
"~ui/*": ["./ui.retheme/*"]
}
}
}
6 changes: 4 additions & 2 deletions packages/clerk-js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"useUnknownInCatchVariables": false,
"declaration": false,
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react"
// "noUncheckedIndexedAccess": true // TODO: Enable and progressively fix related errors
Copy link
Member

Choose a reason for hiding this comment

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

@nikosdouvlis Shall we add a ticket to bring noUncheckedIndexedAccess back ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't changed as part of this PR but agreed, let's add a ticket in triage

"jsxImportSource": "@emotion/react",
"paths": {
"~ui/*": ["./ui/*"]
}
},
"include": [
"src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const common = ({ mode }) => {
// @see https://webpack.js.org/configuration/resolve/#resolveextensions
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],
alias: {
...(uiRetheme && { './ui': './ui.retheme' }),
'~ui': uiRetheme ? './ui.retheme' : './ui',
},
},
plugins: [
Expand Down
Loading