@@ -51,7 +51,7 @@ export async function build(serverEntry?: string) {
51
51
return [ filename , exportNames ] ;
52
52
} ) ) ;
53
53
}
54
- const port = Deno . env . get ( "ALEPH_MODULES_PROXY_PORT" ) ;
54
+ const modulesProxyPort = Deno . env . get ( "ALEPH_MODULES_PROXY_PORT" ) ;
55
55
const serverEntryCode = [
56
56
`import { DependencyGraph } from "${ alephPkgUri } /server/graph.ts";` ,
57
57
`import graph from "./server_dependency_graph.js";` ,
@@ -86,7 +86,7 @@ export async function build(serverEntry?: string) {
86
86
if ( ! hasDefaultExport && ! hasDataExport ) {
87
87
return [ ] ;
88
88
}
89
- const url = `http://localhost:${ port } ${ filename . slice ( 1 ) } ` ;
89
+ const url = `http://localhost:${ modulesProxyPort } ${ filename . slice ( 1 ) } ` ;
90
90
return [
91
91
`import { ${
92
92
[
@@ -102,7 +102,7 @@ export async function build(serverEntry?: string) {
102
102
} });`,
103
103
] ;
104
104
} ) ,
105
- serverEntry && `import "http://localhost:${ port } /${ basename ( serverEntry ) } ";` ,
105
+ serverEntry && `import "http://localhost:${ modulesProxyPort } /${ basename ( serverEntry ) } ";` ,
106
106
! serverEntry && `import { serve } from "${ alephPkgUri } /server/mode.ts";` ,
107
107
! serverEntry && `serve();` ,
108
108
] . flat ( ) . filter ( Boolean ) . join ( "\n" ) ;
@@ -125,15 +125,15 @@ export async function build(serverEntry?: string) {
125
125
) ;
126
126
}
127
127
128
- const forceBundle = ( importUrl : string ) => {
128
+ const shouldBundle = ( importUrl : string ) => {
129
129
return importUrl === alephPkgUri + "/server/mod.ts" ||
130
130
importUrl === alephPkgUri + "/server/transformer.ts" ||
131
131
// since deno deploy doesn't support importMap, we need to resolve the 'react' import
132
132
importUrl . startsWith ( alephPkgUri + "/framework/react/" ) ||
133
- importUrl . startsWith ( `http://localhost:${ Deno . env . get ( "ALEPH_MODULES_PROXY_PORT" ) } /` ) ;
133
+ importUrl . startsWith ( `http://localhost:${ modulesProxyPort } /` ) ;
134
134
} ;
135
135
136
- // build server entry
136
+ // build the server entry
137
137
await esbuild ( {
138
138
stdin : {
139
139
contents : serverEntryCode ,
@@ -144,7 +144,7 @@ export async function build(serverEntry?: string) {
144
144
format : "esm" ,
145
145
target : [ "esnext" ] ,
146
146
bundle : true ,
147
- minify : ! Deno . env . get ( "ALEPH_DEV_PORT " ) ,
147
+ minify : ! Deno . env . get ( "ALEPH_DEV " ) ,
148
148
treeShaking : true ,
149
149
sourcemap : true ,
150
150
jsxFactory : jsxCofig . jsxRuntime === "preact" ? "h" : "React.createElement" ,
@@ -156,6 +156,7 @@ export async function build(serverEntry?: string) {
156
156
build . onResolve ( { filter : / .* / } , ( args ) => {
157
157
let importUrl = args . path ;
158
158
if ( importUrl in importMap . imports ) {
159
+ // since deno deploy doesn't support importMap, we need to resolve the 'react' import
159
160
importUrl = importMap . imports [ importUrl ] ;
160
161
}
161
162
@@ -168,13 +169,13 @@ export async function build(serverEntry?: string) {
168
169
169
170
if ( args . namespace === "http" ) {
170
171
const { href } = new URL ( path , args . importer ) ;
171
- if ( ! forceBundle ( href ) ) {
172
+ if ( ! shouldBundle ( href ) ) {
172
173
return { path : href , external : true } ;
173
174
}
174
175
return { path : href , namespace : "http" } ;
175
176
}
176
177
177
- if ( isRemote && forceBundle ( path ) ) {
178
+ if ( isRemote && shouldBundle ( path ) ) {
178
179
return { path, namespace : "http" } ;
179
180
}
180
181
@@ -258,6 +259,7 @@ export async function build(serverEntry?: string) {
258
259
while ( tasks . length > 0 ) {
259
260
const deps = new Set < string > ( ) ;
260
261
await Promise . all ( tasks . map ( async ( specifier ) => {
262
+ clientModules . add ( specifier ) ;
261
263
const url = new URL ( util . isLikelyHttpURL ( specifier ) ? toLocalPath ( specifier ) : specifier , "http://localhost" ) ;
262
264
const isCSS = url . pathname . endsWith ( ".css" ) ;
263
265
const req = new Request ( url . toString ( ) ) ;
@@ -273,7 +275,6 @@ export async function build(serverEntry?: string) {
273
275
Deno . open ( savePath , { write : true , create : true } ) ,
274
276
] ) ;
275
277
await res . body ?. pipeTo ( file . writable ) ;
276
- clientModules . add ( specifier ) ;
277
278
if ( ! isCSS ) {
278
279
const clientDependencyGraph : DependencyGraph | undefined = Reflect . get ( globalThis , "clientDependencyGraph" ) ;
279
280
clientDependencyGraph ?. get ( specifier ) ?. deps ?. forEach ( ( { specifier } ) => {
0 commit comments