Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloudflare): use workerd implementation of node:dns #376

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"typescript": "^5.7.2",
"unbuild": "^2.0.0",
"vitest": "^2.1.8",
"workerd": "^1.20241202.0",
"wrangler": "^3.91.0"
"workerd": "^1.20241216.0",
"wrangler": "^3.95.0"
},
"packageManager": "[email protected]"
}
143 changes: 68 additions & 75 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/presets/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const cloudflareNodeCompatModules = [
"assert/strict",
"buffer",
"diagnostics_channel",
"dns",
vicb marked this conversation as resolved.
Show resolved Hide resolved
"dns/promises",
"events",
"path",
"path/posix",
Expand Down
28 changes: 28 additions & 0 deletions test/workerd/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,34 @@ export const workerd_path = {
},
};

// --- node:dns

export const workerd_dns = {
async test() {
const dns = await import("node:dns");
await new Promise((resolve, reject) => {
dns.resolveTxt("nodejs.org", (error, results) => {
if (error) {
reject(error);
return;
}
assert.ok(Array.isArray(results[0]));
assert.strictEqual(results.length, 1);
assert.ok(results[0][0].startsWith("v=spf1"));
resolve(null);
});
});

const dnsPromises = await import("node:dns/promises");
const results = await dnsPromises.resolveCaa("google.com");
assert.ok(Array.isArray(results));
assert.strictEqual(results.length, 1);
assert.strictEqual(typeof results[0].critical, "number");
assert.strictEqual(results[0].critical, 0);
assert.strictEqual(results[0].issue, "pki.goog");
},
};

// --- unenv:fetch

// https://github.com/unjs/unenv/issues/364
Expand Down
Loading