You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our project builds the uniform.js client-side library directly to the build/ directory which is served to the user. However, most projects will use us by performing an npm install uniform-validation, meaning that build/ directory is hidden inside our node_modules folder and cannot be easily served to the user (it is actually ignored by NPM anyways).
We need a way for the developer to easily serve the client-side library to the user. Something along the lines of a function validator.getClientLib() which would return the client library (as a promise since it needs to be read off the file system). This can then be served to the user when they request whatever URL the developer chooses to host Uniform at (in this case /uniform.js).
From the client's point of view, they would load the library with simply:
<scriptsrc="/uniform.js"></script>
This does make it slightly more complicated to install Uniform and get it working, which is a bit of a drawback. On the plus side, it serves the client and server side libraries off the same codebase installed with the same package manager, so there's no possibility of a version mismatch. The only other options would be something like using bower to manage the client-side package, but that complicates the build process significantly and makes things tricky for the user regardless, since they would have to install the client-side library separately and could easily update one, but forget the other. I think this solution of a simple getClientLib() function is the best option.
The text was updated successfully, but these errors were encountered:
Implemented the above interface. Works without any known issues.
Went through a few version of the NPM package to figure out how to get .npmignore working correctly. I relearned out how to locally debug packages half-way through this, which reminded me make some documentation for that (#57).
Our project builds the
uniform.js
client-side library directly to thebuild/
directory which is served to the user. However, most projects will use us by performing annpm install uniform-validation
, meaning thatbuild/
directory is hidden inside ournode_modules
folder and cannot be easily served to the user (it is actually ignored by NPM anyways).We need a way for the developer to easily serve the client-side library to the user. Something along the lines of a function
validator.getClientLib()
which would return the client library (as a promise since it needs to be read off the file system). This can then be served to the user when they request whatever URL the developer chooses to host Uniform at (in this case/uniform.js
).From the client's point of view, they would load the library with simply:
This does make it slightly more complicated to install Uniform and get it working, which is a bit of a drawback. On the plus side, it serves the client and server side libraries off the same codebase installed with the same package manager, so there's no possibility of a version mismatch. The only other options would be something like using
bower
to manage the client-side package, but that complicates the build process significantly and makes things tricky for the user regardless, since they would have to install the client-side library separately and could easily update one, but forget the other. I think this solution of a simplegetClientLib()
function is the best option.The text was updated successfully, but these errors were encountered: