diff --git a/packages/create-twenty-app/package.json b/packages/create-twenty-app/package.json index 5c3f8a8157..e68ab30823 100644 --- a/packages/create-twenty-app/package.json +++ b/packages/create-twenty-app/package.json @@ -1,6 +1,6 @@ { "name": "create-twenty-app", - "version": "1.22.0-canary.3", + "version": "1.22.0-canary.4", "description": "Command-line interface to create Twenty application", "main": "dist/cli.cjs", "bin": "dist/cli.cjs", diff --git a/packages/twenty-client-sdk/package.json b/packages/twenty-client-sdk/package.json index c1d4bc4afb..e08d38948e 100644 --- a/packages/twenty-client-sdk/package.json +++ b/packages/twenty-client-sdk/package.json @@ -1,6 +1,6 @@ { "name": "twenty-client-sdk", - "version": "1.22.0-canary.3", + "version": "1.22.0-canary.4", "sideEffects": false, "license": "AGPL-3.0", "scripts": { diff --git a/packages/twenty-sdk/package.json b/packages/twenty-sdk/package.json index c3398dffb1..8a214b5c18 100644 --- a/packages/twenty-sdk/package.json +++ b/packages/twenty-sdk/package.json @@ -1,6 +1,6 @@ { "name": "twenty-sdk", - "version": "1.22.0-canary.3", + "version": "1.22.0-canary.4", "main": "dist/index.cjs", "module": "dist/index.mjs", "types": "dist/sdk/index.d.ts", @@ -83,6 +83,7 @@ "@types/node": "^24.0.0", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", + "rollup-plugin-dts": "^6.4.1", "ts-morph": "^25.0.0", "tsx": "^4.7.0", "twenty-shared": "workspace:*", diff --git a/packages/twenty-sdk/project.json b/packages/twenty-sdk/project.json index 28afe5bed8..2e88e6b00a 100644 --- a/packages/twenty-sdk/project.json +++ b/packages/twenty-sdk/project.json @@ -15,7 +15,8 @@ "cwd": "{projectRoot}", "commands": [ "npx rimraf dist && npx vite build -c vite.config.node.ts && npx vite build -c vite.config.browser.ts && npx vite build -c vite.config.sdk.ts", - "tsgo -p tsconfig.lib.json --declaration --emitDeclarationOnly --noEmit false --outDir dist --rootDir src && npx tsc-alias -p tsconfig.lib.json --outDir dist" + "tsgo -p tsconfig.lib.json --declaration --emitDeclarationOnly --noEmit false --outDir dist --rootDir src && npx tsc-alias -p tsconfig.lib.json --outDir dist", + "npx rimraf 'dist/sdk/**/*.d.ts' 'dist/sdk/**/*.d.ts.map' && npx rollup -c rollup.config.sdk-dts.mjs" ], "parallel": false } @@ -25,7 +26,7 @@ "dependsOn": ["^build"], "options": { "cwd": "packages/twenty-sdk", - "command": "npx rimraf dist && npx vite build -c vite.config.node.ts && npx vite build -c vite.config.browser.ts && npx vite build -c vite.config.sdk.ts && tsgo -p tsconfig.lib.json --declaration --emitDeclarationOnly --noEmit false --outDir dist --rootDir src && npx tsc-alias -p tsconfig.lib.json --outDir dist && npx vite build -c vite.config.node.ts --watch & npx vite build -c vite.config.browser.ts --watch & npx vite build -c vite.config.sdk.ts --watch" + "command": "npx rimraf dist && npx vite build -c vite.config.node.ts && npx vite build -c vite.config.browser.ts && npx vite build -c vite.config.sdk.ts && tsgo -p tsconfig.lib.json --declaration --emitDeclarationOnly --noEmit false --outDir dist --rootDir src && npx tsc-alias -p tsconfig.lib.json --outDir dist && npx rimraf 'dist/sdk/**/*.d.ts' 'dist/sdk/**/*.d.ts.map' && npx rollup -c rollup.config.sdk-dts.mjs && npx vite build -c vite.config.node.ts --watch & npx vite build -c vite.config.browser.ts --watch & npx vite build -c vite.config.sdk.ts --watch" } }, "start": { @@ -93,7 +94,7 @@ "outputs": ["{projectRoot}/dist/sdk"], "options": { "cwd": "{projectRoot}", - "command": "npx vite build -c vite.config.sdk.ts" + "command": "npx vite build -c vite.config.sdk.ts && npx rollup -c rollup.config.sdk-dts.mjs" } } } diff --git a/packages/twenty-sdk/rollup.config.sdk-dts.mjs b/packages/twenty-sdk/rollup.config.sdk-dts.mjs new file mode 100644 index 0000000000..da3d64bf5a --- /dev/null +++ b/packages/twenty-sdk/rollup.config.sdk-dts.mjs @@ -0,0 +1,26 @@ +import dts from 'rollup-plugin-dts'; + +// Generates a self-contained SDK declaration file directly from source, +// inlining types from twenty-shared so npm consumers don't need it. +export default { + input: 'src/sdk/index.ts', + output: { + file: 'dist/sdk/index.d.ts', + format: 'es', + }, + external: (id) => { + if (id === 'twenty-shared' || id.startsWith('twenty-shared/')) { + return false; + } + if (id.startsWith('@/')) { + return false; + } + return !id.startsWith('.') && !id.startsWith('/'); + }, + plugins: [ + dts({ + tsconfig: './tsconfig.lib.json', + respectExternal: true, + }), + ], +}; diff --git a/yarn.lock b/yarn.lock index b33fcb513f..c558cbae9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56013,6 +56013,25 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-dts@npm:^6.4.1": + version: 6.4.1 + resolution: "rollup-plugin-dts@npm:6.4.1" + dependencies: + "@babel/code-frame": "npm:^7.29.0" + "@jridgewell/remapping": "npm:^2.3.5" + "@jridgewell/sourcemap-codec": "npm:^1.5.5" + convert-source-map: "npm:^2.0.0" + magic-string: "npm:^0.30.21" + peerDependencies: + rollup: ^3.29.4 || ^4 + typescript: ^4.5 || ^5.0 || ^6.0 + dependenciesMeta: + "@babel/code-frame": + optional: true + checksum: 10c0/23d51f4780c5878cb31a45103da961e2e1f81fb830d4b53114931060b58ee431e44c561c1215d253477ad884ba50223dd2586fee704763db9a454cb1c6b97a1d + languageName: node + linkType: hard + "rollup-plugin-inject@npm:^3.0.0": version: 3.0.2 resolution: "rollup-plugin-inject@npm:3.0.2" @@ -60582,6 +60601,7 @@ __metadata: preact: "npm:^10.28.3" react: "npm:^19.0.0" react-dom: "npm:^19.0.0" + rollup-plugin-dts: "npm:^6.4.1" tinyglobby: "npm:^0.2.15" ts-morph: "npm:^25.0.0" tsx: "npm:^4.7.0"