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: 0 additions & 7 deletions .changeset/fix-pages-deploy-command-injection.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/native-dgram-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/unenv-preset": minor
---

Add support for native `node:dgram` module when the `enable_nodejs_dgram_module` compatibility flag is enabled. This feature is currently experimental and requires both the `enable_nodejs_dgram_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.20251202.0"
"workerd": "^1.20251221.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 @@ -81,6 +81,7 @@ export function getCloudflarePreset({
const vmOverrides = getVmOverrides(compat);
const inspectorOverrides = getInspectorOverrides(compat);
const sqliteOverrides = getSqliteOverrides(compat);
const dgramOverrides = getDgramOverrides(compat);

// "dynamic" as they depend on the compatibility date and flags
const dynamicNativeModules = [
Expand All @@ -98,6 +99,7 @@ export function getCloudflarePreset({
...vmOverrides.nativeModules,
...inspectorOverrides.nativeModules,
...sqliteOverrides.nativeModules,
...dgramOverrides.nativeModules,
];

// "dynamic" as they depend on the compatibility date and flags
Expand All @@ -116,6 +118,7 @@ export function getCloudflarePreset({
...vmOverrides.hybridModules,
...inspectorOverrides.hybridModules,
...sqliteOverrides.hybridModules,
...dgramOverrides.hybridModules,
];

return {
Expand Down Expand Up @@ -674,3 +677,39 @@ function getSqliteOverrides({
hybridModules: [],
};
}

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

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

const enabled = enabledByFlag && !disabledByFlag;

// When enabled, use the native `dgram` module from workerd
return enabled
? {
nativeModules: ["dgram"],
hybridModules: [],
}
: {
nativeModules: [],
hybridModules: [],
};
}
7 changes: 7 additions & 0 deletions packages/vite-plugin-cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @cloudflare/vite-plugin

## 1.20.3

### Patch Changes

- Updated dependencies [[`99b1f32`](https://github.com/cloudflare/workers-sdk/commit/99b1f328a9afe181b49f1114ed47f15f6d25f0be)]:
- wrangler@4.59.1

## 1.20.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflare/vite-plugin",
"version": "1.20.2",
"version": "1.20.3",
"description": "Cloudflare plugin for Vite",
"keywords": [
"cloudflare",
Expand Down
7 changes: 7 additions & 0 deletions packages/vitest-pool-workers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @cloudflare/vitest-pool-workers

## 0.12.3

### Patch Changes

- Updated dependencies [[`99b1f32`](https://github.com/cloudflare/workers-sdk/commit/99b1f328a9afe181b49f1114ed47f15f6d25f0be)]:
- wrangler@4.59.1

## 0.12.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest-pool-workers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflare/vitest-pool-workers",
"version": "0.12.2",
"version": "0.12.3",
"description": "Workers Vitest integration for writing Vitest unit and integration tests that run inside the Workers runtime",
"keywords": [
"cloudflare",
Expand Down
8 changes: 8 additions & 0 deletions packages/wrangler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# wrangler

## 4.59.1

### Patch Changes

- [#11889](https://github.com/cloudflare/workers-sdk/pull/11889) [`99b1f32`](https://github.com/cloudflare/workers-sdk/commit/99b1f328a9afe181b49f1114ed47f15f6d25f0be) Thanks [@emily-shen](https://github.com/emily-shen)! - Use argument array when executing git commands with `wrangler pages deploy`

Pass user provided values from `--commit-hash` safely to underlying git command.

## 4.59.0

### Minor Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,26 +347,26 @@ const testCases: TestCase[] = [
}),
expectFetchToMatch: [expect.stringContaining(`image/avif`)],
},
{
name: "Media",
scriptPath: "media.js",
setup: () => ({
remoteProxySessionConfig: {
bindings: {
MEDIA: {
type: "media",
},
},
},
miniflareConfig: (connection) => ({
media: {
binding: "MEDIA",
remoteProxyConnectionString: connection,
},
}),
}),
expectFetchToMatch: [expect.stringContaining(`image/jpeg`)],
},
// {
// name: "Media",
// scriptPath: "media.js",
// setup: () => ({
// remoteProxySessionConfig: {
// bindings: {
// MEDIA: {
// type: "media",
// },
// },
// },
// miniflareConfig: (connection) => ({
// media: {
// binding: "MEDIA",
// remoteProxyConnectionString: connection,
// },
// }),
// }),
// expectFetchToMatch: [expect.stringContaining(`image/jpeg`)],
// },
{
name: "Dispatch Namespace",
scriptPath: "dispatch-namespace.js",
Expand Down
21 changes: 21 additions & 0 deletions packages/wrangler/e2e/unenv-preset/preset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,27 @@ const localTestConfigs: TestConfig[] = [
},
},
],
// node:dgram (experimental, no default enable date)
[
// TODO: add test for disabled by date (no date defined yet)
// TODO: add test for enabled by date (no date defined yet)
{
name: "dgram enabled by flag",
compatibilityDate: "2024-09-23",
compatibilityFlags: ["enable_nodejs_dgram_module", "experimental"],
expectRuntimeFlags: {
enable_nodejs_dgram_module: true,
},
},
{
name: "dgram disabled by flag",
compatibilityDate: "2024-09-23",
compatibilityFlags: ["disable_nodejs_dgram_module", "experimental"],
expectRuntimeFlags: {
enable_nodejs_dgram_module: false,
},
},
],
].flat() as TestConfig[];

describe.each(localTestConfigs)(
Expand Down
14 changes: 14 additions & 0 deletions packages/wrangler/e2e/unenv-preset/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,20 @@ export const WorkerdTests: Record<string, () => void> = {
);
}
},

async testDgram() {
const dgram = await import("node:dgram");

assertTypeOfProperties(dgram, {
createSocket: "function",
Socket: "function",
});

assertTypeOfProperties(dgram.default, {
createSocket: "function",
Socket: "function",
});
},
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wrangler",
"version": "4.59.0",
"version": "4.59.1",
"description": "Command-line interface for all things Cloudflare Workers",
"keywords": [
"wrangler",
Expand Down
62 changes: 2 additions & 60 deletions pnpm-lock.yaml

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

Loading