Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup && vite build && block-tools build-model",
"build": "vite build && BUILD_UMD=true vite build && block-tools build-model",
"lint": "eslint ."
},
"dependencies": {
Expand All @@ -17,22 +17,7 @@
"@platforma-sdk/block-tools": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"tsup": "catalog:",
"vite-plugin-dts": "catalog:",
"@platforma-sdk/eslint-config": "catalog:"
},
"tsup": {
"entry": [
"src/index.ts"
],
"splitting": false,
"treeshake": true,
"clean": true,
"format": [
"cjs",
"esm"
],
"dts": true,
"minify": false,
"sourcemap": true
}
}
43 changes: 32 additions & 11 deletions model/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import { defineConfig } from 'vite';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';

// Check if we're building UMD format specifically
const buildingUMD = process.env.BUILD_UMD === 'true';

export default defineConfig({
plugins: [
dts({
insertTypesEntry: true,
rollupTypes: true,
outDir: 'dist',
}),
],
build: {
emptyOutDir: false,
minify: false,
// Use SSR mode for ES/CJS to automatically externalize dependencies
ssr: !buildingUMD,
lib: {
entry: 'src/index.ts',
name: 'model',
fileName: (format) => `my-lib.${format}.js`
entry: resolve(__dirname, 'src/index.ts'),
formats: buildingUMD ? ['umd'] : ['es', 'cjs'],
fileName: (format) => {
switch (format) {
case 'es':
return 'index.js';
case 'cjs':
return 'index.cjs';
case 'umd':
return 'bundle.js';
default:
return `index.${format}.js`;
}
},
name: 'model', // Global variable name for UMD
},
minify: false,
sourcemap: true,
rollupOptions: {
output: {
format: 'iife',
entryFileNames: 'bundle.js'
}
}
}
},
});

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ catalog:
"vue-tsc": ^2.2.10

"typescript": ~5.5.4
"tsup": ~8.1.2
"turbo": ^2.5.4

"vite": ^6.3.5
"vitest": ~2.1.9
"@vitejs/plugin-vue": ^5.2.4
"vite-plugin-dts": ^4.3.0

"@changesets/cli": ^2.29.5
"js-yaml": "^4.1.0"