Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing as dependency (instead of devDependency) makes final bundle big #180

Open
elledienne opened this issue May 5, 2022 · 2 comments

Comments

@elledienne
Copy link

I noticed that this library lists typescript as a peer dependency in the package.json. At the same time, the README suggests installing this library by doing npm install schema-dts.

What happens then is that when I generate the bundle for my server, this library and also typescript are being bundled together with my server code, making the bundle quite big (typescript alone is 3MB minified).

Am I doing something wrong? Or should this library be installed as a devDependency instead?

@Eyas
Copy link
Collaborator

Eyas commented May 16, 2022

Hm, great point.

If you use import {...} from 'schema-dts';, your bundler might not optimize away that import, so you might still need the empty index.js that comes with schema-dts. If you use import type {...} from 'schema-dts';, then you can probably just install it as a dev dependency.

I think removing typescript as a peer dependency is probably right, to allow folks to use this library however way they like without being too restrictive about bundling/optimizing. The side-effect being that without typescript in your development toolchain, this library isn't helpful at all.

Eyas added a commit to Eyas/schema-dts that referenced this issue May 16, 2022
This is one potential fix to google#180 that allows schema-dts to continue to be used
with `import` and any/no bundlers without increasing bundle size.

It is also possible to address google#180 by simply asking users to save
schema-dts as a dev dependency. This is generally more correct for
typings, but runs the risk of leaving dangling imports to nonexistent
"schema-dts" js.

We _may_ want to add TypeScript as a dev dependency instead. I'm not
sure.
Eyas added a commit to Eyas/schema-dts that referenced this issue Feb 27, 2023
This is one potential fix to google#180 that allows schema-dts to continue to be used
with `import` and any/no bundlers without increasing bundle size.

It is also possible to address google#180 by simply asking users to save
schema-dts as a dev dependency. This is generally more correct for
typings, but runs the risk of leaving dangling imports to nonexistent
"schema-dts" js.

We _may_ want to add TypeScript as a dev dependency instead. I'm not
sure.
@guy-borderless
Copy link

This change is required to use schema-dts in a serverless setting like deno-deploy, since including the 38MB of typescript makes the bundle size prohibitive. Any update on when this will be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants