wzrd.in
wzrd.in copied to clipboard
level-filesystem fails to bundle [was: Bundle fail]
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:
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) {}
What happens if you try to browserify this code locally? It appears that this is a problem with either your code or browserify.
This is coming from requirebin? wzrd.in doesn't ingest javascript code, just package.json-style dependencies hashes.
works fine locally with no browserify flags/transforms, i only had one file so i thought i might throw it into requirebin and see what happens
Weird. Possibly needs a browserify upgrade?
Here's the original payload:
{
"options": {
"debug": true
},
"dependencies": {
"ap": "latest",
"async": "latest",
"level-js": "latest",
"levelup": "latest",
"level-filesystem": "latest",
"treeify": "latest"
}
}
Here's a minimal reproducing case:
curl http://wzrd.in/multi -d '{"options":{"debug":true},"dependencies":{"level-filesystem":"latest"}}'