revert: bring back Babel CJS transform (#3798)

## Summary

Reverts two commits that broke CJS package handling in dev mode:

- Reverts #3793 (CJS detection regex fix)
- Reverts #3767 (removal of Babel CJS→ESM transform)

The simplified CJS shim introduced in #3767 has two fundamental issues:
1. **Detection**: the heuristic (`code.includes("export ")`) is fooled
by comments containing "export"
2. **Named exports**: the shim only provides `export default
module.exports`, so `import { trace } from "@opentelemetry/api"` returns
`undefined` (#3797)

The Babel-based transform handled both correctly. Bringing it back until
we can replace it with a proper solution using `deno_ast`'s CJS parser.
This commit is contained in:
Bartek Iwańczuk
2026-04-28 13:20:33 +02:00
committed by GitHub
parent 2cf68af996
commit 8c148663e6
17 changed files with 2051 additions and 234 deletions
@@ -452,17 +452,6 @@ Deno.test({
sanitizeResources: false,
});
Deno.test({
name: "vite dev - CJS npm package (qs)",
fn: async () => {
const res = await fetch(`${demoServer.address()}/tests/cjs_npm`);
const text = await res.text();
expect(text).toContain("<h1>qs-ok</h1>");
},
sanitizeOps: false,
sanitizeResources: false,
});
// issue: https://github.com/denoland/fresh/issues/3666
integrationTest(
"vite dev - basePath does not intercept Vite URLs",