Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.normalStripDefine = function(mainModuleName, varModules, stubModules, name, path, contents){
// Remove requirejs plugin module like requirejs-tmpl
if( stubModules && stubModules.indexOf(name) !== -1 ) return '';
try{
return require('amdclean').clean(contents);
}catch(e){
logger.error(e);
}
}
return function ( name, path, contents ) {
var relativePath, prefix, moduleNames = {};
relativePath = path.substring( path.indexOf( 'tmp/amd/' ) + 8 );
prefix = '/* ' + relativePath + ' */\n';
return prefix + require( 'amdclean' ).clean({
prefixTransform: function ( prefix ) {
var match, result, lastPart;
// special case
if ( prefix === 'utils_hasOwnProperty' ) {
return 'hasOwn';
}
prefix = prefix.replace( /(\w+)__(\w+)/, function ( match, $1, $2 ) {
if ( $1 === $2 ) {
return $1;
}
return match;
});
return '';
})
// rename them
.replace( /__dependency\d+__/g, function ( match ) {
return depMap[ match ];
})
// return default exports
.replace( '__exports__["default"] =', 'return' )
// remove __exports__
.replace( /,?"exports"\]/, ']' )
.replace( /,?\s*__exports__/, '' );
return require( 'amdclean' ).clean({
code: contents,
prefixTransform: function ( name ) {
if ( name === 'viewbox' ) {
return 'ViewBox';
}
return name
.replace( 'utils_', '' )
.replace( 'animation_', '' )
.replace( 'prototype_', 'ViewBox$' );
}
}) + '\n';
}
}
'onModuleBundleComplete': function (data) {
var fs = require('fs'),
path = require('path'),
amdclean = require('amdclean'),
outputFile = data.path;
var main = fs.readFileSync(path.join(path.dirname(outputFile),'siunitx-amd.js'),{encoding:'utf-8'});
var start_mark = /\n\s*\/\/ amd-replace-start\s*\n/m,
stop_mark = /\n\s*\/\/ amd-replace-stop\s*\n/m;
start_mark = start_mark.exec(main);
var start_pos = start_mark.index + start_mark[0].length;
stop_mark = stop_mark.exec(main);
var stop_pos = stop_mark.index; // + stop_mark[0].length;
var cleaned = amdclean.clean({
'filePath': outputFile
});
main = main.substring(0,start_pos)
+ cleaned
+ main.substring(stop_pos).replace(
/(MathJax\.Ajax\.loadComplete\("\[Contrib\]\/siunitx).*?("\);)/,
'$1/unpacked/siunitx.js$2'
);
fs.writeFileSync(outputFile, main);
}
}
onModuleBundleComplete: function(data) {
fs.writeFileSync(data.path, amdclean.clean({
filePath: data.path,
prefixMode: 'camelCase'
}));
}
},
onModuleBundleComplete: function(data) {
var fs = require('fs'),
amdclean = require('amdclean'),
outputFile = data.path;
fs.writeFileSync(outputFile, amdclean.clean({
'filePath': outputFile,
'transformAMDChecks': false,
'wrap': {
'start': ';(function(__root) {\n',
'end': '\n matreshka.version="' + pkg.version + '";\
(' + dirtyMatreshkaAMDCleanHack + ')()\
})(typeof window != "undefined" ? window : Function("return this")());'
},
}));
}
}
'onModuleBundleComplete': function (data) {
var fs = require('fs'),
amdclean = require('amdclean'),
outputFile = data.path;
fs.writeFileSync(outputFile, amdclean.clean({
'filePath': outputFile
}));
}
}
amdclean_logic = function(data) {
var outputFile = data.path;
fs.writeFileSync(outputFile, amdclean.clean({
'filePath': outputFile,
'config': {
moment: {
noGlobal: true
}
}
}));
};
grunt.initConfig({
return function (data) {
var modulePath = paths.build("requirejs", data.path);
var cleanedModulePath = paths.build("requirejs", data.name + ".cleaned.js");
var globalModules = (parameters.exportEntryPoint === true) ? [parameters.entryPoint] : [];
fs.writeFileSync(cleanedModulePath, amdclean.clean({
filePath: modulePath,
globalModules: globalModules,
transformAMDChecks: true
}));
};
};
onBuildWrite: function(name, path, contents) {
return require('amdclean').clean({
code: contents,
prefixMode: 'camelCase',
escodegen: {
format: {
indent: { style: ' ' }
}
}
});
}
}