Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bem-pack

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bem-pack - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

coverage/coverage.json

10

package.json
{
"name": "bem-pack",
"version": "0.0.0",
"version": "0.1.0",
"description": "Pack node-style source files from a stream of path's into a browser bundle",

@@ -13,3 +13,4 @@ "keywords": [

"scripts": {
"test": "mocha -R spec"
"test": "mocha -R spec",
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
},

@@ -26,5 +27,8 @@ "repository": {

"should": "^4.0.4",
"mocha": "*"
"mocha": "*",
"coveralls": "^2.7.0",
"istanbul": "^0.3.0",
"mocha-lcov-reporter": "^0.0.1"
},
"main": "index.js"
}
# bem-pack
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url]
Pack node-style source files from a stream of path's into a browser bundle with redefinition support.
Pack node-style source files from a stream of path's into a browser bundle with require layering support.

@@ -22,2 +22,40 @@ __Note:__ This plugin is __highly__ sensitive to order, in which you call `add` method.

## Require layering
This feature is really handy, when you want to achieve flexible extension of javascript files, that not exported in modules. In normal world to extend some `base` module you possible create `myBase` module and require `base` constructor from `myBase` constructor:
```js
// base.js
module.exports = 'base';
// myBase.js
module.exports = require('./base.js') + ' extended!';
```
But in BEM world you have same filename for javascript file in different layers of definition (or directoires):
```js
// base/base.js
module.exports = 'base';
// site/base.js
module.exports = require('./base.js') + ' extended!';
```
As you can see, snippet above will not work properly, because you should fix the path of the require call. Ofter there is no way to do this, because order of layers can change eventually. So we come up with this idea:
> Every bundled file will "export" module with it BEM identifier.
For example `base__elem.js` will export `base__elem` module, that can be required in next bundled javascript file:
```js
// base/base.js
module.exports = 'base';
// site/base.js
module.exports = require('base') + ' extended!';
```
This is not stable way of doing layered requires, but it seems nice and simple to implement.
## API

@@ -48,1 +86,7 @@

[travis-image]: http://img.shields.io/travis/floatdrop/bem-pack.svg?branch=master&style=flat
[depstat-url]: https://david-dm.org/floatdrop/bem-pack
[depstat-image]: http://img.shields.io/david/floatdrop/bem-pack.svg?style=flat
[coveralls-url]: https://coveralls.io/r/floatdrop/bem-pack
[coveralls-image]: http://img.shields.io/coveralls/floatdrop/bem-pack.svg?style=flat
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc