{"id":17766553,"url":"https://github.com/floatdrop/bem-pack","last_synced_at":"2025-07-19T06:33:56.979Z","repository":{"id":20147474,"uuid":"23417840","full_name":"floatdrop/bem-pack","owner":"floatdrop","description":"Pack node-style source files from a stream of path's into a browser bundle","archived":false,"fork":false,"pushed_at":"2014-08-28T08:44:49.000Z","size":164,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T11:06:07.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"osrg/gobgp","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floatdrop.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-28T06:31:35.000Z","updated_at":"2022-04-12T02:33:40.000Z","dependencies_parsed_at":"2022-09-01T12:40:18.089Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/bem-pack","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbem-pack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbem-pack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbem-pack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbem-pack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/bem-pack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735795,"owners_count":20339530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-26T20:32:23.952Z","updated_at":"2025-03-15T13:30:50.450Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bem-pack\n\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url]\n\nPack node-style source files from a stream of path's into a browser bundle with require layering support.\n\n__Note:__ This plugin is __highly__ sensitive to order, in which you call `add` method.\n\n## Usage\n\n```js\nvar bempack = require('bem-pack');\nvar pack = bempack();\n\npack.add('base/base.js');\n    .add('main/base.js');\n    .bundle(function (err, buf) {\n        console.log(buf.toString());\n    });\n```\n\n## Require layering\n\nThis 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:\n\n```js\n// base.js\nmodule.exports = 'base';\n\n// myBase.js\nmodule.exports = require('./base.js') + ' extended!';\n```\n\nBut in BEM world you have same filename for javascript file in different layers of definition (or directoires):\n\n```js\n// base/base.js\nmodule.exports = 'base';\n\n// site/base.js\nmodule.exports = require('./base.js') + ' extended!';\n```\n\nAs 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:\n\n\u003e Every bundled file will \"export\" module with it BEM identifier.\n\nFor example `base__elem.js` will export `base__elem` module, that can be required in next bundled javascript file:\n\n```js\n// base/base.js\nmodule.exports = 'base';\n\n// site/base.js\nmodule.exports = require('base') + ' extended!';\n```\n\nThis is not stable way of doing layered requires, but it seems nice and simple to implement.\n\n## API\n\n### bem-pack([options])\n\nReturns instance of [browserify](https://github.com/substack/node-browserify) with additional step added to `deps` pipeline.\n\n#### options\n\nAll options are passed to [browserify constructor](https://github.com/substack/node-browserify#var-b--browserifyfiles-or-opts), except `ignoreMissing` is setted to true always.\n\n##### naming\nType: `Function`\n\nFunction, that will generate some kind of export name for given path.\nBy default we split filename by `.` and take first part. For our usage cases it will contain BEM identificator.\n\n## License\n\nMIT (c) 2014 Vsevolod Strukchinsky\n\n[npm-url]: https://npmjs.org/package/bem-pack\n[npm-image]: http://img.shields.io/npm/v/bem-pack.svg?style=flat\n\n[travis-url]: http://travis-ci.org/floatdrop/bem-pack\n[travis-image]: http://img.shields.io/travis/floatdrop/bem-pack.svg?branch=master\u0026style=flat\n\n[depstat-url]: https://david-dm.org/floatdrop/bem-pack\n[depstat-image]: http://img.shields.io/david/floatdrop/bem-pack.svg?style=flat\n\n[coveralls-url]: https://coveralls.io/r/floatdrop/bem-pack\n[coveralls-image]: http://img.shields.io/coveralls/floatdrop/bem-pack.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fbem-pack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fbem-pack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fbem-pack/lists"}