inhago
inhago2mo ago

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 in order for Deno to know that they're CommonJS. My question - is there a way to configure Deno to treat all .js files as CommonJS and all .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, which transpiles all ESM to commonjs before running) but it's yielding some weird syntax errors, like not recognizing export abstract class and simple decorators (Unexpected token '@'.). I'm using deno 2.3.7 and typescript 5.8.3
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?