How to use @ampproject/remapping - 1 common examples

To help you get started, we’ve selected a few @ampproject/remapping 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 ggoodman / velcro / packages / bundler / src / bundle.ts View on Github external
private generateSourceMap(bundle: MagicStringBundle | MagicString, href: string) {
    const inputMap = bundle.generateMap({
      includeContent: true,
      hires: false,
      source: href,
    });

    // In case a source map seems to be self-referential, avoid crashing
    const seen = new Set();

    return new SourceMap(
      remapping(
        inputMap.toString(),
        (uri: string) => {
          const asset = this.assetsByHref.get(uri);

          if (asset && asset.sourceMappingUrl) {
            if (seen.has(asset)) {
              return null;
            }

            seen.add(asset);

            const match = asset.sourceMappingUrl.match(/^data:application\/json;(?:charset=([^;]+);)?base64,(.*)$/);

            if (match) {
              if (match[1] && match[1] !== 'utf-8') {
                return null;

@ampproject/remapping

Remap sequential sourcemaps through transformations to point at the original source code

Apache-2.0
Latest version published 10 months ago

Package Health Score

83 / 100
Full package analysis

Popular @ampproject/remapping functions