Skip to content

Commit 09fbafd

Browse files
authored
chore(clerk-js): Add support for import alias (#6030)
1 parent 5644d94 commit 09fbafd

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

.changeset/rich-candies-wish.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/clerk-js/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const config = {
3737
// ],
3838
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!(@formkit/auto-animate/react)).+\\.(js|jsx|mjs|cjs|ts|tsx)$'],
3939
moduleDirectories: ['node_modules', '<rootDir>/src'],
40+
moduleNameMapper: {
41+
'@/(.*)': '<rootDir>/src/$1',
42+
},
4043
transform: {
4144
'^.+\\.m?tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json', diagnostics: false }],
4245
// '^.+\\.m?tsx?$': ['@swc/jest'],

packages/clerk-js/rspack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const common = ({ mode, variant, disableRHC = false }) => {
4141
return {
4242
mode,
4343
resolve: {
44+
alias: {
45+
'@': path.resolve(__dirname, './src'),
46+
},
4447
// Attempt to resolve these extensions in order
4548
// @see https://webpack.js.org/configuration/resolve/#resolveextensions
4649
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],

packages/clerk-js/src/ui/components/SignIn/SignIn.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ import { useClerk } from '@clerk/shared/react';
22
import type { SignInModalProps, SignInProps } from '@clerk/types';
33
import React from 'react';
44

5-
import { SessionTasks as LazySessionTasks } from '../../../ui/lazyModules/components';
6-
import { normalizeRoutingOptions } from '../../../utils/normalizeRoutingOptions';
7-
import { SignInEmailLinkFlowComplete, SignUpEmailLinkFlowComplete } from '../../common/EmailLinkCompleteFlowCard';
5+
import { SignInEmailLinkFlowComplete, SignUpEmailLinkFlowComplete } from '@/ui/common/EmailLinkCompleteFlowCard';
86
import {
97
SignInContext,
108
SignUpContext,
119
useSignInContext,
1210
useSignUpContext,
1311
withCoreSessionSwitchGuard,
14-
} from '../../contexts';
15-
import { Flow } from '../../customizables';
16-
import { useFetch } from '../../hooks';
17-
import { usePreloadTasks } from '../../hooks/usePreloadTasks';
18-
import { Route, Switch, useRouter, VIRTUAL_ROUTER_BASE_PATH } from '../../router';
19-
import type { SignUpCtx } from '../../types';
12+
} from '@/ui/contexts';
13+
import { Flow } from '@/ui/customizables';
14+
import { useFetch } from '@/ui/hooks';
15+
import { usePreloadTasks } from '@/ui/hooks/usePreloadTasks';
16+
import { SessionTasks as LazySessionTasks } from '@/ui/lazyModules/components';
17+
import { Route, Switch, useRouter, VIRTUAL_ROUTER_BASE_PATH } from '@/ui/router';
18+
import type { SignUpCtx } from '@/ui/types';
19+
import { normalizeRoutingOptions } from '@/utils/normalizeRoutingOptions';
20+
2021
import {
2122
LazySignUpContinue,
2223
LazySignUpSSOCallback,

packages/clerk-js/src/ui/elements/DevModeNotice.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ThemableCssProp } from 'ui/styledSystem';
1+
import type { ThemableCssProp } from '@/ui/styledSystem';
22

33
import { Box, Text } from '../customizables';
44
import { useDevMode } from '../hooks/useDevMode';

packages/clerk-js/src/ui/elements/LinkRenderer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { memo, useMemo } from 'react';
22

3-
import { Link } from '../customizables';
4-
import type { PropsOfComponent } from '../styledSystem';
3+
import { Link } from '@/ui/customizables';
4+
import type { PropsOfComponent } from '@/ui/styledSystem';
55

66
interface LinkRendererProps extends Omit<PropsOfComponent<typeof Link>, 'href' | 'children'> {
77
text: string;

packages/clerk-js/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"compilerOptions": {
33
"allowJs": false,
4-
"baseUrl": "src",
54
"declaration": false,
65
"esModuleInterop": true,
76
"forceConsistentCasingInFileNames": true,
@@ -20,7 +19,10 @@
2019
"sourceMap": false,
2120
"strict": true,
2221
"target": "ES2019",
23-
"useUnknownInCatchVariables": false
22+
"useUnknownInCatchVariables": false,
23+
"paths": {
24+
"@/*": ["./src/*"]
25+
}
2426
},
2527
"include": ["src", "jest.setup.ts", "jest.setup-after-env.ts", "jest.jsdom-with-timezone.ts"]
2628
}

0 commit comments

Comments
 (0)