Vendor twenty-shared into twenty-sdk (#16592)

twenty-shared is not bundled properly when deploying twenty-sdk to npm.
This aims to fix that issue
This commit is contained in:
martmull
2025-12-16 16:48:38 +01:00
committed by GitHub
parent 38a0bba57b
commit 9b00084fb0
8 changed files with 46 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "create-twenty-app",
"version": "0.2.0",
"version": "0.2.1",
"description": "Command-line interface to create Twenty application",
"main": "dist/cli.cjs",
"bin": "dist/cli.cjs",
@@ -127,7 +127,7 @@ const createPackageJson = async ({
auth: 'twenty auth login',
},
dependencies: {
'twenty-sdk': '0.2.0',
'twenty-sdk': '0.2.1',
},
devDependencies: {
'@types/node': '^24.7.2',
@@ -1,6 +1,6 @@
{
"name": "hello-world",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"engines": {
"node": "^24.5.0",
@@ -17,7 +17,7 @@
"auth": "twenty auth login"
},
"dependencies": {
"twenty-sdk": "0.2.0"
"twenty-sdk": "0.2.1"
},
"devDependencies": {
"@types/node": "^24.7.2"
+4 -4
View File
@@ -1083,7 +1083,7 @@ __metadata:
resolution: "hello-world@workspace:."
dependencies:
"@types/node": "npm:^24.7.2"
twenty-sdk: "npm:0.2.0"
twenty-sdk: "npm:0.2.1"
languageName: unknown
linkType: soft
@@ -1904,9 +1904,9 @@ __metadata:
languageName: node
linkType: hard
"twenty-sdk@npm:0.2.0":
version: 0.2.0
resolution: "twenty-sdk@npm:0.2.0"
"twenty-sdk@npm:0.2.1":
version: 0.2.1
resolution: "twenty-sdk@npm:0.2.1"
dependencies:
"@genql/cli": "npm:^3.0.3"
axios: "npm:^1.6.0"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "twenty-sdk",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
@@ -26,6 +26,7 @@ export const config: FunctionConfig = {
universalIdentifier: '71e45a58-41da-4ae4-8b73-a543c0a9d3d4',
name: 'serverless-function-name',
timeoutSeconds: 5,
triggers: [],
};
`);
@@ -29,6 +29,7 @@ export const config: FunctionConfig = {
universalIdentifier: '${universalIdentifier}',
name: '${kebabCaseName}',
timeoutSeconds: 5,
triggers: [],
};
`;
+35
View File
@@ -1,3 +1,4 @@
import * as fs from 'fs-extra';
import path from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
@@ -30,6 +31,21 @@ const entryFileNames = (chunk: any, extension: 'cjs' | 'mjs') => {
}
return `${moduleDirectory}.${extension}`;
};
const copySharedDist = () => {
return {
name: 'copy-twenty-shared-dist',
closeBundle: async () => {
const sharedDist = path.resolve(__dirname, '../twenty-shared/dist');
const vendorDist = path.resolve(__dirname, 'dist/vendor/twenty-shared');
await fs.remove(vendorDist);
await fs.ensureDir(path.dirname(vendorDist));
await fs.copy(sharedDist, vendorDist);
},
};
};
export default defineConfig(() => {
const tsConfigPath = path.resolve(__dirname, './tsconfig.lib.json');
@@ -40,10 +56,29 @@ export default defineConfig(() => {
tsconfigPaths({
root: __dirname,
}),
copySharedDist(),
dts({
entryRoot: './src',
tsconfigPath: tsConfigPath,
exclude: ['vite.config.ts'],
beforeWriteFile: (filePath, content) => {
const fromDir = path.dirname(filePath);
const vendorDir = path.resolve(process.cwd(), 'dist/vendor');
let rel = path
.relative(fromDir, vendorDir)
.split(path.sep)
.join(path.posix.sep);
if (!rel.startsWith('.')) rel = `./${rel}`;
return {
filePath,
content: content.replace(
/(from\s+["'])twenty-shared(\/[^"']*)?(["'])/g,
`$1${rel}/twenty-shared$2$3`,
),
};
},
}),
],
build: {