How to use umd - 10 common examples

To help you get started, we’ve selected a few umd 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 browserify / browser-pack / index.js View on Github external
function write (row, enc, next) {

        if (first) {
            // stream.push(Buffer('console.time("scriptLoad");'));
            if (opts.standalone) {
                var pre = umd.prelude(opts.standalone).trim();
                stream.push(Buffer(pre + 'return '));
            }
            else if (stream.hasExports) {
                pre = opts.externalRequireName || 'require';
                stream.push(Buffer(pre + '='));
            }
            stream.push(Buffer(prelude + '({'));
        }

        var wrappedModule;
        var wrappedSource;
        if (evalInline) {
            var key = row.sourceFile + '::' + row.nomap + '::' + shasum(row.source);
            if (key in cache) {
                wrappedModule = cache[key];
            } else {
github goto-bus-stop / browser-pack-flat / index.js View on Github external
outro += '\n' + rows.exposeName + '.m[' + JSON.stringify(rows[i].id) + '] = ' + rows[i][kExportsName] + ';'
      }
    }

    var isEntryModule = rows[i].entry && rows[i].hasExports && opts.standalone
    // Need this for:
    // https://github.com/browserify/browserify/blob/0305b703b226878f3acb5b8f2ff9451c87cd3991/test/debug_standalone.js#L44-L64
    var isStandaloneModule = opts.standalone && rows[i].id === stream.standaloneModule
    if (isEntryModule || isStandaloneModule) {
      outro += '\nreturn ' + rows[i][kExportsName] + ';\n'
    }
  }

  if (opts.standalone) {
    intro += umd.prelude(opts.standalone)
    outro += umd.postlude(opts.standalone)
  } else if (exposesModules) {
    intro += dedent`
      require = (function (require) {
      var ${rows.exposeName} = ${exposedRequireCode};
      ${rows.exposeName}.m = {};
      ${rows.exposeName}.r = require;
    `
    outro += '\n' + dedent`
      return ${rows.exposeName};
      }(typeof require === 'function' ? require : void 0));
    `
  } else if (opts.iife || opts.iife == undefined) {
    intro += '(function(){\n'
    outro += '\n}());'
  }
github goto-bus-stop / browser-pack-flat / index.js View on Github external
} else {
        outro += '\n' + rows.exposeName + '.m[' + JSON.stringify(rows[i].id) + '] = ' + rows[i][kExportsName] + ';'
      }
    }

    var isEntryModule = rows[i].entry && rows[i].hasExports && opts.standalone
    // Need this for:
    // https://github.com/browserify/browserify/blob/0305b703b226878f3acb5b8f2ff9451c87cd3991/test/debug_standalone.js#L44-L64
    var isStandaloneModule = opts.standalone && rows[i].id === stream.standaloneModule
    if (isEntryModule || isStandaloneModule) {
      outro += '\nreturn ' + rows[i][kExportsName] + ';\n'
    }
  }

  if (opts.standalone) {
    intro += umd.prelude(opts.standalone)
    outro += umd.postlude(opts.standalone)
  } else if (exposesModules) {
    intro += dedent`
      require = (function (require) {
      var ${rows.exposeName} = ${exposedRequireCode};
      ${rows.exposeName}.m = {};
      ${rows.exposeName}.r = require;
    `
    outro += '\n' + dedent`
      return ${rows.exposeName};
      }(typeof require === 'function' ? require : void 0));
    `
  } else if (opts.iife || opts.iife == undefined) {
    intro += '(function(){\n'
    outro += '\n}());'
  }
github jamesshore / automatopia / node_modules / browserify / node_modules / browser-pack / index.js View on Github external
function end () {
        if (first) stream.push(Buffer(prelude + '({'));
        entries = entries.filter(function (x) { return x !== undefined });
        
        stream.push(Buffer('},{},' + JSON.stringify(entries) + ')'));

        if (opts.standalone && !first) {
            stream.push(Buffer(
                '(' + JSON.stringify(stream.standaloneModule) + ')'
                + umd.postlude(opts.standalone)
            ));
        }
        
        if (sourcemap) {
            var comment = sourcemap.comment();
            if (opts.sourceMapPrefix) {
                comment = comment.replace(
                    /^\/\/#/, function () { return opts.sourceMapPrefix }
                )
            }
            stream.push(Buffer('\n' + comment + '\n'));
        }
        if (!sourcemap && !opts.standalone) stream.push(Buffer(';\n'));

        stream.push(null);
    }
github centrifugal / web / node_modules / browser-pack / index.js View on Github external
function end () {
        if (first) stream.push(Buffer(prelude + '({'));
        entries = entries.filter(function (x) { return x !== undefined });
        
        stream.push(Buffer('},{},' + JSON.stringify(entries) + ')'));
        
        if (opts.standalone) {
            stream.push(Buffer(
                '(' + JSON.stringify(stream.standaloneModule) + ')'
                + umd.postlude(opts.standalone)
            ));
        }
        
        if (sourcemap) {
            var comment = sourcemap.comment();
            if (opts.sourceMapPrefix) {
                comment = comment.replace(
                    /^\/\/#/, function () { return opts.sourceMapPrefix }
                )
            }
            stream.push(Buffer('\n' + comment + '\n'));
        }
        if (!sourcemap && !opts.standalone) stream.push(Buffer(';\n'));

        stream.push(null);
    }
github jondubois / nombo / node_modules / browserify / index.js View on Github external
function end () {
        if (first) writePrelude.call(this);
        if (standalone) {
            this.queue('\n(' + mainModule + ')' + umd.postlude(standalone));
        }
        this.queue('\n;');
        this.queue(null);
    }
github Woodhouse / core / interfaces / hangouts / node_modules / hangouts-bot / node_modules / node-xmpp / node_modules / browserify / index.js View on Github external
function end () {
        if (first) writePrelude.call(this);
        if (opts.standalone) {
            this.queue(
                '\n(' + mainModule + ')'
                + umd.postlude(opts.standalone)
            );
        }
        if (opts.debug) this.queue('\n');
        this.queue(null);
    }
github ninabreznik / voting-ethereum-contract / node_modules / browser-pack / index.js View on Github external
function end () {
        if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));
        entries = entries.filter(function (x) { return x !== undefined });
        
        stream.push(
            Buffer.from('},{},' + JSON.stringify(entries) + ')', 'utf8')
        );

        if (opts.standalone && !first) {
            stream.push(Buffer.from(
                '(' + JSON.stringify(stream.standaloneModule) + ')'
                    + umd.postlude(opts.standalone),
                'utf8'
            ));
        }
        
        if (sourcemap) {
            var comment = sourcemap.comment();
            if (opts.sourceMapPrefix) {
                comment = comment.replace(
                    /^\/\/#/, function () { return opts.sourceMapPrefix }
                )
            }
            stream.push(Buffer.from('\n' + comment + '\n', 'utf8'));
        }
        if (!sourcemap && !opts.standalone) {
            stream.push(Buffer.from(';\n', 'utf8'));
        }
github ShieldBattery / ShieldBattery / node_modules / browserify-middleware / node_modules / browserify / index.js View on Github external
function end () {
        if (first) writePrelude.call(this);
        if (standalone) {
            this.queue('\n(' + mainModule + ')' + umd.postlude(standalone));
        }
        this.queue('\n;');
        this.queue(null);
    }
github oceanofthelost / InteractiveBOM / GUI / node_modules / browser-pack / index.js View on Github external
function end () {
        if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));
        entries = entries.filter(function (x) { return x !== undefined });
        
        stream.push(
            Buffer.from('},{},' + JSON.stringify(entries) + ')', 'utf8')
        );

        if (opts.standalone && !first) {
            stream.push(Buffer.from(
                '(' + JSON.stringify(stream.standaloneModule) + ')'
                    + umd.postlude(opts.standalone),
                'utf8'
            ));
        }
        
        if (sourcemap) {
            var comment = sourcemap.comment();
            if (opts.sourceMapPrefix) {
                comment = comment.replace(
                    /^\/\/#/, function () { return opts.sourceMapPrefix }
                )
            }
            stream.push(Buffer.from('\n' + comment + '\n', 'utf8'));
        }
        if (!sourcemap && !opts.standalone) {
            stream.push(Buffer.from(';\n', 'utf8'));
        }

umd

Universal Module Definition for use in automated build systems

MIT
Latest version published 6 years ago

Package Health Score

71 / 100
Full package analysis

Popular umd functions