Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/episcopature-theocrasy-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/workers-playground": minor
---

Add expandable object logging and improved console UI

The Quick Editor console now displays logged objects and arrays as expandable tree views instead of `[object Object]`.
7 changes: 7 additions & 0 deletions .changeset/native-readline-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/unenv-preset": minor
---

Add support for native `node:readline` module when the `enable_nodejs_readline_module` compatibility flag is enabled.

This feature is currently experimental and requires both the `enable_nodejs_readline_module` and `experimental` compatibility flags to be set.
2 changes: 1 addition & 1 deletion packages/unenv-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"peerDependencies": {
"unenv": "2.0.0-rc.24",
"workerd": "^1.20260214.0"
"workerd": "^1.20260218.0"
},
"peerDependenciesMeta": {
"workerd": {
Expand Down
39 changes: 39 additions & 0 deletions packages/unenv-preset/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function getCloudflarePreset({
const ttyOverrides = getTtyOverrides(compat);
const childProcessOverrides = getChildProcessOverrides(compat);
const workerThreadsOverrides = getWorkerThreadsOverrides(compat);
const readlineOverrides = getReadlineOverrides(compat);

// "dynamic" as they depend on the compatibility date and flags
const dynamicNativeModules = [
Expand All @@ -109,6 +110,7 @@ export function getCloudflarePreset({
...ttyOverrides.nativeModules,
...childProcessOverrides.nativeModules,
...workerThreadsOverrides.nativeModules,
...readlineOverrides.nativeModules,
];

// "dynamic" as they depend on the compatibility date and flags
Expand All @@ -134,6 +136,7 @@ export function getCloudflarePreset({
...ttyOverrides.hybridModules,
...childProcessOverrides.hybridModules,
...workerThreadsOverrides.hybridModules,
...readlineOverrides.hybridModules,
];

return {
Expand Down Expand Up @@ -1057,3 +1060,39 @@ function getWorkerThreadsOverrides({
hybridModules: [],
};
}

/**
* Returns the overrides for `node:readline` and `node:readline/promises` (unenv or workerd)
*
* The native readline implementation:
* - is experimental and has no default enable date
* - can be enabled with the "enable_nodejs_readline_module" flag
* - can be disabled with the "disable_nodejs_readline_module" flag
*/
function getReadlineOverrides({
compatibilityFlags,
}: {
compatibilityDate: string;
compatibilityFlags: string[];
}): { nativeModules: string[]; hybridModules: string[] } {
const disabledByFlag = compatibilityFlags.includes(
"disable_nodejs_readline_module"
);

const enabledByFlag =
compatibilityFlags.includes("enable_nodejs_readline_module") &&
compatibilityFlags.includes("experimental");

const enabled = enabledByFlag && !disabledByFlag;

// When enabled, use the native `readline` and `readline/promises` modules from workerd
return enabled
? {
nativeModules: ["readline", "readline/promises"],
hybridModules: [],
}
: {
nativeModules: [],
hybridModules: [],
};
}
Loading
Loading