dnt icon indicating copy to clipboard operation
dnt copied to clipboard

Use case: Code transform step without esModule/scriptModule emitting

Open dylanpyle opened this issue 11 months ago • 0 comments

Hiya—

My use case here is exporting a shared library from an existing larger Deno codebase, to be consumed by number of different TypeScript apps running in both Deno and on the web — i.e. just using dnt for the first "code transform" & shimming step without any actual JS compilation.

This almost works perfectly but turns out to be a bit tricky for a couple of minor reasons:

  • The .ts-to-.js import path rewriting [^1] means that other Deno apps can't load files from the transformed source directory, as the extensions are now '.js'.
    • (ref: https://github.com/denoland/dnt/issues/154 - I think this is one use case where that's undesirable)
  • I don't need scriptModule or esModule outputs (just the transformed TypeScript source code), however dnt throws an error if both are disabled.

I'd be happy to make a PR to make both of those behaviors configurable, but mostly wanted a gut check first - is this a bad idea / does this align with dnts goals / am I misunderstanding something fundamental here?

[^1]: edit: Looks like this is perhaps actually happening somewhere deeper than that, but — same idea.

dylanpyle avatar Mar 21 '24 19:03 dylanpyle