How to use the umd.prelude function in umd

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
} 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 / lets_code_javascript / node_modules / browser-pack / index.js View on Github external
function write (row, enc, next) {
        if (first && opts.standalone) {
            var pre = umd.prelude(opts.standalone).trim();
            stream.push(new Buffer(pre + 'return '));
        }
        else if (first && stream.hasExports) {
            var pre = opts.externalRequireName || 'require';
            stream.push(new Buffer(pre + '='));
        }
        if (first) stream.push(new Buffer(prelude + '({'));
        
        if (row.sourceFile && !row.nomap) {
            if (!sourcemap) {
                sourcemap = combineSourceMap.create();
                sourcemap.addFile(
                    { sourceFile: preludePath, source: prelude },
                    { line: 0 }
                );
            }
github jamesshore / automatopia / node_modules / browserify / node_modules / browser-pack / index.js View on Github external
function write (row, enc, next) {
        if (first && opts.standalone) {
            var pre = umd.prelude(opts.standalone).trim();
            stream.push(Buffer(pre + 'return '));
        }
        else if (first && stream.hasExports) {
            var pre = opts.externalRequireName || 'require';
            stream.push(Buffer(pre + '='));
        }
        if (first) stream.push(Buffer(prelude + '({'));
        
        if (row.sourceFile && !row.nomap) {
            if (!sourcemap) {
                sourcemap = combineSourceMap.create();
                sourcemap.addFile(
                    { sourceFile: preludePath, source: prelude },
                    { line: 0 }
                );
            }
github LavaMoat / lavamoat-browserify / src / createCustomPack.js View on Github external
function write (row, enc, next) {
        if (first && opts.standalone) {
            var pre = umd.prelude(opts.standalone).trim();
            stream.push(Buffer.from(pre + 'return ', 'utf8'));
        }
        else if (first && stream.hasExports) {
            var pre = opts.externalRequireName || 'require';
            stream.push(Buffer.from(pre + '=', 'utf8'));
        }
        if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));

        if (row.sourceFile && !row.nomap) {
            if (!sourcemap) {
                sourcemap = combineSourceMap.create(null, opts.sourceRoot);
                sourcemap.addFile(
                    { sourceFile: preludePath, source: prelude },
                    { line: 0 }
                );
            }
github ShieldBattery / ShieldBattery / node_modules / browserify-middleware / node_modules / browserify / index.js View on Github external
function writePrelude () {
        if (!first) return;
        if (standalone) {
            return this.queue(umd.prelude(standalone) + 'return ');
        }
        if (!hasExports) return this.queue(';');
        this.queue('require=');
    }
github myter / Spiders.js / node_modules / browser-pack / index.js View on Github external
function write (row, enc, next) {
        if (first && opts.standalone) {
            var pre = umd.prelude(opts.standalone).trim();
            stream.push(Buffer.from(pre + 'return ', 'utf8'));
        }
        else if (first && stream.hasExports) {
            var pre = opts.externalRequireName || 'require';
            stream.push(Buffer.from(pre + '=', 'utf8'));
        }
        if (first) stream.push(Buffer.from(prelude + '({', 'utf8'));
        
        if (row.sourceFile && !row.nomap) {
            if (!sourcemap) {
                sourcemap = combineSourceMap.create(null, opts.sourceRoot);
                sourcemap.addFile(
                    { sourceFile: preludePath, source: prelude },
                    { line: 0 }
                );
            }
github w3c / midgard / node_modules / browserify / node_modules / browser-pack / index.js View on Github external
function write (row, enc, next) {
        if (first && opts.standalone) {
            var pre = umd.prelude(opts.standalone).trim();
            stream.push(Buffer(pre + 'return '));
        }
        else if (first && stream.hasExports) {
            var pre = opts.externalRequireName || 'require';
            stream.push(Buffer(pre + '='));
        }
        if (first) stream.push(Buffer(prelude + '({'));
        
        if (row.sourceFile && !row.nomap) {
            if (!sourcemap) {
                sourcemap = combineSourceMap.create();
                sourcemap.addFile(
                    { sourceFile: preludePath, source: prelude },
                    { line: 0 }
                );
            }
github kyledrake / coinpunk / node_modules / browserify / index.js View on Github external
function writePrelude () {
        if (!first) return;
        if (opts.standalone) {
            return this.queue(umd.prelude(opts.standalone).trim() + 'return ');
        }
        if (hasExports) this.queue(
            (opts.externalRequireName || 'require') + '='
        );
    }

umd

Universal Module Definition for use in automated build systems

MIT
Latest version published 7 years ago

Package Health Score

74 / 100
Full package analysis

Popular umd functions