browserify / browserify/wzrd.in
level-filesystem fails to bundle [was: Bundle fail]
- Dominant language
- JavaScript
- Stars
- 637
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
error:
```
Bundling error:
---FLAGRANT SYSTEM ERROR---
--- error #0: ---
Error: "browserify exited with code 8"
code: 8
stderr:
/home/admin/browserify-cdn/node_modules/browserify/index.js:628
var keys = Object.keys(a);
^
RangeError: Maximum call stack size exceeded
dirPath: /tmp/level-filesystem11465-1072-wx7l81
```
code:
``` js
var curry = require('ap')
var async = require('async')
var leveljs = require('level-js')
var levelup = require('levelup')
var filesystem = require('level-filesystem')
var treeify = require('treeify').asTree
var db = levelup('foo', { db: leveljs })
var fs = filesystem(db)
window.fs = fs
seedFs(function(){
buildIndex(function(error, fsObj) {
console.log( treeify(fsObj, false) )
})
})
function seedFs(callback) {
async.series([
curry(['index.js','DATA'], fs.writeFile),
curry(['package.json','DATA'], fs.writeFile),
curry(['lib'], fs.mkdir),
curry(['lib/util.js','DATA'], fs.writeFile),
], callback)
}
function buildIndex(callback) {
var rootPath = '/'
var fsObj = new Directory()
var rootDirObj = new Directory()
fsObj[rootPath] = rootDirObj
updateDir({dirPath: rootPath, dirObj: rootDirObj }, callback)
}
function updateDir(opts, callback) {
var dirPath = opts.dirPath
var dirObj = opts.dirObj
fs.readdir(dirPath, function(error, entityNameList) {
var entityPathList = entityNameList.map(function(entityName) {
return dirPath + '/' +entityName
})
async.map(entityPathList, fs.stat, function(err, statList) {
// add files + dirs to directoryObject,
// filter out subdirs for recursive updates
var subDirs = []
statList.map(function(stats, index) {
var entryName = entityNameList[index]
var entryPath = dirPath + '/'+ entryName
switch (stats.type) {
case 'file':
// dirObj[entryName] = stats
dirObj[entryName] = true
break
case 'directory':
var newDir = new Directory()
dirObj[entryName] = newDir
subDirs.push({
dirPath: entryPath,
dirObj: newDir,
})
break
default:
throw new Error('unknown fs entity type')
break
}
})
// recursively update subdirs
async.parallel(subDirs, updateDir, function() {
callback(null, dirObj)
})
})
})
}
function Directory(opts) {}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the JavaScript reproduction from the issue and confirm the failure at browserify/index.js:628, using the listed level-filesystem setup. Trace the bundling path around the reported maximum call stack error; done means this example bundles successfully without the recursive failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100