Napoleon's Penguin Mascot

    shared-pack

    1.2.5 • Public • Published

    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

    Keywords

    none

    Install

    npm i shared-pack

    DownloadsWeekly Downloads

    1

    Version

    1.2.5

    License

    ISC

    Last publish

    Collaborators

    • wonderflow-user
    • bitliner