extract sourceMappingURL comments from modules and offer it to webpack
Installations
npm install source-map-loader
Developer
webpack-contrib
Developer Guide
Module System
CommonJS
Min. Node Version
>= 18.12.0
Typescript Support
No
Node Version
18.19.0
NPM Version
10.2.3
Statistics
364 Stars
177 Commits
84 Forks
16 Watching
2 Branches
42 Contributors
Updated on 08 Nov 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
1,166,646,135
Last day
-4.4%
1,405,460
Compared to previous day
Last week
1.6%
7,358,171
Compared to previous week
Last month
8.1%
31,009,565
Compared to previous month
Last year
9.9%
350,342,793
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
1
source-map-loader
Extracts source maps from existing source files (from their sourceMappingURL
).
Getting Started
To begin, you'll need to install source-map-loader
:
1npm i -D source-map-loader
or
1yarn add -D source-map-loader
or
1pnpm add -D source-map-loader
Then add the plugin to your webpack
config. For example:
file.js
1import css from "file.css";
webpack.config.js
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.js$/, 6 enforce: "pre", 7 use: ["source-map-loader"], 8 }, 9 ], 10 }, 11};
The source-map-loader
extracts existing source maps from all JavaScript entries.
This includes both inline source maps as well as those linked via URL.
All source map data is passed to webpack for processing as per a chosen source map style specified by the devtool
option in webpack.config.js.
This loader is especially useful when using 3rd-party libraries having their own source maps.
If not extracted and processed into the source map of the webpack bundle, browsers may misinterpret source map data. source-map-loader
allows webpack to maintain source map data continuity across libraries so ease of debugging is preserved.
The source-map-loader
will extract from any JavaScript file, including those in the node_modules
directory.
Be mindful in setting include and exclude rule conditions to maximize bundling performance.
And run webpack
via your preferred method.
Options
Name | Type | Default | Description |
---|---|---|---|
filterSourceMappingUrl | {Function} | undefined | Allows to control SourceMappingURL behaviour |
filterSourceMappingUrl
Type: Function
Default: undefined
Allows you to specify the behavior of the loader for SourceMappingURL
comment.
The function must return one of the values:
true
or'consume'
- consume the source map and removeSourceMappingURL
comment (default behavior)false
or'remove'
- do not consume the source map and removeSourceMappingURL
commentskip
- do not consume the source map and do not removeSourceMappingURL
comment
Example configuration:
webpack.config.js
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.js$/, 6 enforce: "pre", 7 use: [ 8 { 9 loader: "source-map-loader", 10 options: { 11 filterSourceMappingUrl: (url, resourcePath) => { 12 if (/broker-source-map-url\.js$/i.test(url)) { 13 return false; 14 } 15 16 if (/keep-source-mapping-url\.js$/i.test(resourcePath)) { 17 return "skip"; 18 } 19 20 return true; 21 }, 22 }, 23 }, 24 ], 25 }, 26 ], 27 }, 28};
Examples
Ignoring Warnings
To ignore warnings, you can use the following configuration:
webpack.config.js
1module.exports = { 2 module: { 3 rules: [ 4 { 5 test: /\.js$/, 6 enforce: "pre", 7 use: ["source-map-loader"], 8 }, 9 ], 10 }, 11 ignoreWarnings: [/Failed to parse source map/], 12};
More information about the ignoreWarnings
option can be found here
Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.
License
No vulnerabilities found.
Reason
GitHub workflow tokens follow principle of least privilege
Details
- Info: topLevel 'contents' permission set to 'read': .github/workflows/dependency-review.yml:5
- Info: topLevel 'contents' permission set to 'read': .github/workflows/nodejs.yml:14
- Info: no jobLevel write permissions found
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
Reason
Found 22/29 approved changesets -- score normalized to 7
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/dependency-review.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependency-review.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/dependency-review.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:97: update your workflow using https://app.stepsecurity.io/secureworkflow/webpack-contrib/source-map-loader/nodejs.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:92
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 2 out of 3 npmCommand dependencies pinned
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Score
5.9
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to source-map-loader
smart-source-map-loader
A Smart Source Map Loader for Webpack
scalajs-friendly-source-map-loader
Drop in replacement for source-map-loader that understands file:// and https:// in the scala.js output source map files.
@skoging/react-app-rewire-source-map-loader
Add [source-map-loader](https://github.com/webpack-contrib/source-map-loader) to a [react-app-rewired](https://github.com/timarney/react-app-rewired) config.
react-app-rewire-source-map-loader
Add [source-map-loader](https://github.com/webpack-contrib/source-map-loader) to a [react-app-rewired](https://github.com/timarney/react-app-rewired) config.