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

export package.json from package.json #123

Closed
wants to merge 1 commit into from

Conversation

tborychowski
Copy link

@tborychowski tborychowski commented Oct 28, 2022

As weird as this sounds - someone has invented a rule now, that package.json should be exported from package.json.

Without this - some of the bundlers show a weird and annoying console log messages, like this one:

CleanShot 2022-10-28 at 10 36 36@2x

More details here: sveltejs/rollup-plugin-svelte#181

If it's not a problem, please merge this 1 line and allow my OCD to move on 😉

@mymth
Copy link
Owner

mymth commented Nov 1, 2022

This was reported in #99, and I thought about it. (see the last paragraph of my comment there.)

At the time, I was slightly leaning to add it, seeing another developer did it. But every time I re-thought, I ended up with the same question, "What's the point of exposing my package.json only to tell rollup-plugin-svelte that my package doesn't contain svelte components? My package.json doesn't contain anything to share with the outside JavaScript world other than npm itself..." Then I stopped re-thinking about it. So now, I kind of decided not to do it.

My understanding on Node.js's document quoted in their issue #181 is that it only says that if you want to allow other packages to use your package's info, you need to export your package.json too. It actually never says exporting package.json is a new standard or convention. (I took a look at all module-related sections, but couldn't find any mentions of it. Of course, I may have overlooked. Please let me know if I did)
This means that I don't need to export my package.json if I don't need to let other packages see my package's info, doesn't it? Or, is it implicitly saying that every package should make it possible for their users to do something like this?

const pkgInfo = require('vanillajs-datepicker/package.json');
console.debug(`I'm using ${pkgInfo.name} v${pkgInfo.version}.`);

(but if so, what's the point of its being concealed by default?)

If the warning were from rollup itself (not from a plugin), I would add it without hesitation because it would be for everyone who uses rollup (including this project), no matter what framework, component system, and/or libraries they use. But it's from a plugin for a component system I didn't make this library for. And, as I said in the comment above, I don't know any other libraries that expect this. (If anyone know some, please educate me.)

I can't help but feeling like "What's the problem for them with considering it as package.json is not exported because it doesn't include the svelte field?"

@tborychowski
Copy link
Author

Haha, I completely understand your concerns and share your opinion (I commented similarly in the original issue).
Anyways, thanks for spending time investigating this and writing this lengthy comment :-)
I respect your decision.
Thanks.

Btw. I will keep using this lib as it plays nicely with my svelte components, because it's the best one I've found, so kudos to you! 😄

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

Successfully merging this pull request may close these issues.

None yet

2 participants