mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
720 stars 147 forks source link

export package.json from package.json #123

Closed tborychowski closed 1 year ago

tborychowski commented 1 year ago

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: https://github.com/sveltejs/rollup-plugin-svelte/issues/181

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

mymth commented 1 year ago

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 commented 1 year ago

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! 😄