Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var optimizeModules = function(index, callback) {
if (index >= currentModules.length) {
return callback(null, results);
}
config.name = currentModules[index];
// console.log(config.name + ' is optimizing...');
requirejs.optimize(config, function (buildResponse) {
results += currentContent;
return optimizeModules(index + 1, callback);
}, function(err) {
callback(err)
});
}
// This only builds the sources for the example amd.html
// all other examples do not need to be built.
var requirejs = require('requirejs');
var config = {
baseUrl: '.',
optimize: 'uglify2',
mainConfigFile: 'Source/mainConfig.js',
name: "Source/amd/main",
out: "Build/amd.min.js",
logLevel: 0
};
requirejs.optimize(config);
} catch (e) {
grunt.fail.warn('There was an error while processing your done function: "' + e + '"');
}
};
// The following catches errors in the user-defined `error` function and passes them.
// if the error function options is not set, this value should be undefined
var tryCatchError = function(fn, done, err) {
try {
fn(done, err);
} catch (e) {
grunt.fail.fatal('There was an error while processing your error function: "' + e + '"');
}
};
requirejs.optimize(
options,
tryCatchDone.bind(null, options.done, done),
options.error ? tryCatchError.bind(null, options.error, done):undefined
);
});
};
gulp.task('requirejs', function(done) {
var config = JSON.parse(Buffer.from(process.argv[3].substring(2), 'base64').toString('utf8'));
// Disable module load timeout
config.waitSeconds = 0;
requirejs.optimize(config, function() {
done();
}, done);
});
function builder( config ) {
// config.out = outputConsole;
requirejs.optimize(config, buildResponse, buildError);
}
return new Promise(function(win, lose) {
requirejs.optimize(conf, function (buildResponse) {
noisyLog(buildResponse);
console.timeEnd("buildJS");
win();
}, function(err) {
console.error(err);
lose(err);
});
});
}
if ( file.isNull() ) {
return cb( null, file );
}
options.logLevel = 2;
options.out = function( text ) {
var outFile = new gutil.File({
path: file.relative,
contents: new Buffer( text )
});
cb( null, outFile );
};
gutil.log('RequireJS optimizing');
requirejs.optimize( options, null, function( err ) {
var gulpError = new gutil.PluginError( 'requirejsOptimize', err.message );
stream.emit( 'error', gulpError );
});
});
function build(config) {
requirejs.optimize(
config,
console.log.bind(console),
console.error.bind(console)
);
}
grunt.registerTask("compile-toolkit-js", "Build", function () {
var done = this.async();
requirejs.optimize(config, function (response) {
grunt.log.writelns(response);
done();
}, function (err) {
done(err);
});
});
function unbundle(name, done) {
var config = {
name: name + '-manifest',
out: name + '.js',
rawText: {},
optimize: 'none'
};
config.rawText[name + '-manifest'] = 'define([], function() {});';
Object.assign(config, configBase);
rjs.optimize(config, () => done());
}