From the documentation:
browserify([files] [, opts])
Returns a new browserify instance.
files
String, file object, or array of those types (they may be mixed) specifying entry file(s).
I couldn't find reference anywhere of what a file object is?
I am assuming it's an object where I can pass the contents and provide a filename for the content straight away in case I want to pass files with post-processing modifications?
@zanona Yeah, it may as well not even say that without documenting what it means. I started trying to document all that kind of stuff a while back (see below), but no one cares ¯\_(ツ)_/¯. Probably some inconsistent grab bag of id, file, entry, expose, maybe even source. I wouldn't recommend relying too heavily on any of it since it is undocumented. If you mean what I think you mean by:
pass files with post-processing modifications?
You might also want to take a look at https://github.com/substack/module-deps/pull/94.
I'm just going to leave this open as a request to update the documentation.
https://github.com/jmm/browserify-pipeline-docs
https://github.com/substack/node-browserify/issues/1162
thanks @jmm that would really help, I have tried the suggestion on the PR you mentioned but apparently that wasn't implemented yet? sending a cache object to browserify where each property contains their own source?
I have been able to achieve this with the following but not sure if it was the correct approach:
var s = new require('stream').Readable(),
path = require('path').parse(process.cwd() + '/' + filePath);
s.push(fileContents);
s.push(null);
browserify(s, { basedir: path.dir }).bundle(callback);
or in case you need a named output
s.file = path.dir + '/named-file.js'
browserify(s).bundle(callback);
@zanona Yeah, you can pass a readable stream to browserify as an entry file. If it's working the way you want that may be your best bet. I don't know too much about that module-deps PR. I think the change was merged & published here: https://github.com/substack/module-deps/pull/95.
Most helpful comment
thanks @jmm that would really help, I have tried the suggestion on the PR you mentioned but apparently that wasn't implemented yet? sending a
cacheobject to browserify where each property contains their own source?I have been able to achieve this with the following but not sure if it was the correct approach:
or in case you need a named output