From 2748b842952275387144ff803665f0c8de720761 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 10 Jan 2025 15:37:06 +0900 Subject: [PATCH 1/2] chore: use native type stripping of Node.js in node testing --- _tools/node_test_runner/deno_compat_hooks.mjs | 30 ------------------- _tools/node_test_runner/package.json | 3 +- collections/max_with.ts | 2 +- collections/min_with.ts | 2 +- 4 files changed, 3 insertions(+), 34 deletions(-) diff --git a/_tools/node_test_runner/deno_compat_hooks.mjs b/_tools/node_test_runner/deno_compat_hooks.mjs index 19c633bea3f7..b1dcf9408175 100644 --- a/_tools/node_test_runner/deno_compat_hooks.mjs +++ b/_tools/node_test_runner/deno_compat_hooks.mjs @@ -1,6 +1,5 @@ // Copyright 2018-2025 the Deno authors. MIT license. -import { transform } from "sucrase"; import { readFile } from "node:fs/promises"; import * as path from "node:path"; import { pathToFileURL } from "node:url"; @@ -21,32 +20,3 @@ export async function resolve(specifier, context, nextResolve) { return await nextResolve(specifier, context); } - -export async function load(specifier, context, nextLoad) { - const { format, source } = await nextLoad(specifier, context).catch( - async (error) => { - if ( - error.code === "ERR_UNKNOWN_FILE_EXTENSION" && - specifier.endsWith(".ts") - ) { - return await nextLoad(specifier, { - ...context, - format: "module", - }); - } else { - throw error; - } - }, - ); - - if (source && specifier.endsWith(".ts")) { - return { - format, - source: encoder.encode( - transform(decoder.decode(source), { transforms: ["typescript"] }).code, - ), - }; - } - - return { format, source }; -} diff --git a/_tools/node_test_runner/package.json b/_tools/node_test_runner/package.json index 81e4c7e147d2..062d06077a30 100644 --- a/_tools/node_test_runner/package.json +++ b/_tools/node_test_runner/package.json @@ -2,7 +2,6 @@ "name": "node_test_runner", "private": true, "dependencies": { - "@deno/shim-deno-test": "^0.5.0", - "sucrase": "^3.35.0" + "@deno/shim-deno-test": "^0.5.0" } } diff --git a/collections/max_with.ts b/collections/max_with.ts index 67e38a17d641..62d9ebb3ce4b 100644 --- a/collections/max_with.ts +++ b/collections/max_with.ts @@ -36,7 +36,7 @@ export function maxWith( let isFirst = true; for (const current of array) { - if (isFirst || comparator(current, max) > 0) { + if (isFirst || comparator(current, max as T) > 0) { max = current; isFirst = false; } diff --git a/collections/min_with.ts b/collections/min_with.ts index df4838de32b1..44e1515ce6f1 100644 --- a/collections/min_with.ts +++ b/collections/min_with.ts @@ -32,7 +32,7 @@ export function minWith( let isFirst = true; for (const current of array) { - if (isFirst || comparator(current, min) < 0) { + if (isFirst || comparator(current, min as T) < 0) { min = current; isFirst = false; } From 4caba864223ba953778633697cea9e75f71eb6d4 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 10 Jan 2025 15:49:06 +0900 Subject: [PATCH 2/2] chore: misc clean up --- .github/workflows/ci.yml | 3 --- _tools/node_test_runner/package.json | 3 +++ deno.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 842f871f02f7..88be898684d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,9 +97,6 @@ jobs: with: node-version: ${{ matrix.node }} - - run: npm install - working-directory: _tools/node_test_runner - - name: Run tests run: deno task test:node diff --git a/_tools/node_test_runner/package.json b/_tools/node_test_runner/package.json index 062d06077a30..cef31b5e362d 100644 --- a/_tools/node_test_runner/package.json +++ b/_tools/node_test_runner/package.json @@ -3,5 +3,8 @@ "private": true, "dependencies": { "@deno/shim-deno-test": "^0.5.0" + }, + "engines": { + "node": ">=23.6.0" } } diff --git a/deno.json b/deno.json index 09a08bc0e375..54db28f199a4 100644 --- a/deno.json +++ b/deno.json @@ -10,7 +10,7 @@ "tasks": { "test": "deno test --unstable-http --unstable-webgpu --doc --allow-all --parallel --coverage --trace-leaks --clean", "test:browser": "git grep --name-only \"This module is browser compatible.\" | grep -v deno.json | grep -v .github/workflows | grep -v _tools | grep -v encoding/README.md | grep -v media_types/vendor/update.ts | xargs deno check --config browser-compat.tsconfig.json", - "test:node": "node --import ./_tools/node_test_runner/register_deno_shim.mjs ./_tools/node_test_runner/run_test.mjs", + "test:node": "(cd _tools/node_test_runner && npm install) && node --import ./_tools/node_test_runner/register_deno_shim.mjs ./_tools/node_test_runner/run_test.mjs", "fmt:licence-headers": "deno run --allow-read --allow-write ./_tools/check_licence.ts", "lint:deprecations": "deno run --allow-read --allow-net --allow-env ./_tools/check_deprecation.ts", "lint:circular": "deno run --allow-env --allow-read --allow-write --allow-net=deno.land,jsr.io ./_tools/check_circular_package_dependencies.ts",