Require stream in browser

For several reasons, I have a use case for a browser where I programmatically launch it in a dynamic set of threads.

This works fine in cases like

var a, b; // objects that contain streams of javascript var brwsrfy = browserify(); brwsrfy.require(a.stream, {expose: a.name, basedir: ...}); brwsrfy.require(b.stream, {expose: b.name, basedir: ...}); brwsrfy.bundle(); 

and then I can require('a') , require('b') , etc. in the following scenarios. However, I came to the case where one of my dynamic threads wants require('a') . But at present, this is a.js error, because it is looking for the a.js file at the base, but really just need a stream a .

Is there a way to tell the browser to search for a stream for this particular request instead of searching for a file?

Edit: I have to add that I have access to the names of everything that expose 'd is, so there might be some kind of custom conversion that is specifically designed for require for these names and does ... something?

+5
source share

Source: https://habr.com/ru/post/1204765/


All Articles