mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
58d299ea42
# Description of Changes This PR removes the `@clockworklabs/typescript-sdk` from the repository and retains only `spacetimedb` in the `crates/bindings-typescript` directory. Some files are migrated to `spacetimedb`. I have also updated the appropriate READMEs. In addition I have symlinked the old `sdks/typescript` directory to point to `crates/bindings-typescript`. # API and ABI breaking changes This is not technically a breaking change of any kind, although it does orphan and deprecate the [@clockworklabs/spacetimedb-sdk](https://www.npmjs.com/package/@clockworklabs/spacetimedb-sdk) npm package. This package will no longer work with SpacetimeDB. Users should now install and use the `spacetimedb` package. # Expected complexity level and risk 2, it's a straightforward change but affects many files. # Testing - [ ] I ran `pnpm test` in the `spacetimedb` package - [ ] I ran the quickstart app --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
185 lines
4.8 KiB
TypeScript
185 lines
4.8 KiB
TypeScript
// tsup.config.ts
|
|
import { defineConfig, type Options } from 'tsup';
|
|
|
|
function commonEsbuildTweaks() {
|
|
return (options: any) => {
|
|
// Prefer "exports"."development" when deps provide it; harmless otherwise.
|
|
options.conditions = ['development', 'import', 'default'];
|
|
options.mainFields = ['browser', 'module', 'main'];
|
|
};
|
|
}
|
|
|
|
const outExtension = (ctx: { format: string }) => ({
|
|
js: ctx.format === 'cjs' ? '.cjs' : ctx.format === 'esm' ? '.mjs' : '.js',
|
|
});
|
|
|
|
export default defineConfig([
|
|
// Root wrapper (SSR-friendly): dist/index.{mjs,cjs}
|
|
{
|
|
entry: { index: 'src/index.ts' },
|
|
format: ['esm', 'cjs'],
|
|
target: 'es2022',
|
|
outDir: 'dist',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'neutral',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// Browser-flavored root wrapper: dist/index.browser.mjs
|
|
{
|
|
entry: { 'index.browser': 'src/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'browser',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// React subpath (SSR-friendly): dist/react/index.{mjs,cjs}
|
|
{
|
|
entry: { index: 'src/react/index.ts' },
|
|
format: ['esm', 'cjs'],
|
|
target: 'es2022',
|
|
outDir: 'dist/react',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'neutral',
|
|
treeshake: 'smallest',
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// React subpath (browser ESM): dist/browser/react/index.mjs
|
|
{
|
|
entry: { index: 'src/react/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist/browser/react',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'browser',
|
|
treeshake: 'smallest',
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// SDK subpath (SSR-friendly): dist/sdk/index.{mjs,cjs}
|
|
{
|
|
entry: { index: 'src/sdk/index.ts' },
|
|
format: ['esm', 'cjs'],
|
|
target: 'es2022',
|
|
outDir: 'dist/sdk',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'neutral',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// SDK browser ESM: dist/sdk/index.browser.mjs
|
|
{
|
|
entry: { 'index.browser': 'src/sdk/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist/sdk',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'browser',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// Server subpath (SSR / node-friendly): dist/server/index.{mjs,cjs}
|
|
{
|
|
entry: { index: 'src/server/index.ts' },
|
|
format: ['esm', 'cjs'],
|
|
target: 'es2022',
|
|
outDir: 'dist/server',
|
|
dts: false,
|
|
sourcemap: true,
|
|
clean: true,
|
|
platform: 'neutral', // flip to 'node' if you actually rely on Node builtins
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// The below minified builds are not referenced in package.json and are
|
|
// just included in the build for measuring the size impact of minification.
|
|
// It is expected that consumers of the library will run their own
|
|
// minification as part of their app bundling process.
|
|
|
|
// Minified browser build: dist/min/index.browser.mjs
|
|
{
|
|
entry: { 'index.browser': 'src/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist/min',
|
|
dts: false,
|
|
sourcemap: true,
|
|
minify: 'terser',
|
|
platform: 'browser',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension,
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// Minified browser React build: dist/min/react/index.mjs
|
|
{
|
|
entry: { index: 'src/react/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist/min/react',
|
|
dts: false,
|
|
sourcemap: true,
|
|
minify: 'terser',
|
|
platform: 'browser',
|
|
external: ['undici'],
|
|
treeshake: 'smallest',
|
|
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.mjs' }),
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
|
|
// Minified browser SDK build: dist/min/sdk/index.browser.mjs
|
|
{
|
|
entry: { 'index.browser': 'src/sdk/index.ts' },
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist/min/sdk',
|
|
dts: false,
|
|
sourcemap: true,
|
|
minify: 'terser',
|
|
platform: 'browser',
|
|
treeshake: 'smallest',
|
|
external: ['undici'],
|
|
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.mjs' }),
|
|
esbuildOptions: commonEsbuildTweaks(),
|
|
},
|
|
]) satisfies
|
|
| Options
|
|
| Options[]
|
|
| ((
|
|
overrideOptions: Options
|
|
) => Options | Options[] | Promise<Options | Options[]>);
|