1.2.5 • Published 8 years ago

shared-pack v1.2.5

Weekly downloads
2
License
ISC
Repository
-
Last release
8 years ago

shared-pack

Write code in node.js, and use it on node.js or angular.js platforms.

Index

Requirements

  • npm
  • node.js

Installation

npm install -g shared-pack

Usage

  1. Create a node.js module
  2. Compile
  3. Configure properly package.json and bower.json

Create a javascript module

The module should satisfy the following 2 conditions:

  1. it should be exposed as node.js module - using module.exports
  2. the function to expose should be the angular.js function - with dependencies declared as parameters of the function

Example

  1. crete folder: mkdir shared-module && cd $_
  2. initialize bower.json and package.json bower init && npm init
  3. create module, example shared-service.js:

    'use strict';
    
    function SharedService(param1) {
    	console.log('Ola', param1);
    }
    
    module.exports = SharedService;

Compile

shared-pack ./shared-service.js

Results

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]);
    	```
  • ./build/shared-service.node.js

    	```
    	function SharedService(param1) {
    		console.log('Ola', param1);
    	}
    
    	 module.exports = SharedService(require('param1.js'));
    	```

Configure properly main field in bower.json and package.json

bower.json

	...
	"main":"./build/shared-service.angular.js",
	...

package.json

	...
	"main":"./build/shared-service.node.js",
	...

Roadmap

  1. Add support for private npm packages
1.2.5

8 years ago

1.2.4

8 years ago

1.2.0

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago