fix(netlify): bundle netlify functions as ESM to support top-level await (#8661)
This commit is contained in:
parent
954cadc1e5
commit
008f7647c4
2 changed files with 16 additions and 1 deletions
5
.changeset/witty-carrots-applaud.md
Normal file
5
.changeset/witty-carrots-applaud.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/netlify': patch
|
||||
---
|
||||
|
||||
fix build failures because of CJS builds and top-level await
|
|
@ -1,5 +1,6 @@
|
|||
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
|
||||
import { extname } from 'node:path';
|
||||
import { extname, join } from 'node:path';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { generateEdgeMiddleware } from './middleware.js';
|
||||
import type { Args } from './netlify-functions.js';
|
||||
|
@ -85,6 +86,15 @@ function netlifyFunctions({
|
|||
}
|
||||
},
|
||||
'astro:build:done': async ({ routes, dir }) => {
|
||||
const functionsConfig = {
|
||||
version: 1,
|
||||
config: {
|
||||
nodeModuleFormat: "esm"
|
||||
}
|
||||
}
|
||||
const functionsConfigPath = join(fileURLToPath(_config.build.server), "entry.json")
|
||||
await writeFile(functionsConfigPath, JSON.stringify(functionsConfig))
|
||||
|
||||
const type = builders ? 'builders' : 'functions';
|
||||
const kind = type ?? 'functions';
|
||||
|
||||
|
|
Loading…
Reference in a new issue