diff --git a/package.json b/package.json index 0a95ce38e3dc..8894395b46bb 100644 --- a/package.json +++ b/package.json @@ -143,8 +143,8 @@ "@types/jsdom": "^21.1.6", "@types/node": "^20.19.0", "@vitest/coverage-v8": "^4.1.11", + "acorn": "^8.14.0", "deepmerge": "^4.2.2", - "es-check": "^9.8.1", "esbuild": "^0.28.1", "jsdom": "^21.1.2", "nodemon": "^3.1.10", diff --git a/packages/angular/package.json b/packages/angular/package.json index 85cf9434eb22..d2cf4b0a7c83 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -54,7 +54,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/{esm2020,fesm2015,fesm2020}/*.mjs --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:unit:watch": "vitest --watch", diff --git a/packages/astro/package.json b/packages/astro/package.json index 86c4623bdf99..a4a74705101e 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -92,7 +92,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/aws-serverless/package.json b/packages/aws-serverless/package.json index 9ca445d6fa29..3d1f58105bd1 100644 --- a/packages/aws-serverless/package.json +++ b/packages/aws-serverless/package.json @@ -94,7 +94,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/npm/cjs/*.js && es-check es2022 ./build/npm/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/browser-utils/package.json b/packages/browser-utils/package.json index ebfdc40be99a..ef5e8634d825 100644 --- a/packages/browser-utils/package.json +++ b/packages/browser-utils/package.json @@ -53,7 +53,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test:unit": "vitest run", "test": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/browser/package.json b/packages/browser/package.json index c63397ee82ba..f44090f12afa 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -65,7 +65,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs/prod}/*.js && es-check es2020 ./build/npm/esm/prod/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "size:check": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES2017: \",$1,\"kB\";}'", "test": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/bun/package.json b/packages/bun/package.json index 8d5aa84401c6..2f5c78a1b9c4 100644 --- a/packages/bun/package.json +++ b/packages/bun/package.json @@ -66,7 +66,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "install:bun": "node ./scripts/install-bun.js", "test": "run-s install:bun test:bun", "test:bun": "bun test", diff --git a/packages/cloudflare/package.json b/packages/cloudflare/package.json index 00523b4e4a39..1c9d88b928e4 100644 --- a/packages/cloudflare/package.json +++ b/packages/cloudflare/package.json @@ -96,7 +96,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/prod/*.js && es-check es2022 ./build/esm/prod/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/core/package.json b/packages/core/package.json index 92c4ebc10bd8..4ba942086d38 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -80,7 +80,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/deno/package.json b/packages/deno/package.json index b178b8849767..94a743939164 100644 --- a/packages/deno/package.json +++ b/packages/deno/package.json @@ -50,7 +50,7 @@ "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", "lint:fix": "oxlint . --fix --type-aware", - "lint:es-compatibility": "es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "install:deno": "node ./scripts/install-deno.mjs", "test": "run-s install:deno deno-types test:types test:unit", "test:types": "deno check --unstable-sloppy-imports test", diff --git a/packages/elysia/package.json b/packages/elysia/package.json index f647f32bb9dc..01cf2b373d21 100644 --- a/packages/elysia/package.json +++ b/packages/elysia/package.json @@ -62,7 +62,7 @@ "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", "lint:fix": "oxlint . --fix --type-aware", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/feedback/package.json b/packages/feedback/package.json index fffb9e6b72b2..6458d84577ad 100644 --- a/packages/feedback/package.json +++ b/packages/feedback/package.json @@ -54,7 +54,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs}/*.js && es-check es2020 ./build/npm/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index bd76356eecef..5ab426ccfe7f 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -67,7 +67,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/google-cloud-serverless/package.json b/packages/google-cloud-serverless/package.json index c14d67945949..249335cfcc72 100644 --- a/packages/google-cloud-serverless/package.json +++ b/packages/google-cloud-serverless/package.json @@ -71,7 +71,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/hono/package.json b/packages/hono/package.json index 9a1cb3e0c245..201ce7ae9058 100644 --- a/packages/hono/package.json +++ b/packages/hono/package.json @@ -126,7 +126,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/integration-shims/package.json b/packages/integration-shims/package.json index fc36769f0de3..793bc13c95d6 100644 --- a/packages/integration-shims/package.json +++ b/packages/integration-shims/package.json @@ -35,7 +35,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run" }, "repository": { diff --git a/packages/nestjs/package.json b/packages/nestjs/package.json index 746c48f365e6..b1db26bbb0ca 100644 --- a/packages/nestjs/package.json +++ b/packages/nestjs/package.json @@ -85,7 +85,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 7dde0daa81d2..75ddd7b1a79a 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -141,7 +141,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:all": "run-s test:unit", "test:unit": "vitest run", diff --git a/packages/nitro/package.json b/packages/nitro/package.json index 873f0893d713..fec0c6cc21f5 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -63,7 +63,7 @@ "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", "lint:fix": "oxlint . --fix --type-aware", - "lint:es-compatibility": "es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/node-native/package.json b/packages/node-native/package.json index 880063f1ea53..25fa2a96e9b7 100644 --- a/packages/node-native/package.json +++ b/packages/node-native/package.json @@ -44,7 +44,7 @@ "clean": "rm -rf build", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "lint:fix": "oxlint . --fix --type-aware", "build": "pnpm run build:types && pnpm run build:transpile", "build:transpile": "pnpm exec rolldown -c rollup.npm.config.mjs", diff --git a/packages/node/package.json b/packages/node/package.json index 16a511f2f9e6..bdb4f3aa2e6e 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -102,7 +102,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 1d7750057282..089fbf643d46 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -93,7 +93,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module && es-check es2020 ./build/module/*.mjs --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index 380fe0d71354..cd8d711a00b9 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -50,7 +50,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/profiling-node/package.json b/packages/profiling-node/package.json index 02a916ccbf0a..174732801943 100644 --- a/packages/profiling-node/package.json +++ b/packages/profiling-node/package.json @@ -36,7 +36,7 @@ "clean": "rm -rf build", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2022", "lint:fix": "oxlint . --fix --type-aware", "build": "pnpm run build:types && pnpm run build:transpile", "build:transpile": "pnpm exec rolldown -c rollup.npm.config.mjs", diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 341ee22d26d8..6260139e3e91 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -96,7 +96,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/react/package.json b/packages/react/package.json index 1400559fbc1c..b948d61dc5fa 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -101,7 +101,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/remix/package.json b/packages/remix/package.json index 9ee8d87c357c..787d3be99e19 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -107,6 +107,9 @@ "react": "18.x", "remix": "3.x" }, + "//_scripts_comment": [ + "`lint:es-compatibility`: `build/v3-node.mjs` is Node-only and uses top-level await. `build/esm/v3/client-bundle.js` inlines web-vitals 6 untranspiled, whose only ES2022 syntax is public instance class fields (Chrome 72, Firefox 69, Safari 14, so supported by all our minimum browsers). Its `Array.prototype.at` use is guarded since #26347." + ], "scripts": { "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", @@ -120,7 +123,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020 'build/{cjs,esm}/**/*.js' '!build/esm/v3/client-bundle.js' build/import-hook.mjs && node ../../scripts/es-check.mjs es2022 build/esm/v3/client-bundle.js build/v3-node.mjs", "test": "pnpm run test:unit", "test:unit": "vitest run --config vitest.config.unit.ts", "test:watch": "vitest --watch --config vitest.config.unit.ts", diff --git a/packages/replay-canvas/package.json b/packages/replay-canvas/package.json index 7abc0cc76ce6..34106d993a52 100644 --- a/packages/replay-canvas/package.json +++ b/packages/replay-canvas/package.json @@ -38,7 +38,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs}/*.js && es-check es2020 ./build/npm/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/replay-internal/package.json b/packages/replay-internal/package.json index 0dec99748bb4..c5dcc3b5ecf0 100644 --- a/packages/replay-internal/package.json +++ b/packages/replay-internal/package.json @@ -54,7 +54,7 @@ "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", "lint:fix": "oxlint . --fix --type-aware", - "lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs}/*.js && es-check es2020 ./build/npm/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/replay-worker/package.json b/packages/replay-worker/package.json index db0dd63e05c6..388423ae79b0 100644 --- a/packages/replay-worker/package.json +++ b/packages/replay-worker/package.json @@ -40,7 +40,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch" }, diff --git a/packages/server-runtime-injection/package.json b/packages/server-runtime-injection/package.json index ef8b0b9e2cf8..10e5d15e5935 100644 --- a/packages/server-runtime-injection/package.json +++ b/packages/server-runtime-injection/package.json @@ -70,7 +70,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test:unit": "vitest run", "test": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/server-utils/package.json b/packages/server-utils/package.json index 182ba3b08e5f..8aeaaade40c8 100644 --- a/packages/server-utils/package.json +++ b/packages/server-utils/package.json @@ -127,7 +127,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test:unit": "vitest run", "test": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/solid/package.json b/packages/solid/package.json index 1b1cb8bd1f22..9cb1c4e58e99 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -98,7 +98,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/solidstart/package.json b/packages/solidstart/package.json index d6a88ef69c46..f2792b3647f2 100644 --- a/packages/solidstart/package.json +++ b/packages/solidstart/package.json @@ -124,7 +124,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/svelte/package.json b/packages/svelte/package.json index e8cdcf514716..1835264c8748 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -60,7 +60,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 0b91191f427b..26bfd2ecc206 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -106,7 +106,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/tanstackstart-react/package.json b/packages/tanstackstart-react/package.json index 5fd1b50fbbb2..7dcec548e3e5 100644 --- a/packages/tanstackstart-react/package.json +++ b/packages/tanstackstart-react/package.json @@ -79,7 +79,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "pnpm run test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", diff --git a/packages/vercel-edge/package.json b/packages/vercel-edge/package.json index 7b1eb06ae1db..3d19843a5373 100644 --- a/packages/vercel-edge/package.json +++ b/packages/vercel-edge/package.json @@ -54,7 +54,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/vue/package.json b/packages/vue/package.json index 76b557061200..a12f63fd7574 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -81,7 +81,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "test": "vitest run", "test:watch": "vitest --watch", "yalc:publish": "pnpm dlx yalc publish --push --sig" diff --git a/packages/wasm/package.json b/packages/wasm/package.json index cd18e858109d..7fdb20287130 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -55,7 +55,7 @@ "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", - "lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs}/*.js && es-check es2020 ./build/npm/esm/*.js --module", + "lint:es-compatibility": "node ../../scripts/es-check.mjs es2020", "yalc:publish": "pnpm dlx yalc publish --push --sig" }, "sideEffects": false diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a6c6b91adc28..4cd85d7d8aa8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -201,12 +201,12 @@ importers: '@vitest/coverage-v8': specifier: ^4.1.11 version: 4.1.11(vitest@4.1.12) + acorn: + specifier: ^8.14.0 + version: 8.18.0 deepmerge: specifier: ^4.2.2 version: 4.3.1 - es-check: - specifier: ^9.8.1 - version: 9.8.1 esbuild: specifier: ^0.28.1 version: 0.28.1 @@ -11438,11 +11438,6 @@ packages: resolution: {integrity: sha512-WSzPgsdLtTcQwm4CROfS5ju2Wa1QQcVeT37jFjYzdFz1r9ahadC8B8/a4qxJxM+09F18iumCdRmlr96ZYkQvEg==} engines: {node: '>= 0.4'} - es-check@9.8.1: - resolution: {integrity: sha512-F6bumjRmN+OWpEUh3ewhE/S1ey6cHKGMNXPn0iE2tBnict3O855Uij6UYbuHnLS1E3eILvg61KdH6kHbGi9www==} - engines: {node: '>=18.0.0'} - hasBin: true - es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -15850,6 +15845,7 @@ packages: postcss-selector-parser@7.2.0: resolution: {integrity: sha512-Khh/tERVBn0I1499dvBSHY0pWJloMJWUxDsOBM0CCDPAcVZ10Jl2L1qy1f19uEX22spa8Mv7DCdEQJc0cGwBhQ==} engines: {node: '>=4'} + deprecated: Double-escapes CSS Modules class names (#362). Use 7.2.1. postcss-svgo@7.1.3: resolution: {integrity: sha512-2QfoFOYMcj8lwcVEf9WeTlkVIAm7u2QvOEhMzkQU3KUhhGX/l8hVV9EtjMv4iq3E9iI3OeeMN0YoMLbGusuigw==} @@ -30695,12 +30691,6 @@ snapshots: unbox-primitive: 1.1.0 which-typed-array: 1.1.19 - es-check@9.8.1: - dependencies: - acorn: 8.18.0 - browserslist: 4.29.0 - fast-glob: 3.3.3 - es-define-property@1.0.1: {} es-errors@1.3.0: {} diff --git a/scripts/es-check.mjs b/scripts/es-check.mjs new file mode 100644 index 000000000000..eff596cc0137 --- /dev/null +++ b/scripts/es-check.mjs @@ -0,0 +1,46 @@ +// Fails if any built file (default: everything in `build/`) uses syntax newer than the given ES version. +// Globs starting with `!` exclude files from the other globs. +/* eslint-disable no-console */ +import { globSync, readFileSync } from 'node:fs'; +import { parse } from 'acorn'; + +const [target, ...args] = process.argv.slice(2); +const ecmaVersion = Number(target?.replace(/^es/, '')); +const excludes = ['**/node_modules/**', ...args.filter(arg => arg.startsWith('!')).map(arg => arg.slice(1))]; +const includes = args.filter(arg => !arg.startsWith('!')); +const patterns = includes.length ? includes : ['build/**/*.{js,mjs,cjs}']; + +if (!ecmaVersion) { + console.error('Usage: node es-check.mjs [glob...]'); + process.exit(1); +} + +let fileCount = 0; +let failed = false; + +for (const pattern of patterns) { + const files = globSync(pattern, { exclude: excludes }); + + if (!files.length) { + console.error(`es-check: no files match ${pattern}`); + failed = true; + } + + for (const file of files) { + fileCount++; + try { + // Module grammar is stricter than script grammar and also accepts CJS and IIFE output, so + // one mode covers every file. Hashbangs are allowed for CLI entry points. + parse(readFileSync(file, 'utf8'), { ecmaVersion, sourceType: 'module', allowHashBang: true }); + } catch (error) { + console.error(`es-check: ${file} is not valid ${target}: ${error.message}`); + failed = true; + } + } +} + +if (failed) { + process.exit(1); +} + +console.log(`es-check: ${fileCount} files are valid ${target}`);