Skip to content

Commit 78582a2

Browse files
authored
fix: use stable edge functions bootstrap package for globalThis.Netlify (#6609)
1 parent 9b716c0 commit 78582a2

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

packages/edge-bundler/deno/config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
// this needs to be updated whenever there's a change to globalThis.Netlify in bootstrap
2-
import { Netlify } from "https://64e8753eae24930008fac6d9--edge.netlify.app/bootstrap/index-combined.ts"
1+
import { type NetlifyGlobal } from 'https://edge.netlify.com/bootstrap/globals/types.ts'
32

43
const [functionURL, collectorURL, rawExitCodes] = Deno.args
54
const exitCodes = JSON.parse(rawExitCodes)
65

6+
const env = {
7+
delete: Deno.env.delete,
8+
get: Deno.env.get,
9+
has: Deno.env.has,
10+
set: Deno.env.set,
11+
toObject: Deno.env.toObject,
12+
};
13+
14+
const Netlify: NetlifyGlobal = {
15+
get context() {
16+
return null;
17+
},
18+
env,
19+
};
20+
721
globalThis.Netlify = Netlify
822

923
let func

packages/edge-bundler/node/formats/tarball.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,26 @@ export const bundle = async ({
107107
const tarballPath = path.join(distDirectory, buildID + TARBALL_EXTENSION)
108108
await fs.mkdir(path.dirname(tarballPath), { recursive: true })
109109

110+
// List files to include in the tarball as paths relative to the bundle dir.
111+
// Using absolute paths here leads to platform-specific quirks (notably on Windows),
112+
// where entries can include drive letters and break extraction/imports.
113+
const files = (await listRecursively(bundleDir.path))
114+
.map((p) => path.relative(bundleDir.path, p))
115+
.map((p) => getUnixPath(p))
116+
.sort()
117+
110118
await tar.create(
111119
{
112120
cwd: bundleDir.path,
113121
file: tarballPath,
114122
gzip: true,
115123
noDirRecurse: true,
124+
// Ensure forward slashes inside the tarball for cross-platform consistency.
116125
onWriteEntry(entry) {
117-
const relativePath = path.relative(bundleDir.path, path.join('/', entry.path))
118-
const normalizedPath = getUnixPath(relativePath)
119-
120-
entry.path = normalizedPath
126+
entry.path = getUnixPath(entry.path)
121127
},
122128
},
123-
await listRecursively(bundleDir.path),
129+
files,
124130
)
125131

126132
const hash = await getFileHash(tarballPath)

0 commit comments

Comments
 (0)