Skip to content

Commit b26a400

Browse files
committed
✨ Add lazy-loaded Jotai DevTools component
1 parent b92ea07 commit b26a400

9 files changed

Lines changed: 90 additions & 25 deletions

File tree

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
pnpx lint-staged

eslint.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import tseslint from 'typescript-eslint';
44
import reactPlugin from 'eslint-plugin-react';
55
import reactHooksPlugin from 'eslint-plugin-react-hooks';
66
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
7-
import importPlugin from 'eslint-plugin-import';
7+
import importPlugin from 'eslint-plugin-import-x';
88
import tanstackQueryPlugin from '@tanstack/eslint-plugin-query';
99
import prettierRecommended from 'eslint-plugin-prettier/recommended';
1010
import { fixupConfigRules } from '@eslint/compat';
1111

1212
export default tseslint.config(
1313
// 1. ignores
14-
{ ignores: ['dist/', 'build/', 'dev-dist', 'eslint.config.js'] },
14+
{ ignores: ['dist/', 'build/', 'dev-dist/', 'eslint.config.js'] },
1515
// 2. 기본 + TS 추천 설정
1616
js.configs.recommended,
1717
tseslint.configs.recommended,
@@ -36,7 +36,7 @@ export default tseslint.config(
3636
},
3737
settings: {
3838
react: { version: 'detect' },
39-
'import/resolver': { typescript: true, node: true },
39+
'import-x/resolver': { typescript: true, node: true },
4040
},
4141
plugins: {
4242
'react-hooks': reactHooksPlugin,
@@ -78,8 +78,8 @@ export default tseslint.config(
7878
],
7979

8080
/** import 정렬 관련 설정 */
81-
'import/no-unresolved': 'error',
82-
'import/order': [
81+
'import-x/no-unresolved': 'error',
82+
'import-x/order': [
8383
'warn',
8484
{
8585
// 그룹 순서 지정

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"eslint": "^10.0.2",
7676
"eslint-config-prettier": "^10.1.8",
7777
"eslint-import-resolver-typescript": "^4.4.4",
78-
"eslint-plugin-import": "^2.32.0",
78+
"eslint-plugin-import-x": "^4.16.1",
7979
"eslint-plugin-prettier": "^5.5.5",
8080
"eslint-plugin-react": "^7.37.5",
8181
"eslint-plugin-react-hooks": "^7.0.1",

pnpm-lock.yaml

Lines changed: 60 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base/components/dev/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './jotai-devtools';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { lazy, Suspense } from 'react';
2+
3+
import { DevToolsProps } from 'jotai-devtools';
4+
5+
const LazyDevTools = lazy(() =>
6+
Promise.all([
7+
import('jotai-devtools'),
8+
import('jotai-devtools/styles.css'),
9+
]).then(([m]) => ({ default: m.DevTools })),
10+
);
11+
12+
export function JotaiDevTools(props: DevToolsProps) {
13+
if (!import.meta.env.DEV) return null;
14+
return (
15+
<Suspense fallback={null}>
16+
<LazyDevTools {...props} />
17+
</Suspense>
18+
);
19+
}

src/base/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './ui';
22
export * from './modal';
33
export * from './layout';
4+
export * from './dev';

src/base/components/ui/link-particles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
33
import { useColorMode } from '@chakra-ui/react';
44
import { type ISourceOptions } from '@tsparticles/engine';
55
import { loadLinksPreset } from '@tsparticles/preset-links';
6-
// eslint-disable-next-line import/no-named-as-default
6+
// eslint-disable-next-line import-x/no-named-as-default
77
import Particles, {
88
initParticlesEngine,
99
type IParticlesProps,

src/features/syntax-editor/pages/syntax-editor-root.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { Provider } from 'jotai';
2-
import { DevTools } from 'jotai-devtools';
32
import { Outlet } from 'react-router-dom';
43

5-
import { Layout } from '@/base';
4+
import { JotaiDevTools, Layout } from '@/base';
65
import { analysisStore } from '@/features/syntax-editor';
76

8-
if (import.meta.env.DEV) void import('jotai-devtools/styles.css');
9-
107
export default function SyntaxEditorRoot() {
118
return (
129
<Layout>
1310
<Provider store={analysisStore}>
14-
<DevTools theme="dark" />
11+
<JotaiDevTools store={analysisStore} theme="dark" />
1512
<Outlet />
1613
</Provider>
1714
</Layout>

0 commit comments

Comments
 (0)