0befb021d0
- moves workspace:* dependencies to dev-dependencies to avoid spreading them in npm releases - remove fix on rollup.external - remove prepublishOnly and postpublish scripts - set bundle packages to private - add release-dump-version that update package.json version before releasing to npm - add release-verify-build that check no externalized twenty package exists in `dist` before releasing to npm - works with new release github action here -> https://github.com/twentyhq/twenty-infra/pull/397
101 lines
2.5 KiB
TypeScript
101 lines
2.5 KiB
TypeScript
import path from 'path';
|
|
import { type PackageJson } from 'type-fest';
|
|
import { defineConfig } from 'vite';
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
import packageJson from './package.json';
|
|
|
|
const entries = ['src/ui/index.ts', 'src/front-component-renderer/index.ts'];
|
|
|
|
const entryFileNames = (chunk: any, extension: 'cjs' | 'mjs') => {
|
|
if (!chunk.isEntry) {
|
|
throw new Error(
|
|
`Should never occur, encountered a non-entry chunk ${chunk.facadeModuleId}`,
|
|
);
|
|
}
|
|
|
|
const entry = entries.find((entryPath) =>
|
|
chunk.facadeModuleId?.endsWith(entryPath),
|
|
);
|
|
|
|
if (!entry) {
|
|
return `${chunk.name}.${extension}`;
|
|
}
|
|
|
|
// Remove 'src/' prefix and '/index.ts' suffix to get the module path
|
|
const modulePath = entry.replace('src/', '').replace('/index.ts', '');
|
|
|
|
return `${modulePath}/index.${extension}`;
|
|
};
|
|
|
|
export default defineConfig(() => {
|
|
return {
|
|
root: __dirname,
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-sdk-browser',
|
|
resolve: {
|
|
alias: {
|
|
'@/': path.resolve(__dirname, 'src') + '/',
|
|
},
|
|
},
|
|
plugins: [
|
|
tsconfigPaths({
|
|
root: __dirname,
|
|
}),
|
|
],
|
|
worker: {
|
|
format: 'iife',
|
|
rollupOptions: {
|
|
output: {
|
|
inlineDynamicImports: true,
|
|
},
|
|
},
|
|
plugins: () => [
|
|
{
|
|
name: 'define-process-env',
|
|
transform: (code: string) =>
|
|
code
|
|
.replace(/process\.env\.NODE_ENV/g, JSON.stringify('production'))
|
|
.replace(/process\.env/g, '{}'),
|
|
},
|
|
],
|
|
},
|
|
build: {
|
|
emptyOutDir: false,
|
|
outDir: 'dist',
|
|
lib: { entry: entries, 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) => entryFileNames(chunk, 'mjs'),
|
|
},
|
|
{
|
|
format: 'cjs',
|
|
interop: 'auto',
|
|
esModule: true,
|
|
exports: 'named',
|
|
entryFileNames: (chunk) => entryFileNames(chunk, 'cjs'),
|
|
},
|
|
],
|
|
},
|
|
},
|
|
logLevel: 'warn',
|
|
};
|
|
});
|