Skip to content

Commit f7b5721

Browse files
committed
chore: add twenty-ui hot reload in development mode
1 parent 8635335 commit f7b5721

File tree

9 files changed

+267
-471
lines changed

9 files changed

+267
-471
lines changed

Diff for: .eslintrc.cjs

+6-1
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ module.exports = {
4848
'error',
4949
{
5050
groups: [
51+
// Packages
5152
['^react', '^@?\\w'],
52-
['^(@|~|src)(/.*|$)'],
53+
// Internal modules
54+
['^(@|~|src|@ui)(/.*|$)'],
55+
// Side effect imports
5356
['^\\u0000'],
57+
// Relative imports
5458
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
5559
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
60+
// CSS imports
5661
['^.+\\.?(css)$'],
5762
],
5863
},

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
"typescript": "^5.3.3",
307307
"vite": "^5.0.0",
308308
"vite-plugin-checker": "^0.6.2",
309-
"vite-plugin-dts": "~2.3.0",
309+
"vite-plugin-dts": "3.8.1",
310310
"vite-plugin-svgr": "^4.2.0",
311311
"vitest": "1.4.0"
312312
},

Diff for: packages/twenty-emails/package.json

-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
"require": "./dist/index.js"
1818
}
1919
},
20-
"devDependencies": {
21-
"@nx/vite": "17.2.8",
22-
"@vitejs/plugin-react-swc": "^3.5.0",
23-
"vite": "^5.0.0",
24-
"vite-plugin-dts": "~2.3.0",
25-
"vite-tsconfig-paths": "^4.2.1"
26-
},
2720
"engines": {
2821
"node": "^18.17.1",
2922
"npm": "please-use-yarn",

Diff for: packages/twenty-emails/vite.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export default defineConfig({
1313
tsconfigPaths(),
1414
dts({
1515
entryRoot: 'src',
16-
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
17-
skipDiagnostics: true,
16+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
1817
}),
1918
],
2019

Diff for: packages/twenty-front/jest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/* eslint-disable @nx/enforce-module-boundaries,import/no-relative-packages */
12
import { JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest';
23

4+
import { compilerOptions as twentyUiCompilerOptions } from '../twenty-ui/tsconfig.json';
5+
36
import { compilerOptions } from './tsconfig.json';
47

58
const jestConfig: JestConfigWithTsJest = {
@@ -15,6 +18,8 @@ const jestConfig: JestConfigWithTsJest = {
1518
},
1619
moduleNameMapper: {
1720
...pathsToModuleNameMapper(compilerOptions.paths),
21+
// Include internal library aliases, so there is no need to build the library before tests.
22+
...pathsToModuleNameMapper(twentyUiCompilerOptions.paths),
1823
'\\.(jpg|jpeg|png|gif|webp|svg|svg\\?react)$':
1924
'<rootDir>/__mocks__/imageMock.js',
2025
'\\.css$': '<rootDir>/__mocks__/styleMock.js',

Diff for: packages/twenty-front/tsconfig.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
"~/*": ["packages/twenty-front/src/*"],
1313
"twenty-ui": ["packages/twenty-ui/src/index.ts"]
1414
},
15-
16-
/* Bundler mode */
15+
1716
"moduleResolution": "bundler",
1817
"allowSyntheticDefaultImports": true,
1918
"allowImportingTsExtensions": true,
2019
"resolveJsonModule": true,
2120
"isolatedModules": true,
2221
"noEmit": true,
2322
"jsx": "react-jsx",
24-
25-
/* Linting */
23+
2624
"strict": true,
2725
"noUnusedLocals": false,
2826
"noUnusedParameters": false,

Diff for: packages/twenty-front/vite.config.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,17 @@ export default defineConfig(({ command, mode }) => {
4242

4343
plugins: [
4444
react({ jsxImportSource: '@emotion/react' }),
45-
tsconfigPaths(),
45+
tsconfigPaths({
46+
projects: [
47+
'tsconfig.app.json',
48+
// Include internal library aliases in development mode, so hot reload is enabled for libraries.
49+
mode === 'development' ? '../twenty-ui/tsconfig.lib.json' : undefined,
50+
].filter(Boolean) as string[],
51+
}),
4652
svgr(),
4753
checker(checkers),
4854
],
4955

50-
resolve:
51-
mode === 'development'
52-
? {
53-
alias: {
54-
'@ui': '../../packages/twenty-ui/src',
55-
},
56-
}
57-
: {},
58-
5956
build: {
6057
outDir: 'build',
6158
},

Diff for: packages/twenty-ui/vite.config.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/// <reference types='vitest' />
2-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
32
import react from '@vitejs/plugin-react-swc';
43
import * as path from 'path';
54
import { defineConfig } from 'vite';
65
import checker from 'vite-plugin-checker';
76
import dts from 'vite-plugin-dts';
7+
import tsconfigPaths from 'vite-tsconfig-paths';
88

99
export default defineConfig({
1010
root: __dirname,
1111
cacheDir: '../../node_modules/.vite/packages/twenty-ui',
1212

1313
plugins: [
1414
react(),
15-
nxViteTsPaths(),
15+
tsconfigPaths(),
1616
dts({
1717
entryRoot: 'src',
18-
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
19-
skipDiagnostics: true,
18+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
2019
}),
2120
checker({
2221
typescript: {

0 commit comments

Comments
 (0)