Welcome Library
Introduction
The welcome
Library is a minimal (getting started) javascript library that will welcome you from two modules.
The story (or blog) over this repository can be found here:
This repository will build a library:
- exposed as the global variable
welcome
- saved in the file
prefix-welcome.js
- aggregating two modules (
foo
andbar
) - testing a method
The tool used are:
- Node for the module dependency
- WebPack as builder.
- Jest as test runner
Output
The output from the browser or from Node will be
Welcome from the foo package !A warm Welcome from the bar package !
Usage of the Git Repository
- Install Node
- Clone this repository
git clone https://github.com/gerardnico/welcomejs
- Execute a
npm install
- Execute a
npm run test
to execute the test with Jest throughnpm
npm run test
- Execute a
npm run build
to build the libraryprefix-welcome.js
in the directorydist
npm run build
- Run the examples given in the usage section below.
Usage of the final library with examples
Node
See the file welcomeLibInNode.js
var welcome = ;console;console;
- Run it
C:\welcome\example>node welcomeLibInNode.js
- Output:
Welcome from the foo package !A warm Welcome from the bar package !
Browser
See the file welcomeLibInBrowser.html
<!--If published in Node<script src="https://unpkg.com/myLisbrary"></script>Otherwised locally-->
- Run it:
Note on dependency
Note on thenpm
configuration file package.json
:
Babel
has been added to be able to use theimport
statement with thejest
test framework.jest
is a node process and actually understand onlyrequire
Webpack 2
understands natively theimport
statement.
Git
package-lock.json
should be versionned. npm create it. It's a lockfile that is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.