How to use amdclean - 10 common examples

To help you get started, we’ve selected a few amdclean examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github modjs / mod / lib / tasks / compile.js View on Github external
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);
    }
}
github ractivejs / ractive / grunt / config / requirejs.js View on Github external
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;
				});
github Rich-Harris / viewbox / grunt / config / requirejs.js View on Github external
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';
			}
		}
github burnpanck / MathJax-siunitx / Gruntfile.js View on Github external
'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);
          }
        }
github aarongloege / pointer / Gruntfile.js View on Github external
onModuleBundleComplete: function(data) {
                    fs.writeFileSync(data.path, amdclean.clean({
                        filePath: data.path,
                        prefixMode: 'camelCase'
                    }));
                }
            },
github matreshkajs / matreshka / Gruntfile.js View on Github external
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")());'
							},
						}));
					}
				}
github bignimbus / extended-javascript-console / Gruntfile.js View on Github external
'onModuleBundleComplete': function (data) {
                        var fs = require('fs'),
                        amdclean = require('amdclean'),
                        outputFile = data.path;

                        fs.writeFileSync(outputFile, amdclean.clean({
                            'filePath': outputFile
                        }));
                    }
                }
github gfranko / amdclean / Gruntfile.js View on Github external
amdclean_logic = function(data) {
      var outputFile = data.path;
      fs.writeFileSync(outputFile, amdclean.clean({
        'filePath': outputFile,
        'config': {
          moment: {
            noGlobal: true
          }
        }
      }));
    };
  grunt.initConfig({
github BootstrapJS / browser-requirejs-vanilla / Build Support / Utilities / AMDClean.js View on Github external
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
        }));
    };
};
github jaridmargolin / formatter.js / Gruntfile.js View on Github external
onBuildWrite: function(name, path, contents) {
          return require('amdclean').clean({
            code: contents,
            prefixMode: 'camelCase',
            escodegen: {
              format: {
                indent: { style: '  ' }
              }
            }
          });
        }
      }

amdclean

A build tool that converts AMD code to standard JavaScript

MIT
Latest version published 10 years ago

Package Health Score

45 / 100
Full package analysis

Popular amdclean functions