@@ -116,6 +116,17 @@ async function verifyJWT(jwt: string): Promise<boolean> {
116116 return true ;
117117}
118118
119+ async function shouldUsePackageJsonDiscovery ( absDir : string ) : Promise < boolean > {
120+ const [ a , b , c , d ] = ( await Promise . allSettled ( [
121+ Deno . stat ( posix . join ( absDir , "deno.json" ) ) ,
122+ Deno . stat ( posix . join ( absDir , "deno.jsonc" ) ) ,
123+ Deno . stat ( posix . join ( absDir , "import_map.json" ) ) ,
124+ Deno . stat ( posix . join ( absDir , "package.json" ) ) ,
125+ ] ) ) . map ( v => v . status === "fulfilled" ) ;
126+
127+ return ! a && ! b && ! c && d ;
128+ }
129+
119130Deno . serve ( {
120131 handler : async ( req : Request ) => {
121132 const url = new URL ( req . url ) ;
@@ -178,6 +189,7 @@ Deno.serve({
178189
179190 const absEntrypoint = posix . join ( Deno . cwd ( ) , functionsConfig [ functionName ] . entrypointPath ) ;
180191 const maybeEntrypoint = posix . toFileUrl ( absEntrypoint ) . href ;
192+ const usePackageJsonDiscovery = await shouldUsePackageJsonDiscovery ( absEntrypoint ) ;
181193
182194 const staticPatterns = functionsConfig [ functionName ] . staticFiles ;
183195
@@ -187,6 +199,7 @@ Deno.serve({
187199 memoryLimitMb,
188200 workerTimeoutMs,
189201 noModuleCache,
202+ noNpm : ! usePackageJsonDiscovery ,
190203 importMapPath : functionsConfig [ functionName ] . importMapPath ,
191204 envVars,
192205 forceCreate,
0 commit comments