Closed lkmill closed 6 years ago
The browserify constructor accepts an option to change the "require=" prelude to any string you want.
var b = browserify({
externalRequireName = 'sup3rmansAwesomeRequire='
});
Does this work for you?
Unfortunately it does not. The externalRequireName
does not allow you to
change it to an empty string, and it always adds a "=" afterwards. So in
your example above "sup3rmansAwesomeRequire==" would be the start of every
file.
I need the external require assignment to be removed completely.
On 15 January 2015 at 04:40, Terin Stock notifications@github.com wrote:
The browserify constructor accepts an option to change the "require=" prelude to any string you want.
var b = browserify({ externalRequireName = 'sup3rmansAwesomeRequire=' });
Does this work for you?
— Reply to this email directly or view it on GitHub https://github.com/substack/factor-bundle/pull/52#issuecomment-70035700.
I guess it would work to assign to some random variable and make sure i do not use that variable name. But I don't like that solution.
On 15 January 2015 at 13:16, Linus Miller linus.miller@thecodebureau.com wrote:
Unfortunately it does not. The
externalRequireName
does not allow you to change it to an empty string, and it always adds a "=" afterwards. So in your example above "sup3rmansAwesomeRequire==" would be the start of every file.I need the external require assignment to be removed completely.
On 15 January 2015 at 04:40, Terin Stock notifications@github.com wrote:
The browserify constructor accepts an option to change the "require=" prelude to any string you want.
var b = browserify({ externalRequireName = 'sup3rmansAwesomeRequire=' });
Does this work for you?
— Reply to this email directly or view it on GitHub https://github.com/substack/factor-bundle/pull/52#issuecomment-70035700 .
@sup3rman Just curious, how exactly are you running the modules defined in the factored modules, if you don't have something that's the require function?
Edit 1: writing some tests around this, but still curious.
Hi Teri, I define a few functions in a seperate file, like follows:
(function(){
var modules = {};
var initializedModules = {};
window.require = function require(o,u){
if(!initializedModules[o]){
if(!modules[o]){
//var a=typeof require=="function"&&require;
//if(!u&&a)return a(o,!0);
//if(i)return i(o,!0);
var f=new Error("Cannot find module '"+o+"'");
throw f.code="MODULE_NOT_FOUND",f
}
var l=initializedModules[o]={exports:{}};
modules[o][0].call(l.exports,function(e){
var n=modules[o][1][e];
return require(n?n:e);
},l,l.exports);
//},l,l.exports,e,t,n,r);
}
return initializedModules[o].exports;
};
window.loadBundle = function e(t,n,r){
for(var property in t) {
if(!modules[property])
modules[property] = t[property];
}
if(!window.loadBundle.dispatch) {
for(var o=0;o<r.length;o++)
require(r[o]);
} else {
document.dispatchEvent(new CustomEvent('loaded', { detail: { run: r }}));
}
};
window.loadBundle.dispatch = false;
})();
Then i simply set the prelude on all files to loadBundle
@sup3rman I cleaned up your changes and added some tests to https://github.com/terinjokes/factor-bundle/tree/hasExports-option, can you tell me if it resolves your issues?
From the test:
var b = browserify(files, {
hasExports: false,
prelude: 'loadBundle'
});
b.plugin(factor, {
outputs: [
path.join(tmpdir, 'x.js'),
path.join(tmpdir, 'y.js')
]
});
@sup3rman ping, to see if you had a chance to test my changes.
ping haha! thats funny. sorry no had a non productive weekend and lots to do today. excited to implement said functionality in our bear bone package so will get back early in the morrows.
On 19 January 2015 at 20:38, Terin Stock notifications@github.com wrote:
@sup3rman https://github.com/sup3rman ping, to see if you had a chance to test my changes.
— Reply to this email directly or view it on GitHub https://github.com/substack/factor-bundle/pull/52#issuecomment-70548570.
ping ping it works briliantly! thanks a bunch! will this be merged into the live release?
@sup3rman Sorry, I didn't see your reply until just now. I'll merge when I get into the office in a few hours.
Sometimes I want to supply a custom prelude to all Browserify bundles, and in order for it work properly i do not want
require=
to be inserted at the start of every bundle file.