Skip to content

Commit

Permalink
fix(cloudflare): Use polyfills for path/* (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored Oct 28, 2024
1 parent 5eab1bc commit 851ba33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/presets/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const cloudflareNodeCompatModules = [
"diagnostics_channel",
"events",
"path",
"path/posix",
"path/win32",
"querystring",
"stream",
"stream/consumers",
Expand Down
17 changes: 17 additions & 0 deletions test/workerd/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ export const util_implements = {
assert.strictEqual(types.isAnyArrayBuffer(new ArrayBuffer(0)), true);
},
};

// --- node:path

export const unenv_polyfills_path = {
async test() {
const pathWin32 = await import("unenv/runtime/node/path/win32");
assert.strictEqual(typeof pathWin32.resolve, "function");
// Note: unenv uses `unjs/pathe` which behavior differs from Node.js
// See https://github.com/unjs/pathe
assert.strictEqual(pathWin32.sep, "/");
assert.strictEqual(pathWin32.delimiter, ":");
const pathPosix = await import("unenv/runtime/node/path/posix");
assert.strictEqual(typeof pathPosix.resolve, "function");
assert.strictEqual(pathPosix.sep, "/");
assert.strictEqual(pathPosix.delimiter, ":");
},
};

0 comments on commit 851ba33

Please sign in to comment.