File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1+ import { existsSync } from 'node:fs' ;
2+ import path from 'node:path' ;
13import type { BunPlugin } from 'bun' ;
24
35const root = import . meta. dir ;
6+ const pkgSrc = path . resolve ( root , '../../packages/classy-store/src' ) ;
47
58const dedupeReact : BunPlugin = {
6- name : 'dedupe-react ' ,
9+ name : 'dedupe-packages ' ,
710 setup ( build ) {
811 build . onResolve ( { filter : / ^ r e a c t ( - d o m ) ? ( \/ .* ) ? $ / } , ( args ) => ( {
912 path : Bun . resolveSync ( args . path , root ) ,
1013 } ) ) ;
14+ // Resolve all @codebelt /classy-store imports to source files
15+ // to avoid duplicate module instances (src vs dist).
16+ build . onResolve (
17+ { filter : / ^ @ c o d e b e l t \/ c l a s s y - s t o r e ( \/ .* ) ? $ / } ,
18+ ( args ) => {
19+ const subpath = args . path . replace ( '@codebelt/classy-store' , '' ) ;
20+ if ( ! subpath || subpath === '/' ) {
21+ return { path : path . join ( pkgSrc , 'index.ts' ) } ;
22+ }
23+ const name = subpath . slice ( 1 ) ;
24+ const direct = path . join ( pkgSrc , name , `${ name } .ts` ) ;
25+ if ( existsSync ( direct ) ) return { path : direct } ;
26+ return { path : path . join ( pkgSrc , name , 'index.ts' ) } ;
27+ } ,
28+ ) ;
1129 } ,
1230} ;
1331
You can’t perform that action at this time.
0 commit comments