top | item 42767900

(no title)

plopz | 1 year ago

I think the biggest hurdle in getting something like that to work is how typescript handles the import syntax

discuss

order

WorldMaker|1 year ago

Most of the "drama" in recent Typescript, such as requiring file extensions, with the import syntax has been aligning with the Browser/Node requirements. If you set the output format to a recent enough ESM and the target platform to a recent enough ES standard or Node version it will be a little more annoying about file extensions, but the benefit is that it import syntax will just work in the browser or in Node.

The only other twist to import syntax is marking type-only imports with the type keyword so that those imports can be completely ignored by simple type removers like Node's. You can turn that check on today in Typescript's compile options with the verbatimModuleSyntax [1] flag, or various eslint rules.

[1] https://www.typescriptlang.org/tsconfig/#verbatimModuleSynta...

madeofpalk|1 year ago

you just tell typescript to stay away from import syntax, and use node-native resolution and it all just works.

its 2025 and node is finally good :)

dunham|1 year ago

It would be nice if node did tail call optimization, but that seems unlikely at this point (v8 added and then removed it). I've been using bun as a backend for my toy language because of this.