First of all, I'm sorry for mostly abandoning the issue I opened in the old repository.
As you pointed out, a lot has changed since the end of January when I initially opened the issue.
One thing however remained mostly unchanged: There is no "practical" way of using the library in node.
What do I mean by practical? For better or worse, npm is the de facto standard for node dependency and version management. The vast, vast majority of node projects use npm. That's by no means limited to server-side projects - most modern frontend frameworks use and depend on npm modules. In other words: If you are starting any new JavaScript project using a modern stack, npm is more or less inevitable.
Now, when you find a good library - like this one - that you want to use in your npm-dependent project, you can't just npm install
or yarn add
it. Downloading the library and adding it to your project is more cumbersome yet still simple enough. But suddenly there's a moving part in your repository, which is managed completely different from the rest of your dependencies, and you need to keep track of it and update it.
So while it's currently not impossible to use this library in a npm-dependent project (read: most JS projects), it's a total pain in the ass to do so.
Good news: It doesn't have to be. It's very easy to publish this library to npm without touching the build system or anything else.
For this to work, the library needs to have a version number (I very strongly suggest following semver) and a name (I'd suggest @sleepdiary/core
, see at the end of this issue).
All we would need to change in the repository is add a package.json
that looks like this:
{
"name": "@sleepdiary/core",
"description": "A short and precise description",
"version": "0.1.0",
"main": "sleepdiary-library.min.js",
"repository": "sleepdiary/library",
"license": "MIT",
"scripts": {
"prepare": "docker run --rm -v \"$PWD\":/sleepdiary-library $(docker build -q .)"
},
"files": [
"sleepdiary-library.min.js"
],
"dependencies": {
"timezonecomplete": "^5.12.4",
"xmldom": "^0.6.0"
}
}
That's essentially it.
In order to publish a new version of the module, you can either run npm publish
, which will simply build the library, pack and publish it, or you can use something like np
, an improved npm publish
that also helps with versioning, release tagging, etc.
To revisit the issue of naming: I propose the syntax of @sleepdiary/<module>
. The @
symbol indicates that the module belongs to the sleepdiary
user (see npm scope). Moreover, the syntax allows the user to easily identify which modules belong to which project.
All three modules that are part of the sleepdiary project could be published this way, named @sleepdiary/core
, @sleepdiary/info
and @sleepdiary/report
respectively. @sleepdiary/core
is a personal suggestion, as the term library is quite ubiquitous in this context, but it could just as well be named @sleepdiary/library
or anything else. Obviously, it makes sense to keep the names consistent.
To summarize: It's very little effort to implement and maintain this and it would allow for this library to be used in any npm-dependent project just as easily as any other module.