bconfig
Structures a requirejs config into shim and remote objects to easier interface with browserify.
Last updated 7 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bconfig 
SYNC missed versions from official npm registry.

bconfig

Structures a requirejs config into shim and remote objects to easier interface with browserify.

requirejs config:

module.exports = {
  baseUrl :  '.',
  entry   :  'index.js', // pretend that exists
  paths   :  {
    jquery :  'vendor/jquery',

    // let's pretend we are in the nineties and still use modules that aren't on npm
    runnel :  'https://raw.github.com/thlorenz/runnel/master/index.js' 
  },
  shim: {
    jquery: {
      exports: '$'
    },
    runnel: {
      // doesn't really depend on it, but for demonstration purposes
      deps: { jquery: 'jquery'},
      exports: 'runnel'
    }
  }
};

Conversion Script:

var bconfig = require('bconfig');
var util = require('util');

var config = bconfig(require.resolve('./fixtures/requirejs-config'));
console.log(util.inspect(config, null, 5));

Output:

{ baseUrl: '.',
  entry: '/Users/.../dev/projects/bconfig/examples/fixtures/index.js',
  shim:
   { jquery:
      { path: '/Users/.../dev/projects/bconfig/examples/fixtures/vendor/jquery.js',
        exports: '$' } },
  remote:
   [ { deps: { jquery: 'jquery' },
       exports: 'runnel',
       key: 'runnel',
       url: 'https://raw.github.com/thlorenz/runnel/master/index.js' } ] }

Status

  • alpha version (fully working) -- tests pending
  • example separate-paths-shims pending

Installation

npm install bconfig

API

###bconfig (configPath, keepPathsAndShimSeparate)

/**
 * Analyzes a requirejs config and creates local shims/paths for local files and remote shims/paths for urls found in paths.
 * 
 * @name exports
 * @function
 * @param configPath {String} Full Path to requirejs config
 * @param keepPathsAndShimSeparate {Boolean} 
 *       if true, only paths will be split into local and remote, 
 *       otherwise aggregated shim and remote objects with all relevant information are returned
 * @return {Object} a more browserify friendly version of the config
 */

License

MIT

Current Tags

  • 0.1.3                                ...           latest (7 years ago)

6 Versions

  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 3
Dependencies (1)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |