How to use the convert-source-map.commentRegex.test function in convert-source-map

To help you get started, we’ve selected a few convert-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 angular / angular / packages / compiler-cli / ngcc / src / rendering / source_maps.ts View on Github external
export function extractSourceMap(
    fs: FileSystem, logger: Logger, file: ts.SourceFile): SourceMapInfo {
  const inline = commentRegex.test(file.text);
  const external = mapFileCommentRegex.exec(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 {
      const fileName = external[1] || external[2];
      const filePath = resolve(dirname(absoluteFromSourceFile(file)), fileName);
      const mappingFile = fs.readFile(filePath);
      externalSourceMap = fromJSON(mappingFile);