Home / Function/ apply() — react Function Reference

apply() — react Function Reference

Architecture documentation for the apply() function in SourceMapIgnoreListPlugin.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  829aac69_785b_fc8f_eca9_12a410ab771d["apply()"]
  5798d5bb_5b75_eb9c_face_62a0b4c1f4d0["SourceMapIgnoreListPlugin"]
  829aac69_785b_fc8f_eca9_12a410ab771d -->|defined in| 5798d5bb_5b75_eb9c_face_62a0b4c1f4d0
  style 829aac69_785b_fc8f_eca9_12a410ab771d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/SourceMapIgnoreListPlugin.js lines 26–70

  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)));
          }
        },
      );
    });
  }

Domain

Subdomains

Frequently Asked Questions

What does apply() do?
apply() is a function in the react codebase, defined in packages/react-devtools-shared/SourceMapIgnoreListPlugin.js.
Where is apply() defined?
apply() is defined in packages/react-devtools-shared/SourceMapIgnoreListPlugin.js at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free