Open jeron-diovis opened 10 years ago
Hm, interesting. Please disable flag pack
and enable optimize: true. Then send me that block of code again.
Same result. Code is not uglified now, but parameter for IIFE is still absent.
And, maybe I was a bit inattentive - not only last parameter disappears, but it is only gone from function declaration. That is, all I have is just (function () { ... }());
.
That's my source code:
(function (sandbox) {
var oldLmdRequire = lmd_require;
lmd_require = function(moduleName) {
var module = oldLmdRequire.apply(this, arguments);
if (module === undefined) throw new Error("Module '" + moduleName + "' is undefined!";);
return module;
};
for (var prop in oldLmdRequire) lmd_require[prop] = oldLmdRequire[prop];
sandbox.require = lmd_require;
}(sandbox));
Well, please replace (function (sandbox) {
with (function (sb) {
. It should help. I'll fix this issue as soon as I can.
Unfortunately, it didn't help. Even more interesting - I've tried several different names instead of "sandbox", and with "sbx" I've got following:
TypeError: Cannot call method 'toString' of undefined
at Array.make_name ( ... /node_modules/grunt-lmd/node_modules/lmd/node_modules/uglify-js/lib/process.js:1519:21)
at walk (... /node_modules/grunt-lmd/node_modules/lmd/node_modules/uglify-js/lib/process.js:223:31)
... and so on, very long stack trace ...
It's like some kind of "cumulative" effect. Because when I change parameter name to another one, or even remove some random files from project (with still "sbx" parameter name), there is no such error. It's something really complex.
So I'd rather wait for your fix.
I've created my own little plugin as described in manual. Tested it and everything worked just fine. Then I've tried to minify my build by enabling "pack" option in config - and got this:
Uncaught ReferenceError: sandbox is not defined
After some meditation on minified code I made sure that error is exactly in my plugin.
And reason is very simple: after minification
sandbox
parameter from plugin's IIFE just disappears. So plugin looks like this:It is quite unexpected. What have I to do? And why LMD built-in plugins have no such problems?