chore: setup twenty-ui absolute path alias (#4732)

Split from https://github.com/twentyhq/twenty/pull/4518

- Setup `@ui/*` as an internal alias to reference `twenty-ui/src`.
- Configures twenty-front to understand the `@ui/*` alias on development
mode, so twenty-ui can be hot reloaded.
- When building on production mode, twenty-front needs twenty-ui to be
built beforehand (which is automatic with the `dependsOn` option).
- Configures twenty-front to understand the `@ui/*` alias when launching
tests, so there is no need to re-build twenty-ui for tests.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Thaïs
2024-04-04 15:38:01 +02:00
committed by GitHub
parent 41960f3593
commit c5349291c8
41 changed files with 406 additions and 594 deletions

View File

@ -1,20 +1,30 @@
export default {
/* eslint-disable @nx/enforce-module-boundaries,import/no-relative-packages */
import { JestConfigWithTsJest, pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions as twentyUiCompilerOptions } from '../twenty-ui/tsconfig.json';
import { compilerOptions } from './tsconfig.json';
const jestConfig: JestConfigWithTsJest = {
// to enable logs, comment out the following line
silent: true,
setupFilesAfterEnv: ['./src/setupTests.ts'],
displayName: 'twenty-front',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['./setupTests.ts'],
testEnvironment: 'jsdom',
transformIgnorePatterns: ['../../node_modules/'],
transform: {
'^.+\\.(ts|js|tsx|jsx)$': '@swc/jest',
},
moduleNameMapper: {
'~/(.+)': '<rootDir>/src/$1',
'@/(.+)': '<rootDir>/src/modules/$1',
'twenty-ui': '<rootDir>/../twenty-ui/src/index.ts',
'@testing/(.+)': '<rootDir>/src/testing/$1',
...pathsToModuleNameMapper(compilerOptions.paths),
// Include internal library aliases, so there is no need to build the library before tests.
...pathsToModuleNameMapper(twentyUiCompilerOptions.paths),
'\\.(jpg|jpeg|png|gif|webp|svg|svg\\?react)$':
'<rootDir>/__mocks__/imageMock.js',
'\\.css$': '<rootDir>/__mocks__/styleMock.js',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
coverageThreshold: {
global: {
@ -41,5 +51,7 @@ export default {
'__stories__/*',
'display/icon/index.ts',
],
// coverageDirectory: '<rootDir>/coverage/',
coverageDirectory: './coverage',
};
export default jestConfig;