Files
wehub-resource-sync 70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:11 +08:00

47 lines
1.5 KiB
TypeScript

import assert from "node:assert/strict";
import { join } from "node:path";
// Check that we can actually import unenv polyfilled modules in user source.
import "node:perf_hooks";
// Check that `cloudflare:worker` imports work when `nodejs_compat` is enabled
import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
export class MyWorkerEntrypoint extends WorkerEntrypoint {}
export class MyDurableObject extends DurableObject {}
export default {
async fetch() {
return testBasicNodejsProperties();
},
} satisfies ExportedHandler;
function testBasicNodejsProperties() {
assert(true, "the world is broken");
assert(join("a", "b") === "a/b", "expected posix path joining");
const buffer1 = Buffer.of(1);
assert(buffer1.toJSON().data[0] === 1, "Buffer is broken");
const buffer2 = global.Buffer.of(1);
assert(buffer2.toJSON().data[0] === 1, "global.Buffer is broken");
const buffer3 = globalThis.Buffer.of(1);
assert(buffer3.toJSON().data[0] === 1, "globalThis.Buffer is broken");
assert(performance !== undefined, "performance is missing");
assert(global.performance !== undefined, "global.performance is missing");
assert(
globalThis.performance !== undefined,
"globalThis.performance is missing"
);
assert(Performance !== undefined, "Performance is missing");
assert(global.Performance !== undefined, "global.Performance is missing");
assert(
globalThis.Performance !== undefined,
"globalThis.Performance is missing"
);
return new Response(`"OK!"`);
}