Gathering detailed insights and metrics for karma-sourcemap-loader
Gathering detailed insights and metrics for karma-sourcemap-loader
Gathering detailed insights and metrics for karma-sourcemap-loader
Gathering detailed insights and metrics for karma-sourcemap-loader
@ampproject/remapping
Remap sequential sourcemaps through transformations to point at the original source code
adjust-sourcemap-loader
Webpack loader that adjusts source maps
karma-coverage-istanbul-reporter
A karma reporter that uses the latest istanbul 1.x APIs (with full sourcemap support) to report coverage.
karma-babel-preprocessor
Preprocessor to compile ES6 on the fly with babel.
Karma plugin that locates and loads existing javascript source map files.
npm install karma-sourcemap-loader
98.2
Supply Chain
99
Quality
75.7
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
73 Stars
66 Commits
21 Forks
4 Watching
4 Branches
12 Contributors
Updated on 05 Feb 2023
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-8.2%
65,594
Compared to previous day
Last week
4%
376,331
Compared to previous week
Last month
18.6%
1,497,406
Compared to previous month
Last year
-3.1%
15,183,944
Compared to previous year
Preprocessor that locates and loads existing source maps.
When you use karma not in isolation but as part of a build process (e.g. using grunt or gulp) it is often the case that the compilation/transpilation is done on a previous step of the process and not handled by karma preprocessors. In these cases source maps don't get loaded by karma and you lose the advantages of having them. Collecting the test code coverage using an instrumented code with source maps, for example.
Another reason may be the need for modifying relative source paths in source maps to make sure that they point to source files in the project running the tests.
This plug-in supports both inline and external source maps.
Inline source maps are located by searching "sourceMappingURL=" inside the javascript file, both plain text and base64-encoded maps are supported.
External source maps are located by appending ".map" to the javascript file name. So if for example you have Hello.js, the preprocessor will try to load source map from Hello.js.map.
Just add karma-sourcemap-loader
as a devDependency in your package.json
.
1{ 2 "devDependencies": { 3 "karma-sourcemap-loader": "~0.3" 4 } 5}
Or issue the following command:
1npm install karma-sourcemap-loader --save-dev
The code below shows a sample configuration of the preprocessor.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 } 8 }); 9};
The code below shows a configuration of the preprocessor with remapping of source file paths in source maps using path prefixes. The object remapPrefixes
contains path prefixes as keys, which if they are detected in a source path, will be replaced by the key value. After the first detected prefix gets replaced, other prefixes will be ignored..
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 remapPrefixes: { 10 '/myproject/': '../src/', 11 '/otherdep/': '../node_modules/otherdep/' 12 } 13 } 14 }); 15};
The code below shows a configuration of the preprocessor with remapping of source file paths in source maps using a callback. The function remapSource
receives an original source path and may return a changed source path. If it returns undefined
or other false-y result, the source path will not be changed.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 remapSource(source) { 10 if (source.startsWith('/myproject/')) { 11 return '../src/' + source.substring(11); 12 } 13 } 14 } 15 }); 16};
The code below shows a sample configuration of the preprocessor with changing the sourceRoot
property to a custom value, which will change the location where the debugger should locate the source files.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 useSourceRoot: '/sources' 10 } 11 }); 12};
The code below shows a sample configuration of the preprocessor with changing the sourceRoot
property using a custom function to be able to compute the value depending on the path to the bundle. The file
argument is the Karma file object { path, originalPath }
for the bundle.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 useSourceRoot(file) { 10 return '/sources'; 11 } 12 } 13 }); 14};
The code below shows a sample configuration of the preprocessor with source map loading only for files with the sourceMappingURL
set. The default behaviour is trying to load source maps for all JavaScript files, also those without the sourceMappingURL
set.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 onlyWithURL: true 10 } 11 }); 12};
The code below shows a sample configuration of the preprocessor with a strict error checking. A missing or an invalid source map will cause the test run fail.
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 plugins: ['karma-sourcemap-loader'], 5 preprocessors: { 6 '**/*.js': ['sourcemap'] 7 }, 8 sourceMapLoader: { 9 strict: true 10 } 11 }); 12};
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
14 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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 More