f17cc4d190
## Split twenty-sdk build into separate Node and browser targets The SDK was bundling Node.js code (CLI, SDK API) and browser code (UI components, front-component renderer) through a single Vite config. This caused incorrect externalization — Node builtins leaked into browser bundles and browser-specific chunking logic applied to CLI output. This PR splits the build into `vite.config.node.ts` and `vite.config.browser.ts` so each target gets the right externals and output format. Also includes a few housekeeping renames: - `front-component` export path → `front-component-renderer` (matches what it actually is) - `front-component-common` merged into `front-component-api` (was a needless extra module)
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import type * as esbuild from 'esbuild';
|
|
|
|
import { FRONT_COMPONENT_EXTERNAL_MODULES } from '../../../src/cli/utilities/build/common/front-component-build/constants/front-component-external-modules';
|
|
import { getFrontComponentBuildPlugins } from '../../../src/cli/utilities/build/common/front-component-build/utils/get-front-component-build-plugins';
|
|
|
|
export type FrontComponentBuildOptions = {
|
|
entryPoints: esbuild.BuildOptions['entryPoints'];
|
|
outdir: string;
|
|
tsconfigPath?: string;
|
|
externalModules?: string[];
|
|
logLevel?: esbuild.LogLevel;
|
|
platform?: esbuild.Platform;
|
|
minify?: boolean;
|
|
metafile?: boolean;
|
|
sourcemap?: boolean;
|
|
};
|
|
|
|
export const createFrontComponentBuildOptions = ({
|
|
entryPoints,
|
|
outdir,
|
|
tsconfigPath,
|
|
externalModules = FRONT_COMPONENT_EXTERNAL_MODULES,
|
|
logLevel = 'silent',
|
|
platform,
|
|
minify,
|
|
metafile = true,
|
|
sourcemap = true,
|
|
}: FrontComponentBuildOptions): esbuild.BuildOptions => {
|
|
return {
|
|
entryPoints,
|
|
bundle: true,
|
|
splitting: false,
|
|
format: 'esm',
|
|
platform,
|
|
outdir,
|
|
outExtension: { '.js': '.mjs' },
|
|
external: externalModules,
|
|
tsconfig: tsconfigPath,
|
|
jsx: 'automatic',
|
|
sourcemap,
|
|
metafile,
|
|
logLevel,
|
|
minify,
|
|
plugins: getFrontComponentBuildPlugins(),
|
|
};
|
|
};
|