From 59a11ec353a3732fa7360d075facd506aba4f1c9 Mon Sep 17 00:00:00 2001 From: jake champion Date: Thu, 28 Aug 2025 08:49:51 +0100 Subject: [PATCH 1/2] Implement a mock Netlify global based upon the published NetlifyGlobal interface We no longer publish the actual implementation of our Netlify global for edge functions, we only publish the types This file is used for parsing the 'in-source configuration' - which is why using a simple implementation for the Netlify global such as the one provided should be good enough Her eis the previous PR which added the Netlify global into this file for context -- https://github.com/netlify/edge-bundler/pull/427 --- packages/edge-bundler/deno/config.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/edge-bundler/deno/config.ts b/packages/edge-bundler/deno/config.ts index 9377184e93..0fb247b981 100644 --- a/packages/edge-bundler/deno/config.ts +++ b/packages/edge-bundler/deno/config.ts @@ -1,9 +1,23 @@ -// this needs to be updated whenever there's a change to globalThis.Netlify in bootstrap -import { Netlify } from "https://64e8753eae24930008fac6d9--edge.netlify.app/bootstrap/index-combined.ts" +import { type NetlifyGlobal } from 'https://edge.netlify.com/bootstrap/globals/types.ts' const [functionURL, collectorURL, rawExitCodes] = Deno.args const exitCodes = JSON.parse(rawExitCodes) +const env = { + delete: Deno.env.delete, + get: Deno.env.get, + has: Deno.env.has, + set: Deno.env.set, + toObject: Deno.env.toObject, +}; + +const Netlify: NetlifyGlobal = { + get context() { + return null; + }, + env, +}; + globalThis.Netlify = Netlify let func From 5478fc9e184611d9427fef7ddd5169db0303877e Mon Sep 17 00:00:00 2001 From: jake champion Date: Thu, 28 Aug 2025 12:59:21 +0100 Subject: [PATCH 2/2] fix: ensure cross-platform compatibility in tarball creation by using relative paths --- packages/edge-bundler/node/formats/tarball.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/edge-bundler/node/formats/tarball.ts b/packages/edge-bundler/node/formats/tarball.ts index f831a4675b..792a689ba5 100644 --- a/packages/edge-bundler/node/formats/tarball.ts +++ b/packages/edge-bundler/node/formats/tarball.ts @@ -107,20 +107,26 @@ export const bundle = async ({ const tarballPath = path.join(distDirectory, buildID + TARBALL_EXTENSION) await fs.mkdir(path.dirname(tarballPath), { recursive: true }) + // List files to include in the tarball as paths relative to the bundle dir. + // Using absolute paths here leads to platform-specific quirks (notably on Windows), + // where entries can include drive letters and break extraction/imports. + const files = (await listRecursively(bundleDir.path)) + .map((p) => path.relative(bundleDir.path, p)) + .map((p) => getUnixPath(p)) + .sort() + await tar.create( { cwd: bundleDir.path, file: tarballPath, gzip: true, noDirRecurse: true, + // Ensure forward slashes inside the tarball for cross-platform consistency. onWriteEntry(entry) { - const relativePath = path.relative(bundleDir.path, path.join('/', entry.path)) - const normalizedPath = getUnixPath(relativePath) - - entry.path = normalizedPath + entry.path = getUnixPath(entry.path) }, }, - await listRecursively(bundleDir.path), + files, ) const hash = await getFileHash(tarballPath)