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


TypeScript convert-source-map.removeComments函数代码示例

本文整理汇总了TypeScript中convert-source-map.removeComments函数的典型用法代码示例。如果您正苦于以下问题:TypeScript removeComments函数的具体用法?TypeScript removeComments怎么用?TypeScript removeComments使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: extractSourceMap

  /**
   * Get the map from the source (note whether it is inline or external)
   */
  protected extractSourceMap(file: ts.SourceFile): SourceMapInfo {
    const inline = commentRegex.test(file.text);
    const external = mapFileCommentRegex.test(file.text);

    if (inline) {
      const inlineSourceMap = fromSource(file.text);
      return {
        source: removeComments(file.text).replace(/\n\n$/, '\n'),
        map: inlineSourceMap,
        isInline: true,
      };
    } else if (external) {
      let externalSourceMap: SourceMapConverter|null = null;
      try {
        externalSourceMap = fromMapFileSource(file.text, dirname(file.fileName));
      } catch (e) {
        console.warn(e);
      }
      return {
        source: removeMapFileComments(file.text).replace(/\n\n$/, '\n'),
        map: externalSourceMap,
        isInline: false,
      };
    } else {
      return {source: file.text, map: null, isInline: false};
    }
  }
开发者ID:hulkike,项目名称:angular,代码行数:30,代码来源:renderer.ts

示例2: file

          .then( () => {
            /*
             Angular compiler with 'flatModuleOutFile' turned on creates an entry JS file with a matching d.ts
             file and an aggregated metadata.json file.

             This is done by creating a corresponding TS file (to the output JS file).
             The side-effect is a source map reference to the TS file.

             Since the TS is virtual and does not exists we need to remove the comment so the source maps
             will not break.
             */
            const flatModuleJsPath = Path.join(copyInst.toSrc, `${util.getMainOutputFileName(util.currentPackage())}.js`);
            const withoutComments = convert.removeComments(fs.readFileSync(flatModuleJsPath, 'utf-8'));
            fs.writeFileSync(flatModuleJsPath, withoutComments, 'utf-8');
          });
开发者ID:shlomiassaf,项目名称:ng2-chess,代码行数:15,代码来源:build.ts

示例3: extractSourceMap

  /**
   * Get the map from the source (note whether it is inline or external)
   */
  protected extractSourceMap(file: ts.SourceFile): SourceMapInfo {
    const inline = commentRegex.test(file.text);
    const external = mapFileCommentRegex.test(file.text);

    if (inline) {
      const inlineSourceMap = fromSource(file.text);
      return {
        source: removeComments(file.text).replace(/\n\n$/, '\n'),
        map: inlineSourceMap,
        isInline: true,
      };
    } else if (external) {
      let externalSourceMap: SourceMapConverter|null = null;
      try {
        externalSourceMap = fromMapFileSource(file.text, dirname(file.fileName));
      } catch (e) {
        if (e.code === 'ENOENT') {
          console.warn(
              `The external map file specified in the source code comment "${e.path}" was not found on the file system.`);
          const mapPath = file.fileName + '.map';
          if (basename(e.path) !== basename(mapPath) && statSync(mapPath).isFile()) {
            console.warn(
                `Guessing the map file name from the source file name: "${basename(mapPath)}"`);
            try {
              externalSourceMap = fromObject(JSON.parse(readFileSync(mapPath, 'utf8')));
            } catch (e) {
              console.error(e);
            }
          }
        }
      }
      return {
        source: removeMapFileComments(file.text).replace(/\n\n$/, '\n'),
        map: externalSourceMap,
        isInline: false,
      };
    } else {
      return {source: file.text, map: null, isInline: false};
    }
  }
开发者ID:DeepanParikh,项目名称:angular,代码行数:43,代码来源:renderer.ts


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