#Can't get the typescript ESM loader to work

1 messages · Page 1 of 1 (latest)

shut cobalt
#

Following the getting started guide, I immediately run into the issue

exports is not defined in ES module scope

that's following the Getting started guide on the website https://docs.dagger.io/sdk/nodejs/783645/get-started. To note is that I'm using another existing repo rather than creating a new react app, but I doubt that'd make much of a difference.

I suspect I need something special in the tsconfig, but don't know what or if that's documented.

shut cobalt
#

Solved!

"module": "esnext", was the magic trick – probably good to have in the docs

finite marlin
#

Can you share more about this case? Node version? ts-node version? etc ?

#

Normally, you shouldn't need what you did

shut cobalt
#
  1. A tsconfig must exist
  2. That tsconfig should have esnext as its module configuration

This was the latest stable version of ts-node, tested across Node 16, 18, and 19

finite marlin
#

You are totally right. We completely didn't document that!

#

Can you write an issue on our repo so we can track/fix that?

lime grotto
shut cobalt
#

@finite marlin if you tell me the part of the docs where it makes sense I'll be happy to add it too 😄

lime grotto
shut cobalt
#

Indeed it does, that's how I found it. This is more broadly an issue of not having documentation for the likely scenario of using dagger with existing code

#

But that's a bigger thing

lime grotto
#

I hope dagger may be in a unique position of doing something more than only maintaining documentation (automatically tested on common CI platforms) and leaving the environment setup up to developers. It may be not just about running what normally is done in CI pipelines, but also about defining the environment and developer experience.

shut cobalt
#

Yeah I suppose in an ideal world, I can define TS dagger files without an npm project too; if you're working in an existing project you have to change it just for dagger, and if it's a non-TS project, you have to add all the extra "cruft" in for no reason other than making dagger/ts happy

finite marlin
#

Basically, we need a new documentation for existing projects already in typescript (they shouldn't need the tsconfig file, since it should already be there), existing project not in typescript (which will require the user to create this file). And then, just in javascript, which shouldn't require anything, but the code would be slightly different.

#

And I guess for those using deno, they wouldn't need the tsconfig, I believe.