Skip to content

Commit

Permalink
feat!: provide import maps when starting the isolate, not server (net…
Browse files Browse the repository at this point in the history
…lify/edge-bundler#548)

* feat!: provide import maps when starting the isolate, not server

* fix: tests

* chore: remove unused type
  • Loading branch information
Skn0tt authored Dec 11, 2023
1 parent 2f374c2 commit 53a9366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/edge-bundler/node/server/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
19 changes: 5 additions & 14 deletions packages/edge-bundler/node/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ interface PrepareServerOptions {
flags: string[]
formatExportTypeError?: FormatFunction
formatImportError?: FormatFunction
importMap: ImportMap
logger: Logger
port: number
rootPath?: string
}

interface StartServerOptions {
getFunctionsConfig?: boolean
importMapPaths?: string[]
}

/**
Expand All @@ -57,7 +57,6 @@ const prepareServer = ({
flags: denoFlags,
formatExportTypeError,
formatImportError,
importMap: baseImportMap,
logger,
port,
rootPath,
Expand Down Expand Up @@ -88,7 +87,10 @@ const prepareServer = ({
})

const features: Record<string, boolean> = {}
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
Expand Down Expand Up @@ -181,7 +183,6 @@ interface ServeOptions {
distImportMapPath?: string
featureFlags?: FeatureFlags
inspectSettings?: InspectSettings
importMapPaths?: string[]
onAfterDownload?: OnAfterDownloadHook
onBeforeDownload?: OnBeforeDownloadHook
formatExportTypeError?: FormatFunction
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -323,10 +319,6 @@ export const serve = async ({
}
}

const importMap = new ImportMap()

await importMap.addFiles(importMapPaths, logger)

const server = prepareServer({
basePath,
bootstrapURL,
Expand All @@ -337,7 +329,6 @@ export const serve = async ({
flags,
formatExportTypeError,
formatImportError,
importMap,
logger,
port,
rootPath,
Expand Down

0 comments on commit 53a9366

Please sign in to comment.