Write code in NodeJS/NPM, compile it for AngularJS/bower.
- npm
- node.js
npm install -g shared-pack
The module should satisfy the following 2 conditions:
- it should be exposed as node.js module - using
module.exports
- the function to expose should be the angular.js function - with dependencies declared as parameters of the function
- crete folder:
mkdir shared-module && cd $_
- initialize bower.json and package.json
bower init && npm init
- create module, example
shared-service.js
:'use strict'; function SharedService(param1) { console.log('Ola', param1); } module.exports = SharedService;
shared-pack ./shared-service.js
The results fo compilation will be a foldr ./build
containing 2 files
-
./build/shared-service.angular.js
function SharedService(param1) { console.log('Ola', param1); } angular.module('SharedService', ['param1']) .factory('SharedService', ['param1', SharedService]);
bower.json
...
"main":"./build/shared-service.angular.js",
...
- Remove generation of node.js file
- Create a parser module with following functions:
- getDependenciesNames(moduleString) // extract require instructions, removing eventually user prefix
- other methods ...
- Fix compilation for AngularJS: the node exported object should be in a wrapping function, depednencies should be delcared in the wrapping function, and the wrapping function should return the exported object
- Add support for semantic versioning of bower:
shared-pack ./node-file.js patch|minor|major
changes field "version" in bower.json. - Add support for updating bower.json dependencies based on modules installed via npm
- Add support for updating bower.json with git address for private packages
- Add support for private npm packages