Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 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 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