diff --git a/package-lock.json b/package-lock.json index 2631c1588..4bab66708 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/parser": "^7.22.5", "@babel/types": "7.23.0", "@netlify/binary-info": "^1.0.0", - "@netlify/serverless-functions-api": "^1.10.1", + "@netlify/serverless-functions-api": "^1.11.0", "@vercel/nft": "^0.23.0", "archiver": "^6.0.0", "common-path-prefix": "^3.0.0", @@ -1936,9 +1936,9 @@ } }, "node_modules/@netlify/serverless-functions-api": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.10.1.tgz", - "integrity": "sha512-KtaC+Z77HUxXEOPhmq4W773CTr0e1zIhXWZRONrfM1AkdphK5c5G+dItj+BQe6LorNSWNNVihBDA5h7WIF2nDQ==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.11.0.tgz", + "integrity": "sha512-3splAsr2CekL7VTwgo6yTvzD2+f269/s+TJafYazonqMNNo31yzvFxD5HpLtni4DNE1ppymVKZ4X/rLN3yl0vQ==", "dependencies": { "@netlify/node-cookies": "^0.1.0", "urlpattern-polyfill": "8.0.2" @@ -12329,9 +12329,9 @@ "integrity": "sha512-OAs1xG+FfLX0LoRASpqzVntVV/RpYkgpI0VrUnw2u0Q1qiZUzcPffxRK8HF3gc4GjuhG5ahOEMJ9bswBiZPq0g==" }, "@netlify/serverless-functions-api": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.10.1.tgz", - "integrity": "sha512-KtaC+Z77HUxXEOPhmq4W773CTr0e1zIhXWZRONrfM1AkdphK5c5G+dItj+BQe6LorNSWNNVihBDA5h7WIF2nDQ==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.11.0.tgz", + "integrity": "sha512-3splAsr2CekL7VTwgo6yTvzD2+f269/s+TJafYazonqMNNo31yzvFxD5HpLtni4DNE1ppymVKZ4X/rLN3yl0vQ==", "requires": { "@netlify/node-cookies": "^0.1.0", "urlpattern-polyfill": "8.0.2" diff --git a/package.json b/package.json index 01ffbe88f..7ed733fd8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@babel/parser": "^7.22.5", "@babel/types": "7.23.0", "@netlify/binary-info": "^1.0.0", - "@netlify/serverless-functions-api": "^1.10.1", + "@netlify/serverless-functions-api": "^1.11.0", "@vercel/nft": "^0.23.0", "archiver": "^6.0.0", "common-path-prefix": "^3.0.0", diff --git a/src/runtimes/node/utils/entry_file.ts b/src/runtimes/node/utils/entry_file.ts index fbb2d1d8b..2453d8ed5 100644 --- a/src/runtimes/node/utils/entry_file.ts +++ b/src/runtimes/node/utils/entry_file.ts @@ -31,13 +31,12 @@ const getEntryFileContents = ( if (runtimeAPIVersion === 2) { return [ - `import * as func from '${importPath}'`, `import * as bootstrap from './${BOOTSTRAP_FILE_NAME}'`, + `import * as func from '${importPath}'`, // See https://esbuild.github.io/content-types/#default-interop. 'const funcModule = typeof func.default === "function" ? func : func.default', - `global.Netlify = bootstrap.getNetlifyGlobal()`, `export const handler = bootstrap.getLambdaHandler(funcModule)`, ].join(';') } diff --git a/tests/fixtures-esm/v2-api-environment-variables/function.mjs b/tests/fixtures-esm/v2-api-environment-variables/function.mjs index 5110ffeda..3fd24b7ea 100644 --- a/tests/fixtures-esm/v2-api-environment-variables/function.mjs +++ b/tests/fixtures-esm/v2-api-environment-variables/function.mjs @@ -1,3 +1,5 @@ +const baz = Netlify.env.get('baz') + export default async () => { Netlify.env.set('bar', 'bar!') @@ -10,5 +12,6 @@ export default async () => { foo: Netlify.env.has('foo'), bar: Netlify.env.get('bar'), env: Netlify.env.toObject(), + baz, }) } diff --git a/tests/v2api.test.ts b/tests/v2api.test.ts index 4cd71448a..d6f33c037 100644 --- a/tests/v2api.test.ts +++ b/tests/v2api.test.ts @@ -480,6 +480,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => { }) vi.stubEnv('foo', 'foo!') + vi.stubEnv('baz', 'baz!') const [{ name: archive, entryFilename }] = files const func = await importFunctionFile(`${tmpDir}/${archive}/${entryFilename}`) @@ -494,6 +495,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => { env: expect.objectContaining({ foo: 'foo!', }), + baz: 'baz!', }) // bar got set and deleted again expect(parsed).not.toHaveProperty('bar')