Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-extract-sourcemap

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-extract-sourcemap - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

15

index.js

@@ -48,3 +48,2 @@ var through = require('through2');

}
if (sMap && sMap.sources) {

@@ -54,12 +53,3 @@ var basedir = opts.basedir || file.cwd || process.cwd();

for (var i = sMap.sources.length; i--;) {
var newSource = path.relative( basedir, sMap.sources[i] );
if (opts.fakeFix && /\/fake_[0-9a-f]{8}\.js$/.test(newSource)) {
var fNameRX = new RegExp( path.basename(newSource).replace(/[\-\[\]\{\}\(\)\*\+\?\.\^\$\|]/g, "\\$&"), 'g' );
src = src.replace(fNameRX, path.basename(file.path));
newSource = newSource.replace(fNameRX, path.basename(file.path));
}
sMap.sources[i] = newSource;
sMap.sources[i] = path.relative( basedir, sMap.sources[i] );
}

@@ -83,5 +73,2 @@ }

this.push(file);
if (!sMap) {
this.emit('missing-map');
}
this.emit('postextract', sMap);

@@ -88,0 +75,0 @@ cb();

2

package.json
{
"name": "gulp-extract-sourcemap",
"version": "0.0.7",
"version": "0.1.0",
"description": "Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,4 +8,23 @@ [![Build Status](https://travis-ci.org/shonny-ua/gulp-extract-sourcemap.svg)](https://travis-ci.org/shonny-ua/gulp-extract-sourcemap)

> Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map
[![NPM](https://nodei.co/npm/gulp-extract-sourcemap.png?downloads=true&stars=true)](https://nodei.co/npm/gulp-extract-sourcemap/)
<table>
<tr>
<td>Package</td><td>gulp-extract-sourcemap</td>
</tr>
<tr>
<td>Description</td>
<td>Gulp Task to strips an inline source into its own file and updates the original file to reference the new external source map</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.8</td>
</tr>
<tr>
<td>Gulp Version</td>
<td>3.x</td>
</tr>
</table>
## Install

@@ -19,24 +38,51 @@

~~var browserify = require('gulp-browserify');~~
Gulp added [~~gulp-browserify~~](https://github.com/deepak1556/gulp-browserify) to their [blacklist](https://github.com/gulpjs/plugins/issues/47)!
```js
var gulp = require('gulp');
var browserify = require('gulp-browserify');
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() {
return gulp.src( ['src/js/app.js'])
.pipe( browserify({
var exchange = {
source_map: {
file: 'bundle.min.js.map',
root: '/',
orig: ''
}
};
return browserify( ['./app.js'], {
basedir: 'src/js/',
commondir: false,
insertGlobals: true,
debug: true
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,
fakeFix: true
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' ) );

@@ -62,10 +108,13 @@ });

#### fakeFix
#### ~~fakeFix~~
Type : `Boolean`
~~Type : `Boolean`~~
[gulp-browserify](https://github.com/deepak1556/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.
[~~gulp-browserify~~](https://github.com/deepak1556/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.
~~You set a flag, fakeFix, which will fix it. The fake script filename wil changed to streemed source file name.~~
Gulp added [~~gulp-browserify~~](https://github.com/deepak1556/gulp-browserify) to their [blacklist](https://github.com/gulpjs/plugins/issues/47)!
Option fakeFix deprecated. Use 0.0.7 version, if You need it.
#### sourceMappingFileName

@@ -81,3 +130,3 @@

#### missing-map
#### ~~missing-map~~

@@ -87,3 +136,5 @@ ```javascript

```
emitted if no map was found in the stream (the src still is piped through in this case, but no map file is piped)
~~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.

@@ -98,10 +149,15 @@ #### postextract

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](#usage) exsample.
### Works with gulp-extract-sourcemap
- [gulp-browserify](https://github.com/deepak1556/gulp-browserify)
- [gulp-rev](https://github.com/sindresorhus/gulp-rev)
- [browserify](https://github.com/substack/node-browserify)
- [vinyl-source-stream](https://github.com/hughsk/vinyl-source-stream)
- [gulp-uglifyjs](https://github.com/craigjennings11/gulp-uglifyjs)
## License
[MIT](http://opensource.org/licenses/MIT) © [Oleksandr Ovcharenko](mailto:shonny.ua@gmail.com)
[MIT](http://opensource.org/licenses/MIT) © [Oleksandr Ovcharenko](mailto:shonny.ua@gmail.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc