# Introduction
We've facing facing intra package build error for a moment such as:
```ts
vite v7.1.12 building for production...
src/components/BaseEmail.tsx:20:19 - error TS2719: Type 'import("/Users/paulrastoin/ws/twenty/node_modules/@lingui/core/dist/index").I18n' is not assignable to type 'import("/Users/paulrastoin/ws/twenty/node_modules/@lingui/core/dist/index").I18n'. Two different types with this name exist, but they are unrelated.
Types have separate declarations of a private property '_locale'.
20 <I18nProvider i18n={i18nInstance}>
~~~~
node_modules/@lingui/react/dist/shared/react.b2b749a9.d.ts:42:5
42 i18n: I18n;
~~~~
The expected type comes from property 'i18n' which is declared here on type 'IntrinsicAttributes & Omit<I18nContext, "_"> & { children?: ReactNode; }'
```
and now since hacktoberfest merge getting even more such as:
```ts
➜ twenty git:(main) ✗ npx nx build twenty-emails
✔ 2/2 dependent project tasks succeeded [2 read from cache]
Hint: you can run the command with --verbose to see the full dependent project outputs
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
[tsconfig-paths] An error occurred while parsing "/Users/paulrastoin/ws/twenty/packages/twenty-apps/hacktoberfest-2025/linkedin-browser-extension/browser-extension/tsconfig.json". See below for details. To disable this message, set the `ignoreConfigErrors` option to true.
TSConfckParseError: failed to resolve "extends":"./.wxt/tsconfig.json" in /Users/paulrastoin/ws/twenty/packages/twenty-apps/hacktoberfest-2025/linkedin-browser-extension/browser-extension/tsconfig.json
at resolveExtends (file:///Users/paulrastoin/ws/twenty/node_modules/tsconfck/src/parse.js:261:8)
at parseExtends (file:///Users/paulrastoin/ws/twenty/node_modules/tsconfck/src/parse.js:196:24)
... 5 lines matching cause stack trace ...
at async createBuilder (file:///Users/paulrastoin/ws/twenty/node_modules/vite/dist/node/chunks/config.js:34104:19)
at async CAC.<anonymous> (file:///Users/paulrastoin/ws/twenty/node_modules/vite/dist/node/cli.js:629:10) {
code: 'EXTENDS_RESOLVE',
cause: Error: Cannot find module './.wxt/tsconfig.json'
Require stack:
- /Users/paulrastoin/ws/twenty/packages/twenty-apps/hacktoberfest-2025/linkedin-browser-extension/browser-extension/tsconfig.json
at Module._resolveFilename (node:internal/modules/cjs/loader:1410:15)
at require.resolve (node:internal/modules/helpers:163:19)
at resolveExtends (file:///Users/paulrastoin/ws/twenty/node_modules/tsconfck/src/parse.js:249:14)
at parseExtends (file:///Users/paulrastoin/ws/twenty/node_modules/tsconfck/src/parse.js:196:24)
at Module.parse (file:///Users/paulrastoin/ws/twenty/node_modules/tsconfck/src/parse.js:54:23)
at async Promise.all (index 21)
at async BasicMinimalPluginContext.configResolved (/Users/paulrastoin/ws/twenty/node_modules/vite-tsconfig-paths/dist/index.js:134:9)
at async Promise.all (index 0)
at async resolveConfig (file:///Users/paulrastoin/ws/twenty/node_modules/vite/dist/node/chunks/config.js:35892:2)
at async createBuilder (file:///Users/paulrastoin/ws/twenty/node_modules/vite/dist/node/chunks/config.js:34104:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/paulrastoin/ws/twenty/packages/twenty-apps/hacktoberfest-2025/linkedin-browser-extension/browser-extension/tsconfig.json'
]
},
tsconfigFile: '/Users/paulrastoin/ws/twenty/packages/twenty-apps/hacktoberfest-2025/linkedin-browser-extension/browser-extension/tsconfig.json'
}
vite v7.1.12 building for production...
src/components/BaseEmail.tsx:20:19 - error TS2719: Type 'import("/Users/paulrastoin/ws/twenty/node_modules/@lingui/core/dist/index").I18n' is not assignable to type 'import("/Users/paulrastoin/ws/twenty/node_modules/@lingui/core/dist/index").I18n'. Two different types with this name exist, but they are unrelated.
Types have separate declarations of a private property '_locale'.
20 <I18nProvider i18n={i18nInstance}>
~~~~
node_modules/@lingui/react/dist/shared/react.b2b749a9.d.ts:42:5
42 i18n: I18n;
~~~~
The expected type comes from property 'i18n' which is declared here on type 'IntrinsicAttributes & Omit<I18nContext, "_"> & { children?: ReactNode; }'
✓ 492 modules transformed.
[vite:dts] Start generate declaration files...
computing gzip size (31)...[vite:dts] Declaration files built in 981ms.
dist/locales/generated/zh-CN.mjs 4.16 kB │ gzip: 2.02 kB
dist/locales/generated/zh-TW.mjs 4.21 kB │ gzip: 2.05 kB
dist/locales/generated/en.mjs 4.34 kB │ gzip: 1.28 kB
dist/locales/generated/fi-FI.mjs 4.45 kB │ gzip: 1.90 kB
dist/locales/generated/af-ZA.mjs 4.50 kB │ gzip: 1.88 kB
dist/locales/generated/no-NO.mjs 4.52 kB │ gzip: 1.85 kB
dist/locales/generated/da-DK.mjs 4.52 kB │ gzip: 1.84 kB
dist/locales/generated/pt-BR.mjs 4.54 kB │ gzip: 1.89 kB
dist/locales/generated/sv-SE.mjs 4.54 kB │ gzip: 1.88 kB
dist/locales/generated/nl-NL.mjs 4.55 kB │ gzip: 1.87 kB
dist/locales/generated/pt-PT.mjs 4.56 kB │ gzip: 1.88 kB
dist/locales/generated/it-IT.mjs 4.59 kB │ gzip: 1.87 kB
dist/locales/generated/pl-PL.mjs 4.66 kB │ gzip: 2.04 kB
dist/locales/generated/cs-CZ.mjs 4.67 kB │ gzip: 2.05 kB
dist/locales/generated/es-ES.mjs 4.70 kB │ gzip: 1.90 kB
dist/locales/generated/tr-TR.mjs 4.70 kB │ gzip: 2.02 kB
dist/locales/generated/de-DE.mjs 4.71 kB │ gzip: 1.97 kB
dist/locales/generated/ca-ES.mjs 4.73 kB │ gzip: 1.92 kB
dist/locales/generated/ko-KR.mjs 4.73 kB │ gzip: 2.14 kB
dist/locales/generated/ro-RO.mjs 4.73 kB │ gzip: 1.95 kB
dist/locales/generated/fr-FR.mjs 4.74 kB │ gzip: 1.92 kB
dist/locales/generated/hu-HU.mjs 4.82 kB │ gzip: 2.09 kB
dist/locales/generated/he-IL.mjs 4.88 kB │ gzip: 1.99 kB
dist/locales/generated/ja-JP.mjs 4.95 kB │ gzip: 2.19 kB
dist/locales/generated/vi-VN.mjs 5.19 kB │ gzip: 2.14 kB
dist/locales/generated/ar-SA.mjs 5.35 kB │ gzip: 2.21 kB
dist/locales/generated/pseudo-en.mjs 5.68 kB │ gzip: 2.27 kB
dist/locales/generated/sr-Cyrl.mjs 5.82 kB │ gzip: 2.32 kB
dist/locales/generated/uk-UA.mjs 6.11 kB │ gzip: 2.41 kB
dist/locales/generated/el-GR.mjs 6.47 kB │ gzip: 2.53 kB
dist/locales/generated/ru-RU.mjs 6.62 kB │ gzip: 2.55 kB
dist/index.mjs 822.22 kB │ gzip: 179.78 kB
dist/locales/generated/zh-CN.js 4.23 kB │ gzip: 2.08 kB
dist/locales/generated/zh-TW.js 4.28 kB │ gzip: 2.10 kB
dist/locales/generated/en.js 4.41 kB │ gzip: 1.33 kB
dist/locales/generated/fi-FI.js 4.52 kB │ gzip: 1.95 kB
dist/locales/generated/af-ZA.js 4.56 kB │ gzip: 1.93 kB
dist/locales/generated/no-NO.js 4.58 kB │ gzip: 1.90 kB
dist/locales/generated/da-DK.js 4.59 kB │ gzip: 1.89 kB
dist/locales/generated/pt-BR.js 4.60 kB │ gzip: 1.94 kB
dist/locales/generated/sv-SE.js 4.61 kB │ gzip: 1.93 kB
dist/locales/generated/nl-NL.js 4.62 kB │ gzip: 1.92 kB
dist/locales/generated/pt-PT.js 4.63 kB │ gzip: 1.93 kB
dist/locales/generated/it-IT.js 4.66 kB │ gzip: 1.92 kB
dist/locales/generated/pl-PL.js 4.73 kB │ gzip: 2.09 kB
dist/locales/generated/cs-CZ.js 4.74 kB │ gzip: 2.10 kB
dist/locales/generated/es-ES.js 4.77 kB │ gzip: 1.95 kB
dist/locales/generated/tr-TR.js 4.77 kB │ gzip: 2.07 kB
dist/locales/generated/de-DE.js 4.77 kB │ gzip: 2.02 kB
dist/locales/generated/ca-ES.js 4.80 kB │ gzip: 1.97 kB
dist/locales/generated/ko-KR.js 4.80 kB │ gzip: 2.20 kB
dist/locales/generated/ro-RO.js 4.80 kB │ gzip: 2.00 kB
dist/locales/generated/fr-FR.js 4.81 kB │ gzip: 1.97 kB
dist/locales/generated/hu-HU.js 4.89 kB │ gzip: 2.14 kB
dist/locales/generated/he-IL.js 4.95 kB │ gzip: 2.04 kB
dist/locales/generated/ja-JP.js 5.02 kB │ gzip: 2.24 kB
dist/locales/generated/vi-VN.js 5.26 kB │ gzip: 2.19 kB
dist/locales/generated/ar-SA.js 5.42 kB │ gzip: 2.26 kB
dist/locales/generated/pseudo-en.js 5.75 kB │ gzip: 2.32 kB
dist/locales/generated/sr-Cyrl.js 5.89 kB │ gzip: 2.37 kB
dist/locales/generated/uk-UA.js 6.18 kB │ gzip: 2.47 kB
dist/locales/generated/el-GR.js 6.54 kB │ gzip: 2.58 kB
dist/locales/generated/ru-RU.js 6.69 kB │ gzip: 2.60 kB
dist/index.js 606.48 kB │ gzip: 160.10 kB
✓ built in 2.45s
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NX Successfully ran target build for project twenty-emails and 2 tasks it depends on (5s)
Nx read the output from the cache instead of running the command for 2 out of 3 tasks.
```
Fixing folder to search for tsconfig from
296 lines
9.3 KiB
TypeScript
296 lines
9.3 KiB
TypeScript
/* eslint-disable no-console */
|
|
import { lingui } from '@lingui/vite-plugin';
|
|
import { isNonEmptyString } from '@sniptt/guards';
|
|
import react from '@vitejs/plugin-react-swc';
|
|
import wyw from '@wyw-in-js/vite';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
import {
|
|
defineConfig,
|
|
loadEnv,
|
|
type PluginOption,
|
|
searchForWorkspaceRoot,
|
|
} from 'vite';
|
|
import checker from 'vite-plugin-checker';
|
|
import svgr from 'vite-plugin-svgr';
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
type Checkers = Parameters<typeof checker>[0];
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
const env = loadEnv(mode, __dirname, '');
|
|
|
|
const {
|
|
REACT_APP_SERVER_BASE_URL,
|
|
VITE_BUILD_SOURCEMAP,
|
|
VITE_DISABLE_TYPESCRIPT_CHECKER,
|
|
VITE_DISABLE_ESLINT_CHECKER,
|
|
VITE_HOST,
|
|
SSL_CERT_PATH,
|
|
SSL_KEY_PATH,
|
|
REACT_APP_PORT,
|
|
IS_DEBUG_MODE,
|
|
} = env;
|
|
|
|
const port = isNonEmptyString(REACT_APP_PORT)
|
|
? parseInt(REACT_APP_PORT)
|
|
: 3001;
|
|
|
|
const isBuildCommand = command === 'build';
|
|
|
|
const tsConfigPath = isBuildCommand
|
|
? path.resolve(__dirname, './tsconfig.build.json')
|
|
: path.resolve(__dirname, './tsconfig.dev.json');
|
|
|
|
const CHUNK_SIZE_WARNING_LIMIT = 1024 * 1024; // 1MB
|
|
// Please don't increase this limit for main index chunk
|
|
// If it gets too big then find modules in the code base
|
|
// that can be loaded lazily, there are more!
|
|
const MAIN_CHUNK_SIZE_LIMIT = 6.1 * 1024 * 1024; // 6.1MB for main index chunk
|
|
const OTHER_CHUNK_SIZE_LIMIT = 5 * 1024 * 1024; // 5MB for other chunks
|
|
|
|
const checkers: Checkers = {
|
|
overlay: false,
|
|
};
|
|
|
|
if (VITE_DISABLE_TYPESCRIPT_CHECKER === 'true') {
|
|
console.log(
|
|
`VITE_DISABLE_TYPESCRIPT_CHECKER: ${VITE_DISABLE_TYPESCRIPT_CHECKER}`,
|
|
);
|
|
}
|
|
|
|
if (VITE_DISABLE_ESLINT_CHECKER === 'true') {
|
|
console.log(`VITE_DISABLE_ESLINT_CHECKER: ${VITE_DISABLE_ESLINT_CHECKER}`);
|
|
}
|
|
|
|
if (VITE_BUILD_SOURCEMAP === 'true') {
|
|
console.log(`VITE_BUILD_SOURCEMAP: ${VITE_BUILD_SOURCEMAP}`);
|
|
}
|
|
|
|
if (VITE_DISABLE_TYPESCRIPT_CHECKER !== 'true') {
|
|
checkers['typescript'] = {
|
|
tsconfigPath: tsConfigPath,
|
|
};
|
|
}
|
|
|
|
if (VITE_DISABLE_ESLINT_CHECKER !== 'true') {
|
|
checkers['eslint'] = {
|
|
lintCommand: 'eslint ../../packages/twenty-front --max-warnings 0',
|
|
useFlatConfig: true,
|
|
};
|
|
}
|
|
|
|
return {
|
|
root: __dirname,
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-front',
|
|
|
|
server: {
|
|
port: port,
|
|
...(VITE_HOST ? { host: VITE_HOST } : {}),
|
|
...(SSL_KEY_PATH && SSL_CERT_PATH
|
|
? {
|
|
protocol: 'https',
|
|
https: {
|
|
key: fs.readFileSync(env.SSL_KEY_PATH),
|
|
cert: fs.readFileSync(env.SSL_CERT_PATH),
|
|
},
|
|
}
|
|
: {
|
|
protocol: 'http',
|
|
}),
|
|
fs: {
|
|
allow: [
|
|
searchForWorkspaceRoot(process.cwd()),
|
|
'**/@blocknote/core/src/fonts/**',
|
|
],
|
|
},
|
|
},
|
|
|
|
plugins: [
|
|
react({
|
|
jsxImportSource: '@emotion/react',
|
|
plugins: [['@lingui/swc-plugin', {}]],
|
|
}),
|
|
tsconfigPaths({
|
|
root: __dirname,
|
|
projects: ['tsconfig.json'],
|
|
}),
|
|
svgr(),
|
|
lingui({
|
|
configPath: path.resolve(__dirname, './lingui.config.ts'),
|
|
}),
|
|
checker(checkers),
|
|
{
|
|
...wyw({
|
|
include: [
|
|
'**/CurrencyDisplay.tsx',
|
|
'**/EllipsisDisplay.tsx',
|
|
'**/ContactLink.tsx',
|
|
'**/BooleanDisplay.tsx',
|
|
'**/LinksDisplay.tsx',
|
|
'**/RoundedLink.tsx',
|
|
'**/OverflowingTextWithTooltip.tsx',
|
|
'**/Chip.tsx',
|
|
'**/Tag.tsx',
|
|
'**/MultiSelectFieldDisplay.tsx',
|
|
'**/RatingInput.tsx',
|
|
'**/RecordTableCellContainer.tsx',
|
|
'**/RecordTableCellDisplayContainer.tsx',
|
|
'**/Avatar.tsx',
|
|
'**/RecordTableBodyDroppable.tsx',
|
|
'**/RecordTableCellBaseContainer.tsx',
|
|
'**/RecordTableCellTd.tsx',
|
|
'**/RecordTableCellStyleWrapper.tsx',
|
|
'**/RecordTableHeaderDragDropColumn.tsx',
|
|
'**/ActorDisplay.tsx',
|
|
'**/BooleanDisplay.tsx',
|
|
'**/CurrencyDisplay.tsx',
|
|
'**/TextDisplay.tsx',
|
|
'**/EllipsisDisplay.tsx',
|
|
'**/AvatarChip.tsx',
|
|
'**/URLDisplay.tsx',
|
|
'**/EmailsDisplay.tsx',
|
|
'**/PhonesDisplay.tsx',
|
|
'**/MultiSelectDisplay.tsx',
|
|
'**/RecordTableRowVirtualizedContainer.tsx',
|
|
'**/RecordTableVirtualizedBodyPlaceholder.tsx',
|
|
'**/RecordTableCellLoading.tsx',
|
|
],
|
|
babelOptions: {
|
|
presets: ['@babel/preset-typescript', '@babel/preset-react'],
|
|
},
|
|
}),
|
|
enforce: 'pre',
|
|
},
|
|
visualizer({
|
|
open: true,
|
|
gzipSize: true,
|
|
brotliSize: true,
|
|
filename: 'dist/stats.html',
|
|
}) as PluginOption, // https://github.com/btd/rollup-plugin-visualizer/issues/162#issuecomment-1538265997,
|
|
],
|
|
|
|
optimizeDeps: {
|
|
exclude: [
|
|
'../../node_modules/.vite',
|
|
'../../node_modules/.cache',
|
|
'../../node_modules/twenty-ui',
|
|
],
|
|
},
|
|
|
|
build: {
|
|
minify: 'esbuild',
|
|
outDir: 'build',
|
|
sourcemap: VITE_BUILD_SOURCEMAP === 'true',
|
|
rollupOptions: {
|
|
// Don't use manual chunks as it causes many issue
|
|
// including this one we wasted a lot of time on:
|
|
// https://github.com/rollup/rollup/issues/2793
|
|
output: {
|
|
// Set chunk size warning limit (in bytes) - warns at 1MB
|
|
chunkSizeWarningLimit: CHUNK_SIZE_WARNING_LIMIT,
|
|
// Custom plugin to fail build if chunks exceed max size
|
|
plugins: [
|
|
{
|
|
name: 'chunk-size-limit',
|
|
generateBundle(_options, bundle) {
|
|
const oversizedChunks: string[] = [];
|
|
|
|
Object.entries(bundle).forEach(([fileName, chunk]) => {
|
|
if (chunk.type === 'chunk' && chunk.code !== undefined) {
|
|
const size = Buffer.byteLength(chunk.code, 'utf8');
|
|
const isMainChunk =
|
|
fileName.includes('index') && chunk.isEntry;
|
|
const sizeLimit = isMainChunk
|
|
? MAIN_CHUNK_SIZE_LIMIT
|
|
: OTHER_CHUNK_SIZE_LIMIT;
|
|
const limitType = isMainChunk ? 'main' : 'other';
|
|
|
|
if (size > sizeLimit) {
|
|
oversizedChunks.push(
|
|
`${fileName} (${limitType}): ${(size / 1024 / 1024).toFixed(2)}MB (limit: ${(sizeLimit / 1024 / 1024).toFixed(2)}MB)`,
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
if (oversizedChunks.length > 0) {
|
|
const errorMessage = `Build failed: The following chunks exceed their size limits:\n${oversizedChunks.map((chunk) => ` - ${chunk}`).join('\n')}`;
|
|
this.error(errorMessage);
|
|
}
|
|
},
|
|
},
|
|
// TODO; later - think about prefetching modules such
|
|
// as date time picker, phone input etc...
|
|
/*
|
|
{
|
|
name: 'add-prefetched-modules',
|
|
transformIndexHtml(html: string,
|
|
ctx: {
|
|
path: string;
|
|
filename: string;
|
|
server?: ViteDevServer;
|
|
bundle?: import('rollup').OutputBundle;
|
|
chunk?: import('rollup').OutputChunk;
|
|
}) {
|
|
|
|
const bundles = Object.keys(ctx.bundle ?? {});
|
|
|
|
let modernBundles = bundles.filter(
|
|
(bundle) => bundle.endsWith('.map') === false
|
|
);
|
|
|
|
|
|
// Remove existing files and concatenate them into link tags
|
|
const prefechBundlesString = modernBundles
|
|
.filter((bundle) => html.includes(bundle) === false)
|
|
.map((bundle) => `<link rel="prefetch" href="${ctx.server?.config.base}${bundle}">`)
|
|
.join('');
|
|
|
|
// Use regular expression to get the content within <head> </head>
|
|
const headContent = html.match(/<head>([\s\S]*)<\/head>/)?.[1] ?? '';
|
|
// Insert the content of prefetch into the head
|
|
const newHeadContent = `${headContent}${prefechBundlesString}`;
|
|
// Replace the original head
|
|
html = html.replace(
|
|
/<head>([\s\S]*)<\/head>/,
|
|
`<head>${newHeadContent}</head>`
|
|
);
|
|
|
|
return html;
|
|
|
|
|
|
},
|
|
}*/
|
|
],
|
|
},
|
|
},
|
|
},
|
|
|
|
envPrefix: 'REACT_APP_',
|
|
|
|
define: {
|
|
_env_: {
|
|
REACT_APP_SERVER_BASE_URL,
|
|
},
|
|
'process.env': {
|
|
REACT_APP_SERVER_BASE_URL,
|
|
IS_DEBUG_MODE,
|
|
},
|
|
},
|
|
css: {
|
|
modules: {
|
|
localsConvention: 'camelCaseOnly',
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
path: 'rollup-plugin-node-polyfills/polyfills/path',
|
|
// https://github.com/twentyhq/twenty/pull/10782/files
|
|
// This will likely be migrated to twenty-ui package when built separately
|
|
'@tabler/icons-react': '@tabler/icons-react/dist/esm/icons/index.mjs',
|
|
},
|
|
},
|
|
};
|
|
});
|