File tree Expand file tree Collapse file tree 3 files changed +35
-29
lines changed Expand file tree Collapse file tree 3 files changed +35
-29
lines changed Original file line number Diff line number Diff line change 77 "module" : " dist/index.js" ,
88 "types" : " dist/index.d.ts" ,
99 "scripts" : {
10- "build" : " tsup && vite build && block-tools build-model" ,
10+ "build" : " vite build && BUILD_UMD=true vite build && block-tools build-model" ,
1111 "lint" : " eslint ."
1212 },
1313 "dependencies" : {
1717 "@platforma-sdk/block-tools" : " catalog:" ,
1818 "typescript" : " catalog:" ,
1919 "vite" : " catalog:" ,
20- "tsup " : " catalog:" ,
20+ "vite-plugin-dts " : " catalog:" ,
2121 "@platforma-sdk/eslint-config" : " catalog:"
22- },
23- "tsup" : {
24- "entry" : [
25- " src/index.ts"
26- ],
27- "splitting" : false ,
28- "treeshake" : true ,
29- "clean" : true ,
30- "format" : [
31- " cjs" ,
32- " esm"
33- ],
34- "dts" : true ,
35- "minify" : false ,
36- "sourcemap" : true
3722 }
3823}
Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite' ;
2+ import { resolve } from 'path' ;
3+ import dts from 'vite-plugin-dts' ;
4+
5+ // Check if we're building UMD format specifically
6+ const buildingUMD = process . env . BUILD_UMD === 'true' ;
27
38export default defineConfig ( {
9+ plugins : [
10+ dts ( {
11+ insertTypesEntry : true ,
12+ rollupTypes : true ,
13+ outDir : 'dist' ,
14+ } ) ,
15+ ] ,
416 build : {
517 emptyOutDir : false ,
18+ minify : false ,
19+ // Use SSR mode for ES/CJS to automatically externalize dependencies
20+ ssr : ! buildingUMD ,
621 lib : {
7- entry : 'src/index.ts' ,
8- name : 'model' ,
9- fileName : ( format ) => `my-lib.${ format } .js`
22+ entry : resolve ( __dirname , 'src/index.ts' ) ,
23+ formats : buildingUMD ? [ 'umd' ] : [ 'es' , 'cjs' ] ,
24+ fileName : ( format ) => {
25+ switch ( format ) {
26+ case 'es' :
27+ return 'index.js' ;
28+ case 'cjs' :
29+ return 'index.cjs' ;
30+ case 'umd' :
31+ return 'bundle.js' ;
32+ default :
33+ return `index.${ format } .js` ;
34+ }
35+ } ,
36+ name : 'model' , // Global variable name for UMD
1037 } ,
11- minify : false ,
1238 sourcemap : true ,
13- rollupOptions : {
14- output : {
15- format : 'iife' ,
16- entryFileNames : 'bundle.js'
17- }
18- }
19- }
39+ } ,
2040} ) ;
41+
Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ catalog:
2222 " vue-tsc " : ^2.2.10
2323
2424 " typescript " : ~5.5.4
25- " tsup " : ~8.1.2
2625 " turbo " : ^2.5.4
2726
2827 " vite " : ^6.3.5
2928 " vitest " : ~2.1.9
3029 " @vitejs/plugin-vue " : ^5.2.4
30+ " vite-plugin-dts " : ^4.3.0
3131
3232 " @changesets/cli " : ^2.29.5
3333 " js-yaml " : " ^4.1.0"
You can’t perform that action at this time.
0 commit comments