@@ -47,7 +47,14 @@ async function loadTw4Deps() {
4747 */
4848export function createModuleLoader ( baseDir : string ) {
4949 return async ( id : string , base : string ) => {
50- const resolved = resolveModulePath ( id , { from : base || baseDir } )
50+ // Use suffixes + extensions to handle packages without an `exports` map
51+ // (e.g. daisyui/theme resolves to daisyui/theme/index.js)
52+ const resolved = resolveModulePath ( id , {
53+ from : base || baseDir ,
54+ try : true ,
55+ suffixes : [ '' , '/index' ] ,
56+ extensions : [ '.js' , '.mjs' , '.cjs' ] ,
57+ } )
5158 if ( resolved ) {
5259 const module = await import ( pathToFileURL ( resolved ) . href ) . then ( m => m . default || m )
5360 return { path : resolved , base : dirname ( resolved ) , module }
@@ -66,7 +73,7 @@ export function createStylesheetLoader(baseDir: string) {
6673 return async ( id : string , base : string ) => {
6774 // Handle tailwindcss import
6875 if ( id === 'tailwindcss' ) {
69- const twPath = resolveModulePath ( 'tailwindcss/index.css' , { from : baseDir } )
76+ const twPath = resolveModulePath ( 'tailwindcss/index.css' , { from : baseDir , try : true } )
7077 if ( twPath ) {
7178 const content = await readFile ( twPath , 'utf-8' ) . catch ( ( ) => '' )
7279 if ( content )
@@ -85,7 +92,13 @@ export function createStylesheetLoader(baseDir: string) {
8592 return { path : resolved , base : dirname ( resolved ) , content }
8693 }
8794 // Handle node_modules imports (e.g., @nuxt/ui)
88- const resolved = resolveModulePath ( id , { from : base || baseDir , conditions : [ 'style' ] } )
95+ const resolved = resolveModulePath ( id , {
96+ from : base || baseDir ,
97+ conditions : [ 'style' ] ,
98+ try : true ,
99+ suffixes : [ '' , '/index' ] ,
100+ extensions : [ '.css' , '.js' , '.mjs' ] ,
101+ } )
89102 if ( resolved ) {
90103 const content = await readFile ( resolved , 'utf-8' ) . catch ( ( ) => '' )
91104 return { path : resolved , base : dirname ( resolved ) , content }
0 commit comments