dnt icon indicating copy to clipboard operation
dnt copied to clipboard

Treeshaking of rewritten local dependencies

Open tom-sherman opened this issue 3 years ago • 2 comments

Reproduction:

  1. Checkout https://github.com/tom-sherman/response-multipart/commit/ebbe84ee913c7ff87905134ca774baf1f0fde268
  2. Run deno run --allow-all scripts/build_npm.ts

Actual behaviour:

npm/src/deps/deno.land/[email protected]/bytes/mod.ts contains unused exports

Desired behaviour:

Only the used exports should be included


It would be good if dnt tried to treeshake unused exports. It's fine if this is best effort IMO (all treeshaking is best effort anyways I believe)

tom-sherman avatar Jun 24 '22 22:06 tom-sherman

It would be a lot of work to do this. What you could do for now is add a post build step that uses a tool that performs tree shaking on the output.

dsherret avatar Jun 28 '22 16:06 dsherret

@dsherret Maybe it could be possible to leverage https://github.com/swc-project/swc/tree/main/crates/swc_bundler for figuring out the dependency graph and performing the tree shaking

tom-sherman avatar Jun 28 '22 16:06 tom-sherman

This is out of scope for dnt because it's a lot of work. I'd recommend using a separate tool to perform tree shaking on the output.

dsherret avatar Jun 08 '23 16:06 dsherret