當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript magic-string.generateMap函數代碼示例

本文整理匯總了TypeScript中magic-string.generateMap函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript generateMap函數的具體用法?TypeScript generateMap怎麽用?TypeScript generateMap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了generateMap函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: renderSourceAndMap

  /**
   * Merge the input and output source-maps, replacing the source-map comment in the output file
   * with an appropriate source-map comment pointing to the merged source-map.
   */
  protected renderSourceAndMap(
      file: AnalyzedFile, input: SourceMapInfo, output: MagicString,
      outputPath: string): RenderResult {
    const outputMapPath = `${outputPath}.map`;
    const outputMap = output.generateMap({
      source: file.sourceFile.fileName,
      includeContent: true,
      // hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
      // the merge algorithm.
    });

    // we must set this after generation as magic string does "manipulation" on the path
    outputMap.file = outputPath;

    const mergedMap =
        mergeSourceMaps(input.map && input.map.toObject(), JSON.parse(outputMap.toString()));

    if (input.isInline) {
      return {
        file,
        source: {path: outputPath, contents: `${output.toString()}\n${mergedMap.toComment()}`},
        map: null
      };
    } else {
      return {
        file,
        source: {
          path: outputPath,
          contents: `${output.toString()}\n${generateMapFileComment(outputMapPath)}`
        },
        map: {path: outputMapPath, contents: mergedMap.toJSON()}
      };
    }
  }
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:38,代碼來源:renderer.ts

示例2: renderSourceAndMap

  /**
   * Merge the input and output source-maps, replacing the source-map comment in the output file
   * with an appropriate source-map comment pointing to the merged source-map.
   */
  protected renderSourceAndMap(
      sourceFile: ts.SourceFile, input: SourceMapInfo, output: MagicString): FileInfo[] {
    const outputPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
    const outputMapPath = `${outputPath}.map`;
    const outputMap = output.generateMap({
      source: sourceFile.fileName,
      includeContent: true,
      // hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
      // the merge algorithm.
    });

    // we must set this after generation as magic string does "manipulation" on the path
    outputMap.file = outputPath;

    const mergedMap =
        mergeSourceMaps(input.map && input.map.toObject(), JSON.parse(outputMap.toString()));

    const result: FileInfo[] = [];
    if (input.isInline) {
      result.push({path: outputPath, contents: `${output.toString()}\n${mergedMap.toComment()}`});
    } else {
      result.push({
        path: outputPath,
        contents: `${output.toString()}\n${generateMapFileComment(outputMapPath)}`
      });
      result.push({path: outputMapPath, contents: mergedMap.toJSON()});
    }
    return result;
  }
開發者ID:felixfbecker,項目名稱:angular,代碼行數:33,代碼來源:renderer.ts

示例3: MagicString

  transform: (code: string) => {
    const newContent = new MagicString(code);

    // Walks through every occurrence of a license comment and overwrites it with an empty string.
    for (let pos = -1; (pos = code.indexOf(licenseBanner, pos + 1)) !== -1; null) {
      newContent.overwrite(pos, pos + licenseBanner.length, '');
    }

    return {
      code: newContent.toString(),
      map:  newContent.generateMap({ hires: true })
    };
  }
開發者ID:Chintuz,項目名稱:material2,代碼行數:13,代碼來源:rollup-remove-licenses.ts


注:本文中的magic-string.generateMap函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。