diff --git a/packages/edge-bundler/node/server/server.test.ts b/packages/edge-bundler/node/server/server.test.ts index 8addea7e9d..81076ab5ee 100644 --- a/packages/edge-bundler/node/server/server.test.ts +++ b/packages/edge-bundler/node/server/server.test.ts @@ -22,7 +22,6 @@ test('Starts a server and serves requests for edge functions', async () => { const server = await serve({ basePath, bootstrapURL: 'https://edge.netlify.com/bootstrap/index-combined.ts', - importMapPaths, port, servePath, }) @@ -43,6 +42,7 @@ test('Starts a server and serves requests for edge functions', async () => { ] const options = { getFunctionsConfig: true, + importMapPaths, } const { features, functionsConfig, graph, success, npmSpecifiersWithExtraneousFiles } = await server( @@ -118,7 +118,6 @@ test('Serves edge functions in a monorepo setup', async () => { const server = await serve({ basePath, bootstrapURL: 'https://edge.netlify.com/bootstrap/index-combined.ts', - importMapPaths, port, rootPath, servePath, @@ -132,6 +131,7 @@ test('Serves edge functions in a monorepo setup', async () => { ] const options = { getFunctionsConfig: true, + importMapPaths, } const { features, functionsConfig, graph, success, npmSpecifiersWithExtraneousFiles } = await server( diff --git a/packages/edge-bundler/node/server/server.ts b/packages/edge-bundler/node/server/server.ts index 090cc01364..0d68b24cbf 100644 --- a/packages/edge-bundler/node/server/server.ts +++ b/packages/edge-bundler/node/server/server.ts @@ -27,7 +27,6 @@ interface PrepareServerOptions { flags: string[] formatExportTypeError?: FormatFunction formatImportError?: FormatFunction - importMap: ImportMap logger: Logger port: number rootPath?: string @@ -35,6 +34,7 @@ interface PrepareServerOptions { interface StartServerOptions { getFunctionsConfig?: boolean + importMapPaths?: string[] } /** @@ -57,7 +57,6 @@ const prepareServer = ({ flags: denoFlags, formatExportTypeError, formatImportError, - importMap: baseImportMap, logger, port, rootPath, @@ -88,7 +87,10 @@ const prepareServer = ({ }) const features: Record = {} - const importMap = baseImportMap.clone() + + const importMap = new ImportMap() + await importMap.addFiles(options.importMapPaths ?? [], logger) + const npmSpecifiersWithExtraneousFiles: string[] = [] // we keep track of the files that are relevant to the user's code, so we can clean up leftovers from past executions later @@ -181,7 +183,6 @@ interface ServeOptions { distImportMapPath?: string featureFlags?: FeatureFlags inspectSettings?: InspectSettings - importMapPaths?: string[] onAfterDownload?: OnAfterDownloadHook onBeforeDownload?: OnBeforeDownloadHook formatExportTypeError?: FormatFunction @@ -243,11 +244,6 @@ export const serve = async ({ */ formatImportError, - /** - * Paths to any additional import map files. - */ - importMapPaths = [], - /** * Callback function to be triggered after the Deno CLI has been downloaded. */ @@ -323,10 +319,6 @@ export const serve = async ({ } } - const importMap = new ImportMap() - - await importMap.addFiles(importMapPaths, logger) - const server = prepareServer({ basePath, bootstrapURL, @@ -337,7 +329,6 @@ export const serve = async ({ flags, formatExportTypeError, formatImportError, - importMap, logger, port, rootPath,