How to use the combine-source-map.create function in combine-source-map

To help you get started, we’ve selected a few combine-source-map 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 stolksdorf / vitreum / node_modules / browserify / node_modules / insert-module-globals / index.js View on Github external
values.splice(3, 0,
          'arguments[3]','arguments[4]',
          'arguments[5]','arguments[6]'
      );
      wrappedSource = '(function (' + names.join(',') + '){\n'
        + src + '\n}).call(this,' + values.join(',') + ')';
    }

    // Generate source maps if wanted. Including the right offset for
    // the wrapped source.
    if (!opts.debug) {
        return wrappedSource;
    }
    var sourceFile = path.relative(opts.basedir, file)
        .replace(/\\/g, '/');
    var sourceMap = combineSourceMap.create().addFile(
        { sourceFile: sourceFile, source: src},
        { line: 1 });
    return combineSourceMap.removeComments(wrappedSource) + "\n"
        + sourceMap.comment();
}
github jamesshore / lets_code_javascript / node_modules / browserify / node_modules / insert-module-globals / index.js View on Github external
values.splice(3, 0,
          'arguments[3]','arguments[4]',
          'arguments[5]','arguments[6]'
      );
      wrappedSource = '(function (' + names.join(',') + '){\n'
        + src + '\n}).call(this,' + values.join(',') + ')';
    }

    // Generate source maps if wanted. Including the right offset for
    // the wrapped source.
    if (!opts.debug) {
        return wrappedSource;
    }
    var sourceFile = path.relative(opts.basedir, file)
        .replace(/\\/g, '/');
    var sourceMap = combineSourceMap.create().addFile(
        { sourceFile: sourceFile, source: src},
        { line: 1 });
    return combineSourceMap.removeComments(wrappedSource) + "\n"
        + sourceMap.comment();
}
github jamesshore / automatopia / node_modules / browserify / node_modules / insert-module-globals / index.js View on Github external
values.splice(3, 0,
          'arguments[3]','arguments[4]',
          'arguments[5]','arguments[6]'
      );
      wrappedSource = '(function (' + names.join(',') + '){\n'
        + src + '\n}).call(this,' + values.join(',') + ')';
    }

    // Generate source maps if wanted. Including the right offset for
    // the wrapped source.
    if (!opts.debug) {
        return wrappedSource;
    }
    var sourceFile = path.relative(opts.basedir, file)
        .replace(/\\/g, '/');
    var sourceMap = combineSourceMap.create().addFile(
        { sourceFile: sourceFile, source: src},
        { line: 1 });
    return combineSourceMap.removeComments(wrappedSource) + "\n"
        + sourceMap.comment();
}
github Jam3 / devtool / lib / require-hook.js View on Github external
].join('\n');
        hasComment = true; // now we have base64 comment
      } catch (err) {
        // Don't attempt to handle source maps for this file,
        // it is most likely a comment about source maps and not
        // a *real* source map comment!
      }
    }

    var wrapScript = moduleWrap(script);

    // do not make any more alterations to the source maps
    if (hasComment || hasMapFile) return wrapScript;

    // Otherwise, if no source maps exist, we can generate a new one
    var sourceMap = combineSourceMap.create(sourceFileName, basedir)
        .addFile({ sourceFile: sourceFile, source: original });
    return [
      combineSourceMap.removeComments(wrapScript),
      sourceMap.comment()
    ].join('\n');
  };
github Truebase-com / TruthStack / Makets / sample / example.js View on Github external
source: "function b()\n{\n\tconsole.log(\"b1\");\n\tconsole.log(\"b2\");\n\tconsole.log(\"b3\");\n}" + "\n" + bComment
	, sourceFile: "b.js"
};

var cFile = {
	source: "function c()\n{\n\tconsole.log(\"c1\");\n\tconsole.log(\"c2\");\n\tconsole.log(\"c3\");\n}" + "\n" + cComment
	, sourceFile: "c.js"
};

var dFile = {
	source: "function d()\n{\n\tconsole.log(\"d1\");\n\tconsole.log(\"d2\");\n\tconsole.log(\"d3\");\n}" + "\n" + dComment
	, sourceFile: "d.js"
};

var offset = { line: 2 };
var base64 = combine
	.create("bundle.js")
	.addFile(aFile, offset)
	.addFile(bFile, { line: offset.line + 8 })
	//.addFile(cFile, { line: offset.line + 16 })
	//.addFile(dFile, { line: offset.line + 24 })
	.base64();

console.log(base64);

//var sm = convert.fromBase64(base64).toObject();
//console.log("Combined source maps:\n", sm);
//console.log("\nMappings:\n", sm.mappings);
github browserify / browser-pack / index.js View on Github external
cache[key] = wrappedModule;
            }
            wrappedSource = sourceWrapper(first, wrappedModule, row.id, row.deps);
            sourcemap = null;
        } else if (evalSourceUrl) {
            if (row.sourceFile && !row.nomap) {
                wrappedModule = wrapEval(row.source,
                    '//# sourceURL=' + row.sourceRoot + '/' + row.sourceFile);
            } else {
                wrappedModule = wrapEval(row.source);
            }
            wrappedSource = sourceWrapper(first, wrappedModule, row.id, row.deps);
        } else {
            if (row.sourceFile && !row.nomap) {
                if (!sourcemap) {
                    sourcemap = combineSourceMap.create();
                    sourcemap.addFile(
                        { sourceFile: preludePath, source: prelude },
                        { line: 0 }
                    );
                }
                sourcemap.addFile(
                    { sourceFile: row.sourceFile, source: row.source },
                    { line: lineno }
                );
            }
            wrappedModule = wrapSimple(row.source);
            wrappedSource = sourceWrapper(first, wrappedModule, row.id, row.deps);
            lineno += newlinesIn(wrappedSource);
        }
        
        stream.push(Buffer(wrappedSource));
github browserify / browser-pack / index.js View on Github external
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 {
                if (row.sourceFile && !row.nomap) {
                    sourcemap = combineSourceMap.create();
                    sourcemap.addFile(
                        { sourceFile: row.sourceFile, source: row.source },
                        { line: 1 }
                    );
                    wrappedModule = wrapEval(row.source, sourcemap.comment());
                } else {
                    wrappedModule = wrapEval(row.source);
                }
                cache[key] = wrappedModule;
            }
            wrappedSource = sourceWrapper(first, wrappedModule, row.id, row.deps);
            sourcemap = null;
        } else if (evalSourceUrl) {
            if (row.sourceFile && !row.nomap) {
                wrappedModule = wrapEval(row.source,
                    '//# sourceURL=' + row.sourceRoot + '/' + row.sourceFile);
github goto-bus-stop / browser-pack-flat / index.js View on Github external
function flatten (rows, opts, stream) {
  rows.byId = Object.create(null)
  rows.forEach(function (row) { rows.byId[row.id] = row })

  var containsCycles = detectCycles(rows)

  var combiner = opts.debug ? combineSourceMap.create() : null

  var intro = ''
  var outro = ''

  rows.usedGlobalVariables = new Set()
  rows.exposeName = generateName(rows, 'exposedRequire')
  rows.createModuleFactoryName = generateName(rows, 'createModuleFactory')
  rows.forEach(function (row, index, rows) {
    parseModule(row, index, rows, opts)
  })
  sortModules(rows)
  rows.forEach(identifyGlobals)
  rows.forEach(markDuplicateVariableNames)
  rows.forEach(rewriteModule)
  moveOnDemandModulesToStart(rows)
github oceanofthelost / InteractiveBOM / GUI / 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 }
                );
            }
            sourcemap.addFile(
                { sourceFile: row.sourceFile, source: row.source },
                { line: lineno }
            );
        }
        
        var wrappedSource = [
            (first ? '' : ','),
            JSON.stringify(row.id),
            ':[',
            'function(require,module,exports){\n',

combine-source-map

Add source maps of multiple files, offset them and then combine them into one source map

MIT
Latest version published 7 years ago

Package Health Score

68 / 100
Full package analysis