Home / Class/ SourceMapIgnoreListPlugin Class — react Architecture

SourceMapIgnoreListPlugin Class — react Architecture

Architecture documentation for the SourceMapIgnoreListPlugin class in SourceMapIgnoreListPlugin.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5798d5bb_5b75_eb9c_face_62a0b4c1f4d0["SourceMapIgnoreListPlugin"]
  5df5c678_11b8_b843_b01f_069fd704f4b2["SourceMapIgnoreListPlugin.js"]
  5798d5bb_5b75_eb9c_face_62a0b4c1f4d0 -->|defined in| 5df5c678_11b8_b843_b01f_069fd704f4b2
  49e4d461_db9f_d1c6_2b0c_7a5e60c5e360["constructor()"]
  5798d5bb_5b75_eb9c_face_62a0b4c1f4d0 -->|method| 49e4d461_db9f_d1c6_2b0c_7a5e60c5e360
  829aac69_785b_fc8f_eca9_12a410ab771d["apply()"]
  5798d5bb_5b75_eb9c_face_62a0b4c1f4d0 -->|method| 829aac69_785b_fc8f_eca9_12a410ab771d

Relationship Graph

Source Code

packages/react-devtools-shared/SourceMapIgnoreListPlugin.js lines 21–71

class SourceMapIgnoreListPlugin {
  constructor({shouldIgnoreSource}) {
    this.shouldIgnoreSource = shouldIgnoreSource;
  }

  apply(compiler) {
    const {RawSource} = compiler.webpack.sources;

    compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
      compilation.hooks.processAssets.tap(
        {
          name: PLUGIN_NAME,
          stage: Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
          additionalAssets: true,
        },
        assets => {
          // eslint-disable-next-line no-for-of-loops/no-for-of-loops
          for (const [name, asset] of Object.entries(assets)) {
            if (!name.endsWith('.map')) {
              continue;
            }

            const mapContent = asset.source().toString();
            if (!mapContent) {
              continue;
            }

            const map = JSON.parse(mapContent);
            const ignoreList = [];

            const sourcesCount = map.sources.length;
            for (
              let potentialSourceIndex = 0;
              potentialSourceIndex < sourcesCount;
              ++potentialSourceIndex
            ) {
              const source = map.sources[potentialSourceIndex];

              if (this.shouldIgnoreSource(name, source)) {
                ignoreList.push(potentialSourceIndex);
              }
            }

            map[IGNORE_LIST] = ignoreList;
            compilation.updateAsset(name, new RawSource(JSON.stringify(map)));
          }
        },
      );
    });
  }
}

Frequently Asked Questions

What is the SourceMapIgnoreListPlugin class?
SourceMapIgnoreListPlugin is a class in the react codebase, defined in packages/react-devtools-shared/SourceMapIgnoreListPlugin.js.
Where is SourceMapIgnoreListPlugin defined?
SourceMapIgnoreListPlugin is defined in packages/react-devtools-shared/SourceMapIgnoreListPlugin.js at line 21.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free