Socket
Socket
Sign inDemoInstall

component-as-module

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    component-as-module

Require components from node programs


Version published
Weekly downloads
6
decreased by-14.29%
Maintainers
1
Install size
11.3 kB
Created
Weekly downloads
 

Readme

Source

component-as-module

It allows you to require components from node programs.

Lookup algorithm is slightly different from component/builder.js in that it does not respect .paths field from component.json.

Examples

Require stand-alone component (with all dependencies in a ./components dir):

var component = require('component-as-module')
var min = component('/path-to/component-min')

Setup loader:

var boot = component('boot', function(loader) {
  // add lookup paths
  loader.addLookup('./components')

  // enable dev dependencies
  loader.development()

  // register node module as a component
  loader.register('foo', require)
})

Alternative way to require components is to create a special "require" function:

var req = component.createRequire(function(loader) {
  loader.addLookup('components')
})

var min = req('component-min')

This differs in that all loaded components are preserved between calls, so, for example, requiring component-min the second time is fast and you get the same instance.

Installation

with npm

npm install component-as-module

To run tests

npm install -d
npm test

There is also component-npm-post-install script which can be used to make component package compatible with npm.

License

MIT

Keywords

FAQs

Last updated on 29 May 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc