1+ import fs from 'fs' ;
2+ import path from 'path' ;
13import * as vite from 'vite' ;
24import { get_aliases } from '../utils.js' ;
35
@@ -44,14 +46,14 @@ export function find_deps(manifest, entry, add_dynamic_css) {
4446 const stylesheets = new Set ( ) ;
4547
4648 /**
47- * @param {string } file
49+ * @param {string } current
4850 * @param {boolean } add_js
4951 */
50- function traverse ( file , add_js ) {
51- if ( seen . has ( file ) ) return ;
52- seen . add ( file ) ;
52+ function traverse ( current , add_js ) {
53+ if ( seen . has ( current ) ) return ;
54+ seen . add ( current ) ;
5355
54- const chunk = manifest [ file ] ;
56+ const { chunk } = resolve_symlinks ( manifest , current ) ;
5557
5658 if ( add_js ) imports . add ( chunk . file ) ;
5759
@@ -68,15 +70,31 @@ export function find_deps(manifest, entry, add_dynamic_css) {
6870 }
6971 }
7072
71- traverse ( entry , true ) ;
73+ const { chunk, file } = resolve_symlinks ( manifest , entry ) ;
74+
75+ traverse ( file , true ) ;
7276
7377 return {
74- file : manifest [ entry ] . file ,
78+ file : chunk . file ,
7579 imports : Array . from ( imports ) ,
7680 stylesheets : Array . from ( stylesheets )
7781 } ;
7882}
7983
84+ /**
85+ * @param {import('vite').Manifest } manifest
86+ * @param {string } file
87+ */
88+ export function resolve_symlinks ( manifest , file ) {
89+ while ( ! manifest [ file ] ) {
90+ file = path . relative ( '.' , fs . realpathSync ( file ) ) ;
91+ }
92+
93+ const chunk = manifest [ file ] ;
94+
95+ return { chunk, file } ;
96+ }
97+
8098/**
8199 * The Vite configuration that we use by default.
82100 * @param {{
0 commit comments