Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rreusser/bundle-collapser-uniqueness-failure
Reproduction of bundle-collapser#20 in which non-unique relative pathnames lead to non-unique bundle IDs
https://github.com/rreusser/bundle-collapser-uniqueness-failure
Last synced: 7 days ago
JSON representation
Reproduction of bundle-collapser#20 in which non-unique relative pathnames lead to non-unique bundle IDs
- Host: GitHub
- URL: https://github.com/rreusser/bundle-collapser-uniqueness-failure
- Owner: rreusser
- Created: 2017-10-02T18:17:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-02T22:34:13.000Z (about 7 years ago)
- Last Synced: 2024-10-26T12:12:53.214Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bundle-collapser-uniqueness-failure
Created to demonstrate [bundle-collapser#20](https://github.com/substack/bundle-collapser/issues/20), in which non-unique relative pathnames lead to non-unique bundle IDs, which leads to incorrect requires.
## To reproduce
### Setup
Setup is two directories containing index files with similar `require('./component')` statements.
```
├─ index.js
├─ a
│ ├─ index.js
│ └─ component.js
└─ b
├─ index.js
└─ component.js
```### baseline
Correct behavior using browserify alone:
```bash
$ browserify index.js > bundle.js
$ node bundle.js
aVal: a
bVal: b
```### CLI
Using bundle-collapser as a command line plugin. Values are incorrect:
```bash
$ browserify -p bundle-collapser/plugin index.js > bundle.cli.js
$ node bundle.cli.js
aVal: a
bVal: a
```### API plugin usage
Using bundle-collapser as a script plugin is (obviously?) the same:
```javascript
// scripts/plugin.jsvar browserify = require('browserify');
var collapse = require('bundle-collapser/plugin');
var fs = require('fs');browserify('index.js', {plugin: [collapse]}).bundle()
.pipe(fs.createWriteStream('bundle.plugin.js'));
``````bash
$ node scripts/plugin.js
$ node bundle.plugin.js
aVal: a
bVal: a
```### API function usage
Running it as a function directly leads to the same incorrect result:
```javascript
// scripts/api.jsvar browserify = require('browserify');
var collapse = require('bundle-collapser');
var fs = require('fs');
var toString = require('stream-to-string');toString(browserify('index.js').bundle(), function (err, str) {
collapse(str).pipe(fs.createWriteStream('bundle.api.js'));
});
``````bash
$ node scripts/api.js
$ node bundle.api.js
aVal: a
bVal: a
```