当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SourceMapGenerator.fromSourceMap方法代码示例

本文整理汇总了TypeScript中source-map.SourceMapGenerator.fromSourceMap方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SourceMapGenerator.fromSourceMap方法的具体用法?TypeScript SourceMapGenerator.fromSourceMap怎么用?TypeScript SourceMapGenerator.fromSourceMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在source-map.SourceMapGenerator的用法示例。


在下文中一共展示了SourceMapGenerator.fromSourceMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: mergeSourceMaps

export function mergeSourceMaps(
    oldMap: RawSourceMap | null, newMap: RawSourceMap): SourceMapConverter {
  if (!oldMap) {
    return fromObject(newMap);
  }
  const oldMapConsumer = new SourceMapConsumer(oldMap);
  const newMapConsumer = new SourceMapConsumer(newMap);
  const mergedMapGenerator = SourceMapGenerator.fromSourceMap(newMapConsumer);
  mergedMapGenerator.applySourceMap(oldMapConsumer);
  const merged = fromJSON(mergedMapGenerator.toString());
  return merged;
}
开发者ID:DeepanParikh,项目名称:angular,代码行数:12,代码来源:renderer.ts

示例2: combineSourceMaps

function combineSourceMaps(
    program: ts.Program, filePath: string, tscSourceMapText: string): string {
  const tscSourceMap = parseSourceMap(tscSourceMapText);
  let tscSourceMapGenerator: SourceMapGenerator|undefined;
  for (const sourceFileName of tscSourceMap.sources) {
    const sourceFile = program.getSourceFile(sourceFileName);
    if (!sourceFile || !containsInlineSourceMap(sourceFile.text)) {
      continue;
    }
    const preexistingSourceMapText = extractInlineSourceMap(sourceFile.text);
    if (!tscSourceMapGenerator) {
      tscSourceMapGenerator = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(tscSourceMap));
    }
    tscSourceMapGenerator.applySourceMap(
        new SourceMapConsumer(parseSourceMap(preexistingSourceMapText, sourceFileName)));
  }
  return tscSourceMapGenerator ? tscSourceMapGenerator.toString() : tscSourceMapText;
}
开发者ID:lucidsoftware,项目名称:tsickle,代码行数:18,代码来源:transformer.ts

示例3: buildOptimizer

export default function buildOptimizerLoader
  (this: webpack.loader.LoaderContext, content: string, previousSourceMap: RawSourceMap) {
  this.cacheable();
  const options: BuildOptimizerLoaderOptions = loaderUtils.getOptions(this) || {};

  // Make up names of the intermediate files so we can chain the sourcemaps.
  const inputFilePath = this.resourcePath + '.pre-build-optimizer.js';
  const outputFilePath = this.resourcePath + '.post-build-optimizer.js';

  const boOutput = buildOptimizer({
    content,
    originalFilePath: this.resourcePath,
    inputFilePath,
    outputFilePath,
    emitSourceMap: options.sourceMap,
    isSideEffectFree: this._module
                      && this._module.factoryMeta
                      && this._module.factoryMeta.sideEffectFree,
  });

  if (boOutput.emitSkipped || boOutput.content === null) {
    // Webpack typings for previousSourceMap are wrong, they are JSON objects and not strings.
    // tslint:disable-next-line:no-any
    this.callback(null, content, previousSourceMap as any);

    return;
  }

  const intermediateSourceMap = boOutput.sourceMap;
  let newContent = boOutput.content;

  let newSourceMap;

  if (options.sourceMap && intermediateSourceMap) {
    // Webpack doesn't need sourceMappingURL since we pass them on explicitely.
    newContent = newContent.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');

    if (previousSourceMap) {
      // If there's a previous sourcemap, we have to chain them.
      // See https://github.com/mozilla/source-map/issues/216#issuecomment-150839869 for a simple
      // source map chaining example.
      // Use http://sokra.github.io/source-map-visualization/ to validate sourcemaps make sense.

      // Force the previous sourcemap to use the filename we made up for it.
      // In order for source maps to be chained, the consumed source map `file` needs to be in the
      // consumers source map `sources` array.
      previousSourceMap.file = inputFilePath;

      // Chain the sourcemaps.
      const consumer = new SourceMapConsumer(intermediateSourceMap);
      const generator = SourceMapGenerator.fromSourceMap(consumer);
      generator.applySourceMap(new SourceMapConsumer(previousSourceMap));
      newSourceMap = generator.toJSON();
    } else {
      // Otherwise just return our generated sourcemap.
      newSourceMap = intermediateSourceMap;
    }
  }

  // Webpack typings for previousSourceMap are wrong, they are JSON objects and not strings.
  // tslint:disable-next-line:no-any
  this.callback(null, newContent, newSourceMap as any);
}
开发者ID:DevIntent,项目名称:angular-cli,代码行数:63,代码来源:webpack-loader.ts

示例4: sourceMapTextToGenerator

export function sourceMapTextToGenerator(sourceMapText: string): SourceMapGenerator {
  const sourceMapJson: any = sourceMapText;
  return SourceMapGenerator.fromSourceMap(sourceMapTextToConsumer(sourceMapJson));
}
开发者ID:Jaspreet-Lamba,项目名称:adminpanel,代码行数:4,代码来源:source_map_utils.ts

示例5: sourceMapConsumerToGenerator

export function sourceMapConsumerToGenerator(sourceMapConsumer: SourceMapConsumer):
    SourceMapGenerator {
  return SourceMapGenerator.fromSourceMap(sourceMapConsumer);
}
开发者ID:Jaspreet-Lamba,项目名称:adminpanel,代码行数:4,代码来源:source_map_utils.ts


注:本文中的source-map.SourceMapGenerator.fromSourceMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。