6ee5413951
### Summary Migrates main monorepo packages from the `vite-tsconfig-paths` plugin to vite’s built-in path resolution. Vite 8 showing this warning when the plugin is detected: > The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead. ### References - https://vite.dev/config/shared-options#resolve-tsconfigpaths - https://vite.dev/guide/features#paths - https://github.com/vitejs/vite/pull/21781 <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/22100?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> --------- Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
// @ts-expect-error: no type declarations for path in this config
|
|
import path from 'path';
|
|
import { defineConfig } from 'vite';
|
|
// @ts-expect-error: importing JSON without resolveJsonModule
|
|
import packageJson from './package.json';
|
|
|
|
const moduleEntries = Object.keys((packageJson as any).exports || {})
|
|
.filter(
|
|
(key) => key !== './style.css' && key !== '.' && !key.startsWith('./src/'),
|
|
)
|
|
.map((module) => `src/${module.replace(/^\.\//, '')}/index.ts`);
|
|
|
|
const entries = ['src/index.ts', ...moduleEntries];
|
|
|
|
const entryFileNames = (chunk: any, extension: 'cjs' | 'mjs') => {
|
|
if (!chunk.isEntry) {
|
|
throw new Error(
|
|
`Should never occurs, encountered a non entry chunk ${chunk.facadeModuleId}`,
|
|
);
|
|
}
|
|
|
|
const splitFaceModuleId = chunk.facadeModuleId?.split('/');
|
|
if (splitFaceModuleId === undefined) {
|
|
throw new Error(
|
|
`Should never occurs splitFaceModuleId is undefined ${chunk.facadeModuleId}`,
|
|
);
|
|
}
|
|
|
|
const moduleDirectory = splitFaceModuleId[splitFaceModuleId?.length - 2];
|
|
if (moduleDirectory === 'src') {
|
|
return `${chunk.name}.${extension}`;
|
|
}
|
|
return `${moduleDirectory}.${extension}`;
|
|
};
|
|
|
|
export default defineConfig(() => {
|
|
return {
|
|
root: __dirname,
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-shared',
|
|
resolve: {
|
|
tsconfigPaths: true,
|
|
alias: {
|
|
'@/': path.resolve(__dirname, 'src') + '/',
|
|
},
|
|
},
|
|
build: {
|
|
emptyOutDir: false,
|
|
outDir: 'dist',
|
|
lib: { entry: entries, name: 'twenty-shared' },
|
|
rollupOptions: {
|
|
external: [
|
|
...Object.keys((packageJson as any).dependencies || {}),
|
|
'typescript',
|
|
],
|
|
output: [
|
|
{
|
|
format: 'es',
|
|
entryFileNames: (chunk) => entryFileNames(chunk, 'mjs'),
|
|
},
|
|
{
|
|
format: 'cjs',
|
|
interop: 'auto',
|
|
esModule: true,
|
|
exports: 'named',
|
|
entryFileNames: (chunk) => entryFileNames(chunk, 'cjs'),
|
|
},
|
|
],
|
|
},
|
|
},
|
|
logLevel: 'warn',
|
|
};
|
|
});
|