@dynameyes/js-utils v0.1.4
🤚🏿Prerequisite
Since this is a privately published package. You need to set your NPM registry to use the registry of dynameyes so all @dynameyes packages will be resolved properly.
Before running npm install --save @dynameyes/js-utils
do:
To easily manage between npm registries see nrm
*Note: Make sure you are using dynameyes VPN or your IP is whitelisted on the registry server so you can use this package.*
📦 Usage
via NPM
This has not been fully tested yet !!! Currently tree shaking is not tested yet. So the best way to import modules is to import the file directly. See second code snippet.
import { module1, module2 } from '@dynameyes/js-utils';
import '@dynameyes/js-utils/index.css' // If you import a CSS file in your library
module1(1,2)
module2(3,4)
...
Method of importing module file directly. (Recommended) - This will ensure you will be only including on your final bundles the modules you will only use.
import module1 from '@dynameyes/js-utils/module1';
import module2 from '@dynameyes/js-utils/module2';
import '@dynameyes/js-utils/index.css' // If you import a CSS file in your library
module1(1,2)
module2(3,4)
...
via CDN
This has not been implemented yet !!! Currently we don't have a use case to use the library as CDN so it has not been implemented yet.
<link href="index.css" rel="stylesheet">
<script src="index.js"></script>
const module1 = window.jsUtils.module1;
module1(1,2)
...
Contributing Guide
All sections below are for the developers that wants to contribute/edit something on this repository.
👊🏻 Getting Started
npm start
- to start development and see console.log in the opened browser.npm run test
- to run a unit test on the last file changed.npm run build
- to build the library.npm run watch:docs
- to serve docs and automatically reloads on source file change.
🚑 Caveats
- Publishing/Packing the library only includes all files inside the build directory. So make sure any file you need to be included for the user to use should be included on the build directory. See copyPackageJsonAndBinDir in
scripts/build.js
- Our build directory will expose all utility files as 1 level deep even if our source directory has multiple levels. see
scripts/reduceRequireToOneLevel.js
. We expose everything as 1 level deep so users can just doimport "@dynameyes/js-utils/<module_name>"
- Only utility files under a certain category will be transpiled on the build directory. This means two-level deep js files will be the only files transpiled. See
npm script transpile
which uses the glob patternsrc/lib/**/**
. - This repo is only meant to host utility functions and should not include any UI component nor should it include any utility function tied to a specific framework. All utility function should work on any frontend framework.
- CDN and tree-shaking has not been tested yet
- Bootstrapped from js-library-boilerplate
⭐️ Features
- Webpack 4
- Babel 7
- Hot Reloading (
npm start
) - CSS Autoprefixer
- SASS/SCSS support
- UMD exports, so your library works everywhere.
- Based on CRA v3.1.1 (For Vanilla JS libs or React libs)
- Jest unit testing
(not applicable for our current use case)npm run demo
To build a ready-for-deployment demo (Example)- Customizable file headers for your build (Example 1) (Example2)
- Daily dependabot dependency updates
🚡 Test Deployment
npm run package
- Check the packaged tarball inside the build directory. You can use that to test how well the library look like inside node_modules once installed
🚀 Deployment
npm run publish
- Your users can include your library as usual