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

Question about dev dependencies. #26

Closed
icy0307 opened this issue Jun 7, 2023 · 8 comments
Closed

Question about dev dependencies. #26

icy0307 opened this issue Jun 7, 2023 · 8 comments

Comments

@icy0307
Copy link

icy0307 commented Jun 7, 2023

Nice Work!
To be clear, this is a question no a bug.
In the readme,
you said

This will bundle your devDependencies in while leaving your dependencies, peerDependencies and optionalDependencies external.
So the default value of devDeps is true.
My question is that what is the scenario that someone wants to ship their library with dev dependencies bundled?

@Septh
Copy link
Owner

Septh commented Jun 7, 2023

Actually, the default value of devDeps is false - i.e., development dependencies are not external. Only deps, peerDeps and optDeps have a default value of true - i.e., these dependencies are external. I double checked the README, this exactly is what is stated. 🙂

The scenario is, that when someone install your library as part of their project, npm will also install your lib's dependencies (and probably peers and maybe optionals). Those are required to make the library work on the user's computer.

On the other hand, devDependecies are dependencies that you, the author, need to build the library. Your user do not need them.

This scenario is the standard behavior of npm and this is what the default settings for this plugin support.

@icy0307
Copy link
Author

icy0307 commented Jun 7, 2023

@Septh
sorry, my mistake.
My original question is why not set devDeps default setting to true, make it external, like the rest.
As you said,

Your user do not need them.

So what is point to bundle this?
I came across this problem when working in some kind of di library.
Most of di library need reflect-metadata or something else to polyfill metadata api. But NOT list is as a dependency, but a dev depdency
The default behavior of [rollup-plugin-node-externals](https://github.com/Septh/rollup-plugin-node-externals)will bundle this.

@Septh
Copy link
Owner

Septh commented Jun 7, 2023

Most of di library need reflect-metadata or something else to polyfill metadata api. But NOT list is as a dependency, but a dev depdency

reflect-metada's readme instructs to install the package as a dependency. I'm not sure why InversifyJS use it as a devDependency, maybe they have a build step of some kind?

@icy0307
Copy link
Author

icy0307 commented Jun 7, 2023

@Septh
I think it is only an old mistake to avoid non-singleton problem
It probably should list is as a dependency like core-js, after all , it is only a form of polyfill.
But again , for this repo, maybe change the default behavior of dev dependency is better? it is quite hard to find a situation that library need bundle dev dependency and not to treat it as external.

@Septh
Copy link
Owner

Septh commented Jun 7, 2023

it is quite hard to find a situation that library need bundle dev dependency and not to treat it as external.

On the contrary, this is the typical case. If your code imports or requires a devDependency, then this dep has to be bundled in by Rollup otherwise the imported code won't be available to your user at runtime. Makes perfect sense.

@icy0307
Copy link
Author

icy0307 commented Jun 7, 2023

Yes , you are right. my mistake.
The code shouldn't require it as a dev dependency.
Thanks for your detailed explanation. 😁

@icy0307 icy0307 closed this as completed Jun 7, 2023
@renyuneyun
Copy link

Great discussion...
To test my understanding: this plugin will not bundle a devDependency if it is not import-ed or require-ed, right? Therefore, tools such as typescript will not be bundled, even though listed as devDependency.

@Septh
Copy link
Owner

Septh commented Mar 12, 2024

You're correct.

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