DenoDDeno
Powered by
inhagoI
Denoβ€’9mo ago
inhago

Migrate very big hybrid project to Deno

Hey folks! I'm trying to figure out if we can migrate our 6M LOC from Node to Deno. A year ago it was fully commonjs, but when I joined the company I was stupefied by that and started a project to migrate it to Typescript. Nowadays about 30% of the codebase is written in Typescript (ESM) while the rest is in Javascript (CommonJS).

We currently use a mix of SWC and Babel to transpile and bundle the code and the tests. I started playing with Deno but realized it can only handle either fully CommonJS (meaning it won't recognize ESM files exist) or ESM (meaning it will break when seeing any require). That is unless I rename all thousands of JS files to
.cjs
.cjs
in order for Deno to know that they're CommonJS.

My question - is there a way to configure Deno to treat all
.js
.js
files as CommonJS and all
.ts
.ts
files as ESM modules?

Another tangent - I tried using the same setup we're using for node (
SWCRC=true deno -r @swc-node/register server.js
SWCRC=true deno -r @swc-node/register server.js
, which transpiles all ESM to commonjs before running) but it's yielding some weird syntax errors, like not recognizing
export abstract class
export abstract class
and simple decorators (
Unexpected token '@'.
Unexpected token '@'.
).

I'm using
deno 2.3.7
deno 2.3.7
and
typescript 5.8.3
typescript 5.8.3
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

migrate from node to deno: p5js project
KitamadoKKitamado / help
3y ago
migrate node to deno
Th3Us3rNam3TTh3Us3rNam3 / help
12mo ago
Deno + Vite + DenoKV
AndiAAndi / help
2y ago
Migrate Node to deno in Next function
朝ε‡ͺ朝朝ε‡ͺ / help
2y ago