• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rbarilani / remove-source-map-url-webpack-plugin / 155

pending completion
155

push

travis-ci-com

web-flow
chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2

Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

10 of 10 branches covered (100.0%)

Branch coverage included in aggregate %.

28 of 28 relevant lines covered (100.0%)

6.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/plugin.js
1
const { sources, Compilation } = require("webpack");
4✔
2
const colors = require("colors/safe");
4✔
3

4
class RemoveSourceMapURLWebpackPlugin {
5
  constructor(opts) {
6
    this.options = opts || {};
12✔
7
    this.options.test = this.options.test || /\.js($|\?)/i;
12✔
8
  }
9

10
  apply(compiler) {
11
    compiler.hooks.compilation.tap("after-compile", (compilation) => {
2✔
12
      compilation.hooks.processAssets.tap(
2✔
13
        {
14
          name: "RemoveSourceMapURLWebpackPlugin",
15
          stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,
16
        },
17
        (assets) => {
18
          // process assets
19
          const count = this.processAssets(assets).reduce(
2✔
20
            (acc, { filename, source }) => {
21
              // update asset for the current compilation
22
              compilation.updateAsset(filename, source);
2✔
23
              return acc + 1;
2✔
24
            },
25
            0
26
          );
27
          console.log(
2✔
28
            colors.green(
29
              `remove-source-map-url: ${count}/${
30
                Object.keys(assets).length
31
              } asset(s) processed and updated`
32
            )
33
          );
34
        }
35
      );
36
    });
37
  }
38

39
  processAssets(assets) {
40
    return Object.keys(assets)
2✔
41
      .filter((filename) => this.testFileName(filename))
2✔
42
      .map((filename) => {
43
        const asset = assets[filename];
2✔
44
        const source = asset
2✔
45
          .source()
46
          .replace(/# sourceMappingURL=(.+?\.map)/g, "# $1");
47

48
        return {
2✔
49
          filename,
50
          source: new sources.RawSource(source),
51
        };
52
      });
53
  }
54

55
  testFileName(filename) {
56
    if (this.options.test instanceof RegExp) {
36✔
57
      return this.options.test.test(filename);
18✔
58
    }
59

60
    if (typeof this.options.test === "string") {
18✔
61
      return this.options.test === filename;
8✔
62
    }
63

64
    if (typeof this.options.test === "function") {
10✔
65
      return this.options.test(filename);
8✔
66
    }
67

68
    throw new Error(
2✔
69
      `remove-source-map-url: Invalid "test" option. May be a RegExp (tested against asset key), a string containing the key, a function(key): bool`
70
    );
71
  }
72
}
73

74
module.exports = RemoveSourceMapURLWebpackPlugin;
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc