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

Remove node_compat flag from C3 templates that use Vitest Pool Workers #7388

Merged
merged 2 commits into from
Jan 8, 2025
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
5 changes: 5 additions & 0 deletions .changeset/healthy-bags-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": minor
---

chore: remove nodejs_compat flag from basic C3 templates
5 changes: 5 additions & 0 deletions .changeset/polite-goats-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/vitest-pool-workers": minor
---

chore: add nodejs_compat by default in Vitest Pool Workers
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name = "basics-integration-auxiliary"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name = "basics-unit-integration-self"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
1 change: 0 additions & 1 deletion fixtures/vitest-pool-workers-examples/d1/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "d1"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[[env.production.d1_databases]]
binding = "DATABASE"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "durable-objects"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[durable_objects]
bindings = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name = "external-package-resolution"
main = "src/index.ts"
compatibility_date = "2024-04-05"
compatibility_flags = ["nodejs_compat"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "hyperdrive"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[[hyperdrive]]
binding = "ECHO_SERVER_HYPERDRIVE"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
name = "internal-module-resolution"
compatibility_date = "2024-04-05"
compatibility_flags = ["nodejs_compat"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "kv-r2-caches"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

kv_namespaces = [
{ binding = "KV_NAMESPACE", id = "00000000000000000000000000000000" }
Expand Down
1 change: 0 additions & 1 deletion fixtures/vitest-pool-workers-examples/misc/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[define]
WRANGLER_DEFINED_THING = "\"thing\""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "api-service"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[[services]]
binding = "AUTH_SERVICE"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "auth-service"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

# `AUTH_PUBLIC_KEY` would be a secret created with `wrangler secret put`, and
# stored in `.dev.vars` during development
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "database-service"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

kv_namespaces = [
{ binding = "KV_NAMESPACE", id = "00000000000000000000000000000000" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#:schema node_modules/wrangler/config-schema.json
name = "pages-with-config"
compatibility_date = "2024-09-19"
compatibility_flags = ["nodejs_compat"]
pages_build_output_dir = "public"

1 change: 0 additions & 1 deletion fixtures/vitest-pool-workers-examples/queues/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = "queues"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

kv_namespaces = [
{ binding = "QUEUE_RESULTS", id = "00000000000000000000000000000000" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name = "request-mocking"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
2 changes: 1 addition & 1 deletion fixtures/vitest-pool-workers-examples/rpc/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "rpc"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat", "rpc"]
compatibility_flags = ["rpc"]

kv_namespaces = [
{ binding = "KV_NAMESPACE", id = "00000000000000000000000000000000" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name = "web-assembly"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "workers-static-assets-only"
compatibility_date = "2024-09-19"
compatibility_flags = ["nodejs_compat"]

[assets]
directory = "./public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "workers-static-assets-with-user-worker"
main = "src/index.ts"
compatibility_date = "2024-09-19"
compatibility_flags = ["nodejs_compat"]

[assets]
directory = "./public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "<TBD>"
main = "src/index.js"
compatibility_date = "<TBD>"
compatibility_flags = ["nodejs_compat"]

# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "<TBD>"
main = "src/index.ts"
compatibility_date = "<TBD>"
compatibility_flags = ["nodejs_compat"]

# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
Expand Down
18 changes: 13 additions & 5 deletions packages/vitest-pool-workers/src/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createBirpc } from "birpc";
import * as devalue from "devalue";
import {
compileModuleRules,
getNodeCompat,
kCurrentWorker,
kUnsafeEphemeralUniqueKey,
Log,
Expand Down Expand Up @@ -355,11 +356,6 @@ function buildProjectWorkerOptions(
disableFlag: "export_commonjs_namespace",
defaultOnDate: "2022-10-31",
}),
() =>
flagAssertions.assertAtLeastOneFlagExists([
"nodejs_compat",
"nodejs_compat_v2",
]),
];

for (const assertion of assertions) {
Expand All @@ -369,6 +365,18 @@ function buildProjectWorkerOptions(
}
}

const { mode } = getNodeCompat(
runnerWorker.compatibilityDate,
runnerWorker.compatibilityFlags
);

if (mode !== "v1" && mode !== "v2") {
runnerWorker.compatibilityFlags.push(
"nodejs_compat",
"no_nodejs_compat_v2"
);
}

// Required for `workerd:unsafe` module. We don't require this flag to be set
// as it's experimental, so couldn't be deployed by users.
if (!runnerWorker.compatibilityFlags.includes("unsafe_module")) {
Expand Down
Loading