Files
twenty/packages/twenty-sdk/vite.config.browser.ts
T
Raphaël Bosi 0dc6272da5 Remove twenty-ui reexport from the SDK and use twenty-ui directly (#22326)
## What & why

Removes the `twenty-sdk/ui` reexport. Apps now use Twenty UI by
installing
[`twenty-ui@1.0.0-alpha.1`](https://www.npmjs.com/package/twenty-ui/v/1.0.0-alpha.1)
from npm and importing its subpaths directly. The reexport re-exported
types that didn't resolve, forcing typecheck workarounds.

## Changes

- **twenty-sdk**: delete `src/ui/index.ts`, drop the `./ui` export,
remove it from the browser vite build, and rewire the CLI manifest-mock
to `twenty-ui` (`.css` falls through to the empty-CSS loader).
`twenty-ui` stays a devDependency for the CLI fixture tests.
- **Renderer + create-twenty-app template**: import from `twenty-ui`
subpaths; the template pins `twenty-ui@1.0.0-alpha.1`.
- **Docs**: new "Using Twenty UI components" section (install + subpath
imports + `useTheme()` for theme tokens), codex references, and the
cross-doc-contract validator.

The `twenty-for-twenty` / `twenty-slack` example apps are intentionally
left on `twenty-sdk/ui`: they consume the published SDK (which still
ships `./ui`), and `twenty-ui@1.0.0-alpha.1` requires react 19 + a
`monaco-editor` peer the react-18 apps can't satisfy. They migrate once
the SDK is republished.
2026-06-30 11:17:48 +02:00

76 lines
1.9 KiB
TypeScript

import path from 'path';
import { type PackageJson } from 'type-fest';
import { defineConfig } from 'vite';
import packageJson from './package.json';
export default defineConfig(() => {
return {
root: __dirname,
cacheDir: '../../node_modules/.vite/packages/twenty-sdk-browser',
resolve: {
tsconfigPaths: true,
alias: {
'@/': path.resolve(__dirname, 'src') + '/',
},
},
build: {
emptyOutDir: false,
outDir: 'dist',
lib: {
entry: ['src/front-component-renderer/index.ts'],
name: 'twenty-sdk',
},
rollupOptions: {
onwarn: (warning, warn) => {
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
warning.message.includes('"use client"')
) {
return;
}
warn(warning);
},
external: (id: string) => {
const deps = Object.keys(
(packageJson as PackageJson).dependencies || {},
);
return deps.some((dep) => id === dep || id.startsWith(dep + '/'));
},
output: [
{
format: 'es',
entryFileNames: (chunk) => {
if (
chunk.facadeModuleId?.includes(
'front-component-renderer/index.ts',
)
) {
return 'front-component-renderer.mjs';
}
return '[name].mjs';
},
},
{
format: 'cjs',
esModule: true,
exports: 'named',
entryFileNames: (chunk) => {
if (
chunk.facadeModuleId?.includes(
'front-component-renderer/index.ts',
)
) {
return 'front-component-renderer.cjs';
}
return '[name].cjs';
},
},
],
},
},
logLevel: 'warn',
};
});