hotel-datepicker
hotel-datepicker copied to clipboard
Importing dependencies to prevent user's requirement to manually add dependencies...
Please excuse my horrible title. Also, I'm not incredibly experienced in creating NPM packages, so take this with a grain of salt.
So you're instructions to get this project installed, you state we need to do the following:
- Download Fecha
- Download HotelDatepicker
My question is, why are you requiring users to manually import Fecha, and not importing it within the package itself?
Since you have Fecha as a dependency on this project, it's already being installed inside of node_modules
, so adding a import fecha from "fecha"
to the top of src/js/hotel-datepicker.js
prevents any user from having to manually import it.
This issue really isn't that big of a deal, because I'm sure if I figured this out, then most of your advanced users will know this as well... but this project is quickly gaining traction (~400 downloads in the last two weeks) so making it easier on the beginners is just a small plus.
With all that being said, if I can make a small suggestion, please import Fecha inside the project itself, and change the installation instructions to the following:
Installation
- Run
npm i hotel-datepicker
- Add
import HotelDatepicker from "hotel-datepicker"
to yourapp.js
Anyways, thank you for creating this datepicker. I've been looking for a project like this for a while now and it has helped me tremendously. So again, thank you!
Have a great weekend!
I am not sure if it is correct to include Fecha directly in the script. Also because at the moment everyone is free to use the version of Fecha they prefer. Without necessarily having to use the one I decide. Also, I am afraid of causing other problems that I currently ignore.
I honestly don't know how other projects behave in such cases. Certainly, a library that has jQuery as a dependency does not include it in the script. But indeed jQuery is a separate case and probably the wrong example.
To me it would also be nicer it seeing working out of the box (the demo etc). Now users open the demo -> doesn't work, and possibly skip the project because they/we are lazy :).
Instead of telling the users they need to get fecha themselves, it could be removed from the initial work/readme, but could be another topic on how to change to another version a bit lower in the readme maybe.
Now users open the demo -> doesn't work, and possibly skip the project because they/we are lazy :).
Wait. The demo has Fecha, you don't need to import it. You need to install the dependencies (npm install
) of course. Then Fecha is installed in the node_modules
folder, see above.
What is being discussed here is whether to include it in the dist version, the one to be used in production.
I am not sure if it is correct to include Fecha directly in the script.
That's what every other package does that I've used. For example, let's take a look at TailwindCSS.
They have a huge list of dependencies that I did not have to manually install myself, because they are importing the dependencies themselves.
"node_modules/tailwindcss": {
"version": "3.1.5",
"dependencies": {
"arg": "^5.0.2",
"chokidar": "^3.5.3",
"color-name": "^1.1.4",
"detective": "^5.2.1",
"didyoumean": "^1.2.2",
"dlv": "^1.1.3",
"fast-glob": "^3.2.11",
"glob-parent": "^6.0.2",
"is-glob": "^4.0.3",
"lilconfig": "^2.0.5",
"normalize-path": "^3.0.0",
"object-hash": "^3.0.0",
"picocolors": "^1.0.0",
"postcss": "^8.4.14",
"postcss-import": "^14.1.0",
"postcss-js": "^4.0.0",
"postcss-load-config": "^4.0.1",
"postcss-nested": "5.0.6",
"postcss-selector-parser": "^6.0.10",
"postcss-value-parser": "^4.2.0",
"quick-lru": "^5.1.1",
"resolve": "^1.22.1"
},
I hope you don't think I mean to copy/paste the entire Fecha source into your project. I'm just talking about adding a import fecha from "fecha"
to the top of src/js/hotel-datepicker.js
, since you're setting fecha as a dependency and it's being installed in the node_modules anyway.
In my opinion, as the maintainer you should be specifying which version of Fecha you're using during development. That prevents any breaking changes if the user doesn't use the correct version.
If you're set on requiring users to manually install Fecha, then why are you requiring it as a dependency in your package.json?
Such a change does not involve simply importing Fecha at the beginning of the file. Remember that this library is not only used in Node environments.
In any case, if someone feels like doing a PR I can also consider including it.