A repo to kickstart your next typescript private node module.
- Typescript - typed superset of JavaScript
- GruntJs - task and build tool
- Jasmine - tests written in Jasmine
- Istanbul - test coverage
- Webpack - module bundler
- To start your new node module using this seed app, clone this repo to a new directory:
git clone https://github.com/nathan-andosen/node-module-seed.git my-module-name
cd my-module-name
git remote rm origin
- Now you can start working on your module. Delete both classes in the /src directory and both of the spec files in the _/spec/ directory. IMPORTANT: Do not delete the always.spec.ts file just yet, you always need a spec file so that the generated output goes into the directory /compiled/src/. Once you create your own spec file, you can delete the always.spec.ts file.
npm run init
- Setup the app for development (run once after cloning)
npm run dev
- Run this command when you want to work on this app. It will
compile typescript, run tests and watch for file changes.
npm run build -- -v <version>
- Create a distribution build of the app.
-v (version) - [Optional] Either "patch", "minor" or "major". Increase the version number in the package.json file.
The build command creates a /compiled directory which has all the javascript compiled code and typescript definitions. As well, a /dist directory is created that contains a minified javascript file.
Tests are automatically ran when you do a build.
npm run test
- Run the tests. The tests will be ran in a nodejs environment.
You can run the tests in a browser environment by opening the file
/spec/in-browser/SpecRunner.html.
import { ClassOne } from 'node-module-seed';
let classOne = new ClassOne();
Simple include the minified file in your page. Webpack is used to compile the minified file, it places all the code into a global property called XApp. You can change this in the /webpack.config.js file.
<script src="dist/my-class.js" type="text/javascript"></script>
var classOne = new XApp.ClassOne();
MIT © Nathan Anderson