@@ -107,44 +107,9 @@ function toImportSpecifier(file: string) {
107107 return specifier ;
108108}
109109
110- async function islandImportLine (
111- file : string ,
112- i : number ,
113- directory : string ,
114- ) : Promise < string > {
115- const specifier = toImportSpecifier ( file ) ;
116- const moduleURL = new URL ( `file://${ directory } /${ specifier } ` ) ;
117- const module = await import ( moduleURL . href ) ;
118- const entries = Object . entries ( module ) ;
119-
120- const allExportsAreComponents = entries . every (
121- ( [ , exportedEntity ] ) => typeof exportedEntity === "function" ,
122- ) ;
123-
124- // if all exports are components, we can use the simple, existing form
125- if ( allExportsAreComponents ) {
126- return `${ JSON . stringify ( specifier ) } : $$${ i } ,` ;
127- }
128-
129- // if not all exports are components, list the component exports explicitly
130- const componentExports = entries
131- . filter ( ( [ , exportedEntity ] ) => typeof exportedEntity === "function" )
132- . map ( ( [ exportName ] ) => exportName ) ;
133-
134- const exportsString = componentExports
135- . map ( ( exp ) => `${ exp } : $$${ i } .${ exp } ` )
136- . join ( ", " ) ;
137-
138- return `"${ specifier } ": { ${ exportsString } },` ;
139- }
140-
141110export async function generate ( directory : string , manifest : Manifest ) {
142111 const { routes, islands } = manifest ;
143112
144- const islandImports = await Promise . all (
145- islands . map ( ( file , i ) => islandImportLine ( file , i , directory ) ) ,
146- ) ;
147-
148113 const output = `// DO NOT EDIT. This file is generated by Fresh.
149114// This file SHOULD be checked into source version control.
150115// This file is automatically updated during development when running \`dev.ts\`.
162127 )
163128 . join ( "\n" )
164129 }
165- import { Manifest } from "$fresh/server.ts";
166130
167131const manifest = {
168132 routes: {
@@ -174,10 +138,15 @@ const manifest = {
174138 }
175139 },
176140 islands: {
177- ${ islandImports . join ( "\n " ) }
141+ ${
142+ islands . map ( ( file , i ) =>
143+ `${ JSON . stringify ( `${ toImportSpecifier ( file ) } ` ) } : $$${ i } ,`
144+ )
145+ . join ( "\n " )
146+ }
178147 },
179148 baseUrl: import.meta.url,
180- } satisfies Manifest ;
149+ };
181150
182151export default manifest;
183152` ;
0 commit comments