Despite many relative questions, they do not answer how to solve the following problem.
I have a nodejs index.js file.
var browserify = require('browserify'); var data = getSomeData(); browserify('entry.js').bundle();
I want data be available in entry.js . I found the browser option insertGlobalVars , but I could not find any suitable documentation or examples. I tried {insertGlobalVars: {myVar: someData}} but it does not work.
I could not call require('someData') because my data is only created when index.js executed.
Update : Data is an array; key is the name of the file, value is the contents of the file (size about 500b).
source share