Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
gulp-extract-sourcemap
Advanced tools
Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map
Package | gulp-extract-sourcemap |
Description | Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map |
Node Version | >= 0.8 |
Gulp Version | 3.x |
$ npm install --save-dev gulp-extract-sourcemap
var browserify = require('gulp-browserify');
Gulp added gulp-browserify to their blacklist!
var gulp = require('gulp');
var browserify = require('browserify');
var vinylSource = require('vinyl-source-stream');
var vinylBuffer = require('vinyl-buffer');
var extractor = require('gulp-extract-sourcemap');
var uglify = require('gulp-uglifyjs');
var filter = require('gulp-filter');
var path = require('path');
gulp.task('bundle', function() {
var exchange = {
source_map: {
file: 'bundle.min.js.map',
root: '/',
orig: ''
}
};
return browserify( ['./app.js'], {
basedir: 'src/js/',
commondir: false,
insertGlobals: true
}) )
.bundle({
debug: true //it's necessary to a source map generate
})
.pipe( vinylSource( 'bundle.js' ) )
.pipe( vinylBuffer() )
.pipe( extractor({
basedir: path.join(__dirname, 'dist'),
removeSourcesContent: true
}) )
.on('postextract', function(sourceMap){
console.log(sourceMap);
exchange.source_map.orig = sourceMap;
})
.pipe( filter('**/*.js') )
.pipe( uglify( 'bundle.min.js', {
outSourceMap: true,
basePath: './dist/',
output: {
source_map: exchange.source_map // it's necessary
// to correct generate of a final source map
// of an uglified javascript bundle
}
}) )
.pipe( gulp.dest( 'dist' ) );
});
Type : String
Specifies base directory for sources paths transformation from absolute paths to relative ones. Sources in browserify generated source maps contain absolute files paths. For correct mapping in browser we need transform them to relative paths.
If option don't specified, all paths will transform relative to streemed source file cwd. If it isn't defined, paths will transform relative to process.cwd().
Type : Boolean
You set a flag, removeSourcesContent, which will remove the sourcesContent field from the extracted source map.
Type : Boolean
gulp-browserify outputs bundled JavaScript code and inline source map containt refs to fake script filename like fake_1d87bebe.js. It causes some problems with correct source maps working in browsers. Also, if we use a bundled assets checksum version control, we have a problem. Same unchanged code after bundling have other checksum. The cause for this is random 8 symbols in said fake script filename.
You set a flag, fakeFix, which will fix it. The fake script filename wil changed to streemed source file name.
Gulp added gulp-browserify to their blacklist!
Option fakeFix deprecated. Use 0.0.7 version, if You need it.
Type : String
As defult gulp-extract-sourcemap plugin cteate an external source map named as a streemed source file name with '.map' suffix. To specify different source map filename use this param.
Other than standard Node.js stream events, gulp-extract-sourcemap emits its own events.
.on('missing-map', function(){})
emitted if no map was found in the stream (the src still is piped through in this case, but no map file is piped)
Event don't emit from version 0.1.0. You can use postextract
event for the same goal. If sourceMapJson
equivalent to empty string, then
no map was found in the stream.
.on('postextract', function(sourceMapJson){})
Event triggered after the source map extracting process is over and provides the source map data json object as an argument to the callback.
It's necessary to correct generate of a final source map of an uglified javascript bundle without writing and reading intermediary files to disk.
See Usage exsample.
FAQs
Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map
The npm package gulp-extract-sourcemap receives a total of 5 weekly downloads. As such, gulp-extract-sourcemap popularity was classified as not popular.
We found that gulp-extract-sourcemap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.