typescript compiler (38.24MB) included in bundle when importing google's npm:schema-dts

Not sure if this is a bug, but I couldn't see how the package imports the compiler. create a ts file with: import type { Accommodation } from "npm:schema-dts" deno info [file.ts] file.ts └─┬ npm:schema-dts@1.1.2 (857.9KB) └── npm:typescript@5.1.3 (38.24MB)
5 Replies
Josh
Josh2y ago
Doesn't seem like a bug to me since the NPM TypeScript package is separate
shultz🇮🇱
shultz🇮🇱OP2y ago
can you please explain a bit? importing a type should inflate the bundle so much?
Josh
Josh2y ago
schema-dts relied on the typescript NPM package, and that package is pretty large. I don't think there's a way to have an NPM package use Deno's TypeScript implementation
shultz🇮🇱
shultz🇮🇱OP2y ago
It's a dev dependenciy. also since I'm only importing a type, why does it bundle the runtime? https://github.com/google/schema-dts/blob/main/package.json
GitHub
schema-dts/package.json at main · google/schema-dts
JSON-LD TypeScript types for Schema.org vocabulary - google/schema-dts
Josh
Josh2y ago
Because it cached the entire package and all its dependencies. If you only need the type and not the whole package, you can technically copy and paste the class into your project, or copy the entire type definition file and paste it into your project to use I don't know if Deno bundling is any good at tree shaking NPM packages

Did you find this page helpful?