πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
ci: fail builds on minifier-dropped bindings in the client bundle (LFE-10645) (#14738)
Nikita Kabardin8a9371e2953c
diff --git a/.agents/AGENTS.md b/.agents/AGENTS.mdindex 95bfd32f96..12662870c9 100644--- a/.agents/AGENTS.md+++ b/.agents/AGENTS.md@@ -105,6 +105,12 @@ langfuse/targeted server API tests, and Fern update/regeneration.- Cross-package refactors: `pnpm run lint`, `pnpm run typecheck`, and targetedtests for impacted packages.+- Client-bundle soundness: CI scans every prod web build+ (`pnpm run scan:client-bundle`) for minifier-dropped bindings and Node-only+ globals leaking into browser chunks β the SWC dropped-binding class ships+ runtime-only `ReferenceError`s that dev builds and type checks cannot see+ (LFE-10645). On failure, `scripts/scan-client-bundle.mjs`'s header explains+ the canonical fix.## Generated Filesdiff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex a3603f2554..ae4094bf5b 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -881,6 +881,16 @@ jobs:# TypeScript is checked explicitly in the lint job; skip duplicate# Next.js type checks in test builds to reduce CI runtime.NEXT_IGNORE_BUILD_ERRORS: "true"+ - name: Scan client bundle for minifier-dropped bindings+ # The SWC/Turbopack minifier can delete a binding that live code+ # still references, producing a production-only ReferenceError (the+ # LFE-10640 trace-peek crash). The build succeeds and next dev is+ # unminified, so this scan of the emitted assets is the only static+ # layer that catches the class β including inside vendored+ # dependencies. Scans this job's build as a proxy: release images+ # minify the same sources separately with different inlined+ # NEXT_PUBLIC_* constants. Analysis: LFE-10645.+ run: node scripts/scan-client-bundle.mjs web/.next/static- name: Wait for dev containersrun: |timeout 300 bash -c 'until [ -f /tmp/compose-up.exit ]; do sleep 1; done' \diff --git a/package.json b/package.jsonindex 005e0bed26..62a1616636 100644--- a/package.json+++ b/package.json@@ -20,6 +20,7 @@"db:seed": "turbo run db:seed","db:seed:examples": "turbo run db:seed:examples","nuke": "bash ./scripts/nuke.sh",+ "scan:client-bundle": "node scripts/scan-client-bundle.mjs web/.next/static","seed": "pnpm --filter=shared run seed:scenario","dx": "pnpm i && pnpm run infra:dev:prune && pnpm run infra:dev:up --pull always && pnpm --filter=shared run db:reset:test && pnpm --filter=shared run db:reset && pnpm --filter=shared run ch:reset && pnpm --filter=shared run db:seed:examples && pnpm run dev","dx-f": "pnpm i && pnpm run infra:dev:prune && pnpm run infra:dev:up --pull always && pnpm --filter=shared run db:reset:test && pnpm --filter=shared run db:reset -f && SKIP_CONFIRM=1 pnpm --filter=shared run ch:reset && pnpm --filter=shared run db:seed:examples && pnpm run dev",@@ -46,6 +47,9 @@"devDependencies": {"@release-it/bumper": "^7.0.6","dotenv-cli": "^7.4.4",+ "eslint-scope": "^9.1.2",+ "espree": "^11.2.0",+ "globals": "^16.5.0","husky": "^9.1.7","knip": "^6.22.0","prettier": "^3.8.3",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex bf82f5fb73..9c473c04b2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -37,6 +37,15 @@ importers:dotenv-cli:specifier: ^7.4.4version: 7.4.4+ eslint-scope:+ specifier: ^9.1.2+ version: 9.1.2+ espree:+ specifier: ^11.2.0+ version: 11.2.0+ globals:+ specifier: ^16.5.0+ version: 16.5.0husky:specifier: ^9.1.7version: 9.1.7@@ -5704,6 +5713,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==}+ '@types/[email protected]':+ resolution: {integrity: sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==}+'@types/[email protected]':resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}@@ -7601,6 +7613,10 @@ packages:resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==}engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}+ resolution: {integrity: sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==}+ engines: {node: ^20.19.0 || ^22.13.0 || >=24}+resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==}engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}@@ -7627,6 +7643,10 @@ packages:resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==}engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}+ resolution: {integrity: sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==}+ engines: {node: ^20.19.0 || ^22.13.0 || >=24}+resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==}engines: {node: '>=4'}@@ -17058,6 +17078,8 @@ snapshots:'@types/estree': 1.0.9'@types/json-schema': 7.0.15+ '@types/[email protected]': {}+'@types/[email protected]':dependencies:'@types/estree': 1.0.9@@ -19291,6 +19313,13 @@ snapshots:esrecurse: 4.3.0estraverse: 5.3.0+ dependencies:+ '@types/esrecurse': 4.3.1+ '@types/estree': 1.0.9+ esrecurse: 4.3.0+ estraverse: 5.3.0+@@ -19344,6 +19373,12 @@ snapshots:acorn-jsx: 5.3.2([email protected])eslint-visitor-keys: 4.2.1+ dependencies:+ acorn: 8.16.0+ acorn-jsx: 5.3.2([email protected])+ eslint-visitor-keys: 5.0.1+diff --git a/scripts/scan-client-bundle.mjs b/scripts/scan-client-bundle.mjsnew file mode 100644index 0000000000..820cb6f79c--- /dev/null+++ b/scripts/scan-client-bundle.mjs@@ -0,0 +1,353 @@+#!/usr/bin/env node+/**+ * Post-build client-bundle scanner (LFE-10645).+ *+ * Parses every emitted client asset and reports identifiers that are+ * REFERENCED but DECLARED NOWHERE in the file and are not known browser+ * globals. A minifier that deletes a binding while keeping a reference to it+ * (the SWC dropped-binding class that caused LFE-10640, a production-only+ * `ReferenceError` on opening a trace peek) always leaves exactly such a free+ * identifier behind β and since the minifier owns every name it emits, a+ * non-global free identifier in minified output is a miscompilation until+ * proven otherwise. The same net also catches Node/CJS leakage into browser+ * code (bare `require`, `process`, `Buffer`, β¦), which crashes just the same.+ *+ * Scope of the guarantee: complete for the *ReferenceError manifestation* of+ * the dropped-binding class (a deleted binding necessarily produces an+ * undeclared reference, and scope analysis finds all of them), including+ * inside vendored dependency code that no source-level lint can see. Known+ * limits: a dropped binding whose name collides with a real window property+ * (`status`, `name`, `length`, β¦) degrades silently instead of throwing and+ * is out of scope here, as are miscompiles that keep all bindings but fold a+ * wrong value β both need runtime exercise to detect. CI scans the e2e job's+ * build as a proxy for the release images, which minify the same sources+ * separately with different inlined NEXT_PUBLIC_* constants.+ *+ * Usage: node scripts/scan-client-bundle.mjs <static-dir>+ * e.g. node scripts/scan-client-bundle.mjs web/.next/static+ *+ * Exit codes: 0 = clean, 1 = findings, 2 = usage / zero files / parse failure.+ *+ * If this scanner fails your build: the named binding was deleted by the+ * minifier while code still reads it. The canonical first-party fix is to+ * move the module-level const into the (single) function that reads it β see+ * the LFE-10640 fix in TraceLayoutDesktop.tsx (#14735) β and to link the+ * upstream SWC issue in a comment so the workaround is deletable once fixed.+ * For vendored dependency code, change how the dependency is shipped (see the+ * prettier/plugins/typescript β babel-ts swap in #14738).+ */+import fs from "node:fs";+import path from "node:path";+import { createRequire } from "node:module";++// espree and eslint-scope are CommonJS without ESM default-export interop.+const require = createRequire(import.meta.url);+const espree = require("espree");+const eslintScope = require("eslint-scope");+const globals = require("globals");++// Identifiers that legitimately appear free in minified chunks even after the+// typeof-guard exemption below. Every entry must carry a reason β this list+// is a hole in the net (it masks the name bundle-wide), keep it short.+const AMBIENT_ALLOWLIST = new Map([+ // Bundler / framework runtime names registered by the runtime chunk or the+ // host page before any app chunk executes (live in today's bundle).+ ["TURBOPACK_NEXT_CHUNK_URLS", "Turbopack chunk-URL manifest global"],+ ["__turbopack_load_page_chunks__", "Turbopack page-chunk loader"],+ // Next.js's scheduler module ships its Node code path into the client+ // chunk with two setImmediate calls that are not typeof-guarded (upstream+ // next/dist; the path is process-gated at runtime and unreached in+ // browsers). Remove when Next fixes the emission.+ ["setImmediate", "Next.js scheduler Node path in client chunk (upstream)"],+ // Devtools / observability hooks that exist only when their host injects+ // them; some reads sit behind existence checks that are not typeof-shaped.+ ["__REACT_DEVTOOLS_GLOBAL_HOOK__", "React DevTools hook"],+ ["__SENTRY_DEBUG__", "Sentry magic build flag"],+ ["__SENTRY_TRACING__", "Sentry magic build flag"],+ ["__SENTRY_BROWSER_BUNDLE__", "Sentry magic build flag"],+ ["__SENTRY_RELEASE__", "Sentry magic build flag"],+ ["__SENTRY_EXCLUDE_REPLAY_WORKER__", "Sentry replay build flag"],+ ["__RRWEB_EXCLUDE_IFRAME__", "rrweb (Sentry replay) build flag"],+ ["__RRWEB_EXCLUDE_SHADOW_DOM__", "rrweb (Sentry replay) build flag"],+ ["__nccwpck_require__", "ncc-precompiled vendored packages' runtime"],+ ["__webpack_nonce__", "webpack CSP nonce hook, read if defined"],+ ["UUIDV7_DENY_WEAK_RNG", "uuidv7 opt-in strictness global"],+ // Cross-environment feature probes in vendored libraries whose guards are+ // not typeof-shaped in the emitted code.+ ["ActiveXObject", "legacy IE probe in vendored libs"],+ ["Bun", "Bun runtime probe"],+ ["Deno", "Deno runtime probe"],+ ["AsyncIterator", "ES proposal probe in vendored libs"],+ [+ "WebKitCSSMatrix",+ "d3-interpolate fallback in a DOMMatrix-guarded alternate; a real global in engines old enough to reach it",+ ],+ [+ "$doc",+ "GWT runtime alias in elkjs, read only on an MSIE-userAgent path β undeclared in the upstream source, not a minifier drop",+ ],+ [+ "toString",+ "bare toString.call idiom resolves to globalThis's inherited Object.prototype.toString β cannot throw",+ ],+]);++// regenerator-runtime self-registers via a try/catch-guarded top-level WRITE+// (`regeneratorRuntime = r`) β that write is legitimate, but a free READ of+// this name would be a real dropped binding in Babel-compiled vendored code,+// so it must not be name-allowlisted wholesale.+const WRITE_ONLY_ALLOWLIST = new Set(["regeneratorRuntime"]);++// Browser globals that only exist in some engines (mostly Chrome-only+// APIs). A dropped binding with one of these names β `ai` and `model` are+// plausible two-char mangler output or LLM-product source names β would be+// masked by globals.browser yet throw for every Firefox/Safari user, the+// exact shape of the original incident. Zero of them appear free in today's+// bundle, so subtracting them costs nothing.+const NOT_UNIVERSALLY_PRESENT = new Set([+ "ai",+ "model",+ "fence",+ "when",+ "viewport",+ "credentialless",+ "scheduler",+]);++// Deliberately NO globals.node: `require`, `module`, `exports`, `process`,+// `Buffer`, `__dirname`, β¦ all throw in a real browser, so a bare reference+// in a client chunk is a guaranteed crash (Node/CJS leakage) that this gate+// must catch, not mask. Runtime probes for these names are typeof-guarded in+// the emitted code and covered by the guard exemption below.+const KNOWN_GLOBALS = new Set(+ [+ ...Object.keys(globals.browser),+ ...Object.keys(globals.worker),+ ...Object.keys(globals.builtin),+ ].filter((name) => !NOT_UNIVERSALLY_PRESENT.has(name)),+);++function parseAsset(code) {+ // Module-first: every current chunk parses identically in both modes, but a+ // top-level-await chunk would misparse in script mode (`await x` becomes a+ // call of a free identifier `await`) and produce a phantom finding.+ try {+ return {+ ast: espree.parse(code, {+ ecmaVersion: "latest",+ sourceType: "module",+ loc: true,+ range: true,+ }),+ sourceType: "module",+ };+ } catch {+ // Sloppy-only syntax (`with`, HTML comments) in vendored code needs+ // script mode. The scope analyzer must use the same mode as the parse.+ return {+ ast: espree.parse(code, {+ ecmaVersion: "latest",+ sourceType: "script",+ loc: true,+ range: true,+ }),+ sourceType: "script",+ };+ }+}++// Collect the names probed via `typeof <name>` anywhere inside `node`.+function typeofNamesIn(node, out) {+ if (!node || typeof node.type !== "string") return out;+ if (+ node.type === "UnaryExpression" &&+ node.operator === "typeof" &&+ node.argument.type === "Identifier"+ ) {+ out.add(node.argument.name);+ }+ for (const key of Object.keys(node)) {+ if (key === "parent") continue;+ const value = node[key];+ if (Array.isArray(value)) value.forEach((v) => typeofNamesIn(v, out));+ else if (value && typeof value.type === "string") typeofNamesIn(value, out);+ }+ return out;+}++// Record every reference range of `names` inside `node` as guard-exempt.+function exemptRefsIn(node, names, exemptRanges) {+ if (!node || typeof node.type !== "string" || names.size === 0) return;+ if (node.type === "Identifier" && names.has(node.name)) {+ exemptRanges.add(node.range[0]);+ }+ for (const key of Object.keys(node)) {+ if (key === "parent") continue;+ const value = node[key];+ if (Array.isArray(value))+ value.forEach((v) => exemptRefsIn(v, names, exemptRanges));+ else if (value && typeof value.type === "string")+ exemptRefsIn(value, names, exemptRanges);+ }+}++/**+ * Two exemption layers for legal free-identifier reads:+ * 1. The argument of `typeof x` itself never throws.+ * 2. Guard-then-use: when a test expression probes `typeof x`, references to+ * x inside the guarded branch are execution-gated on the probe, e.g.+ * `"function"==typeof require?require:__require` (Turbopack runtime) or+ * `typeof onProfilerEvent=="function"&&onProfilerEvent(e)`. Exemption is+ * scoped to the guarded subtree only β never the whole chunk β so a+ * dropped binding elsewhere in the file that happens to share the name+ * still fires.+ */+function collectExemptRanges(ast) {+ const exemptRanges = new Set();+ (function walk(node) {+ if (!node || typeof node.type !== "string") return;+ if (+ node.type === "UnaryExpression" &&+ node.operator === "typeof" &&+ node.argument.type === "Identifier"+ ) {+ exemptRanges.add(node.argument.range[0]);+ } else if (node.type === "LogicalExpression") {+ exemptRefsIn(+ node.right,+ typeofNamesIn(node.left, new Set()),+ exemptRanges,+ );+ } else if (node.type === "ConditionalExpression") {+ const names = typeofNamesIn(node.test, new Set());+ exemptRefsIn(node.consequent, names, exemptRanges);+ exemptRefsIn(node.alternate, names, exemptRanges);+ } else if (node.type === "IfStatement") {+ const names = typeofNamesIn(node.test, new Set());+ exemptRefsIn(node.consequent, names, exemptRanges);+ if (node.alternate) exemptRefsIn(node.alternate, names, exemptRanges);+ }+ for (const key of Object.keys(node)) {+ if (key === "parent") continue;+ const value = node[key];+ if (Array.isArray(value)) value.forEach(walk);+ else if (value && typeof value.type === "string") walk(value);+ }+ })(ast);+ return exemptRanges;+}++function scanFile(file) {+ const code = fs.readFileSync(file, "utf8");+ const { ast, sourceType } = parseAsset(code);++ const scopeManager = eslintScope.analyze(ast, {+ ecmaVersion: 2024,+ sourceType,+ ignoreEval: true,+ });++ const exemptRanges = collectExemptRanges(ast);++ // globalScope.through = references that no scope in this file resolves.+ const findings = new Map();+ for (const ref of scopeManager.globalScope.through) {+ const name = ref.identifier.name;+ if (KNOWN_GLOBALS.has(name)) continue;+ if (AMBIENT_ALLOWLIST.has(name)) continue;+ if (WRITE_ONLY_ALLOWLIST.has(name) && ref.isWrite() && !ref.isRead())+ continue;+ if (exemptRanges.has(ref.identifier.range[0])) continue;+ if (!findings.has(name)) findings.set(name, []);+ findings+ .get(name)+ .push(+ `${ref.identifier.loc.start.line}:${ref.identifier.loc.start.column}`,+ );+ }+ return findings;+}++const dir = process.argv[2];+if (!dir || !fs.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) {+ console.error(+ "usage: node scripts/scan-client-bundle.mjs <static-dir>\n" ++ ` not a directory: ${dir ?? "(missing argument)"}`,+ );+ process.exit(2);+}++// Recursive walk (chunks can be emitted into subdirectories) over every JS+// flavor; regular files only, sorted for deterministic output. Missing files+// would silently narrow the gate.+const files = fs+ .readdirSync(dir, { recursive: true, withFileTypes: true })+ .filter((entry) => entry.isFile() && /\.(js|mjs|cjs)$/.test(entry.name))+ .map((entry) => path.join(entry.parentPath, entry.name))+ .sort();++if (files.length === 0) {+ // An empty scan must never pass β a build-output restructure would+ // otherwise silently disable the gate.+ console.error(`no JS files found in ${dir} β check the build output path`);+ process.exit(2);+}++const started = Date.now();+const byName = new Map();+let parseFailures = 0;+for (const file of files) {+ const relative = path.relative(dir, file);+ try {+ for (const [name, locs] of scanFile(file)) {+ if (!byName.has(name)) byName.set(name, []);+ byName.get(name).push({ file: relative, locs });+ }+ } catch (error) {+ parseFailures += 1;+ const at =+ error.lineNumber != null ? ` (${error.lineNumber}:${error.column})` : "";+ console.error(`PARSE FAILED ${relative}${at}: ${error.message}`);+ }+}++const seconds = ((Date.now() - started) / 1000).toFixed(1);+console.log(`scanned ${files.length} files in ${seconds}s`);++// Print findings even when some chunks failed to parse β a parse failure+// must not suppress evidence from the chunks that did parse.+if (byName.size > 0) {+ console.error(+ `\n${byName.size} undeclared identifier(s) found β the minifier likely ` ++ "deleted a binding that live code still reads (LFE-10640 class), or " ++ "Node-only code leaked into a browser chunk.\n" ++ "Each of these throws ReferenceError when the referencing line executes:\n",+ );+ for (const [name, hits] of [...byName.entries()].sort(+ (a, b) => b[1].length - a[1].length,+ )) {+ console.error(+ ` ${name} β ${hits.length} file(s): ${hits+ .slice(0, 4)+ .map((h) => `${h.file}:${h.locs[0]}`)+ .join(", ")}${hits.length > 4 ? ", β¦" : ""}`,+ );+ }+ console.error(+ "\nFix: keep the value local to its single reader (see #14735 for the " ++ "canonical fix) or restructure the shape; for vendored dependency code, " ++ "change how the dependency is shipped. See LFE-10645 for the analysis.",+ );+}++if (parseFailures > 0) {+ console.error(`\n${parseFailures} file(s) could not be parsed β failing.`);+ process.exit(2);+}++if (byName.size > 0) {+ process.exit(1);+}++console.log("clean: every referenced identifier is declared or a known global");+process.exit(0);diff --git a/web/AGENTS.md b/web/AGENTS.mdindex b5a971b5d7..ccec0238e4 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -140,6 +140,12 @@ changes.Dialog as a SIBLING (trigger inside, dialog outside), as`useAddLlmConnectionSelect` in `src/components/ModelParameters/index.tsx` does(LFE-10615).+- Never import `prettier/plugins/typescript` in client code β it embeds the+ TypeScript compiler, which the SWC minifier miscompiles (dropped bindings β+ production-only `ReferenceError`; caught by the CI client-bundle scan,+ LFE-10645). Format TypeScript with `parser: "babel-ts"` ++ `prettier/plugins/babel` instead, as the eval-template editor does+ (`src/features/evals/components/code-eval-template-form-body.tsx`).- Public API routes should use`src/features/public-api/server/withMiddlewares.ts`, define strict request andresponse types in `src/features/public-api/types/*`, add server tests, anddiff --git a/web/src/features/evals/components/code-eval-template-form-body.tsx b/web/src/features/evals/components/code-eval-template-form-body.tsxindex 6cbafe41b6..7efa46ea7f 100644--- a/web/src/features/evals/components/code-eval-template-form-body.tsx+++ b/web/src/features/evals/components/code-eval-template-form-body.tsx@@ -163,25 +163,28 @@ const contractReadOnlyExtension = EditorState.changeFilter.of((tr) => {const contractReadOnlyExtensions = [contractReadOnlyExtension];async function formatTypeScriptSource(source: string) {- const [{ format }, typescriptPlugin, estreePlugin] = await Promise.all([+ // babel-ts instead of the typescript plugin: the latter embeds the+ // TypeScript compiler, which the SWC minifier miscompiles (dropped+ // bindings β LFE-10645, caught by scripts/scan-client-bundle.mjs).+ const [{ format }, babelPlugin, estreePlugin] = await Promise.all([import("prettier/standalone"),- import("prettier/plugins/typescript"),+ import("prettier/plugins/babel"),import("prettier/plugins/estree"),]);const ranges = findTypeScriptContractRanges(source);if (!ranges?.prelude) {return format(source, {- parser: "typescript",- plugins: [typescriptPlugin, estreePlugin],+ parser: "babel-ts",+ plugins: [babelPlugin, estreePlugin],});}const formattedEditableSource = await format(source.slice(ranges.prelude.to),{- parser: "typescript",- plugins: [typescriptPlugin, estreePlugin],+ parser: "babel-ts",+ plugins: [babelPlugin, estreePlugin],},);diff --git a/web/src/features/evals/utils/code-eval-template-starter-examples.ts b/web/src/features/evals/utils/code-eval-template-starter-examples.tsindex 815aaf1169..479075525c 100644--- a/web/src/features/evals/utils/code-eval-template-starter-examples.ts+++ b/web/src/features/evals/utils/code-eval-template-starter-examples.ts@@ -153,15 +153,18 @@ export function getCodeEvalSourceForEditor({}async function formatTypeScriptSource(source: string): Promise<string> {- const [{ format }, typescriptPlugin, estreePlugin] = await Promise.all([+ // babel-ts instead of the typescript plugin: the latter embeds the+ // TypeScript compiler, which the SWC minifier miscompiles (dropped+ // bindings β LFE-10645, caught by scripts/scan-client-bundle.mjs).+ const [{ format }, babelPlugin, estreePlugin] = await Promise.all([import("prettier/standalone"),- import("prettier/plugins/typescript"),+ import("prettier/plugins/babel"),import("prettier/plugins/estree"),]);return format(source, {- parser: "typescript",- plugins: [typescriptPlugin, estreePlugin],+ parser: "babel-ts",+ plugins: [babelPlugin, estreePlugin],});}