deathcap / nodeachrome

run Node.js scripts in Google Chrome (experimental)
MIT License
2 stars 0 forks source link

browserify: ParseError: Unexpected character '' - fs.read inout buffer null #9

Closed deathcap closed 8 years ago

deathcap commented 8 years ago

g.evalsb('G.browserify("h.js").bundle().pipe(G.process.stdout).toString()')

After https://github.com/deathcap/nodeachrome/issues/8 this gets further, but fails in:

bundle-sandboxed.js:24849 Uncaught /h.js:1

^ ParseError: Unexpected character ''

syntax-error check:

module.exports = function (src, file) {
    if (typeof src !== 'string') src = String(src);

    try {
        eval('throw "STOP"; (function () { ' + src + '})()');
        return;
    }

src.length 28 src.charCodeAt(0) 0 src.toString() "" JSON.stringify(src) ""\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000""

fs.read buffer is null - need to return this data back (inout buffer), bad/incomplete fix for GH-8

deathcap commented 8 years ago

Or get the data back from the callback - "The callback is given the three arguments, (err, bytesRead, buffer)."

deathcap commented 8 years ago

Now this is fixed, browserify works:

g.evalsb('cat("h.js")')

null "console.log('hello world'); "

g.evalsb('G.browserify("h.js").bundle().pipe(G.process.stdout).toString()')

…prelude…
})({
bundle-sandboxed.js:10519 stdout: 1:[function(require,module,exports){
console.log('hello world');

},{}]