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

rollup-plugin-sourcemaps

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-sourcemaps - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

88

dist/rollup-plugin-sourcemaps.esm.js

@@ -5,3 +5,3 @@ import _regeneratorRuntime from 'babel-runtime/regenerator';

import { createFilter } from 'rollup-pluginutils';
import * as path from 'path';
import { dirname, resolve } from 'path';
import { readFile } from 'fs';

@@ -34,3 +34,3 @@ import _Promise from 'babel-runtime/core-js/promise';

var regex2 = new RegExp('//' + baseRegex + '($|\n|\r\n?)'); // Matches // .... comments
var regexDataUrl = /data:[^;\n]+;base64,(.*)/; // Matches DataUrls
var regexDataUrl = /data:(.*?)(?:;charset=(.*?))?(?:;(base64))?,(.+)/i; // Matches data urls

@@ -50,3 +50,3 @@ function sourceMapsPlugin() {

return _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var code, match, _match, sourceMapComment, sourceMapURL, dataUrlMatch, context, rawMap, fileName, map;
var code, match, _match, sourceMapComment, sourceMapURL, dataUrlMatch, rawMap, _dataUrlMatch, dataUrl, mimeType, _dataUrlMatch$, charset, _dataUrlMatch$2, encoding, data, sourceMapPath, map;

@@ -81,4 +81,8 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

case 12:
// Check for source map comments
match = regex1.exec(code) || regex2.exec(code);
// No source map detected, return code
if (!(match === null)) {

@@ -95,4 +99,2 @@ _context.next = 15;

sourceMapURL = _match[1];
dataUrlMatch = regexDataUrl.exec(sourceMapURL);
context = path.dirname(id);

@@ -103,50 +105,76 @@ // Remove the source map comment, and make sure we don't return an empty string

// Check if the source map is inlined, i.e. it uses a data url
dataUrlMatch = regexDataUrl.exec(sourceMapURL);
rawMap = void 0;
if (!dataUrlMatch) {
_context.next = 26;
if (!(dataUrlMatch !== null)) {
_context.next = 40;
break;
}
rawMap = new Buffer(dataUrlMatch[1], 'base64').toString();
_context.next = 37;
/* eslint-disable no-unused-vars */
_dataUrlMatch = _slicedToArray(dataUrlMatch, 5);
dataUrl = _dataUrlMatch[0];
mimeType = _dataUrlMatch[1];
_dataUrlMatch$ = _dataUrlMatch[2];
charset = _dataUrlMatch$ === undefined ? 'utf8' : _dataUrlMatch$;
_dataUrlMatch$2 = _dataUrlMatch[3];
encoding = _dataUrlMatch$2 === undefined ? 'base64' : _dataUrlMatch$2;
data = _dataUrlMatch[4];
/* eslint-enable */
_context.prev = 30;
rawMap = new Buffer(data, encoding).toString(charset);
_context.next = 38;
break;
case 26:
fileName = path.resolve(context, sourceMapURL);
_context.prev = 27;
_context.next = 30;
return readFileAsync(fileName, 'utf8');
case 34:
_context.prev = 34;
_context.t1 = _context['catch'](30);
case 30:
console.error('rollup-plugin-sourcemaps: Failed parsing data url: ' + _context.t1);
return _context.abrupt('return', code);
case 38:
_context.next = 51;
break;
case 40:
sourceMapPath = resolve(dirname(id), sourceMapURL);
_context.prev = 41;
_context.next = 44;
return readFileAsync(sourceMapPath, 'utf8');
case 44:
rawMap = _context.sent;
_context.next = 37;
_context.next = 51;
break;
case 33:
_context.prev = 33;
_context.t1 = _context['catch'](27);
case 47:
_context.prev = 47;
_context.t2 = _context['catch'](41);
console.error('rollup-plugin-sourcemaps: Could not open source map: ' + _context.t1);
console.error('rollup-plugin-sourcemaps: Could not open source map: ' + _context.t2);
return _context.abrupt('return', code);
case 37:
case 51:
map = void 0;
_context.prev = 38;
_context.prev = 52;
map = JSON.parse(rawMap);
_context.next = 46;
_context.next = 60;
break;
case 42:
_context.prev = 42;
_context.t2 = _context['catch'](38);
case 56:
_context.prev = 56;
_context.t3 = _context['catch'](52);
console.error('rollup-plugin-sourcemaps: Failed parsing raw source map from ' + id + ': ' + _context.t2);
console.error('rollup-plugin-sourcemaps: Failed parsing raw source map from ' + id + ': ' + _context.t3);
return _context.abrupt('return', code);
case 46:
case 60:
return _context.abrupt('return', { code: code, map: map });
case 47:
case 61:
case 'end':

@@ -156,3 +184,3 @@ return _context.stop();

}
}, _callee, _this, [[3, 9], [27, 33], [38, 42]]);
}, _callee, _this, [[3, 9], [30, 34], [41, 47], [52, 56]]);
}))();

@@ -159,0 +187,0 @@ }

@@ -37,3 +37,3 @@ 'use strict';

var regex2 = new RegExp('//' + baseRegex + '($|\n|\r\n?)'); // Matches // .... comments
var regexDataUrl = /data:[^;\n]+;base64,(.*)/; // Matches DataUrls
var regexDataUrl = /data:(.*?)(?:;charset=(.*?))?(?:;(base64))?,(.+)/i; // Matches data urls

@@ -53,3 +53,3 @@ function sourceMapsPlugin() {

return _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var code, match, _match, sourceMapComment, sourceMapURL, dataUrlMatch, context, rawMap, fileName, map;
var code, match, _match, sourceMapComment, sourceMapURL, dataUrlMatch, rawMap, _dataUrlMatch, dataUrl, mimeType, _dataUrlMatch$, charset, _dataUrlMatch$2, encoding, data, sourceMapPath, map;

@@ -84,4 +84,8 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

case 12:
// Check for source map comments
match = regex1.exec(code) || regex2.exec(code);
// No source map detected, return code
if (!(match === null)) {

@@ -98,4 +102,2 @@ _context.next = 15;

sourceMapURL = _match[1];
dataUrlMatch = regexDataUrl.exec(sourceMapURL);
context = path.dirname(id);

@@ -106,50 +108,76 @@ // Remove the source map comment, and make sure we don't return an empty string

// Check if the source map is inlined, i.e. it uses a data url
dataUrlMatch = regexDataUrl.exec(sourceMapURL);
rawMap = void 0;
if (!dataUrlMatch) {
_context.next = 26;
if (!(dataUrlMatch !== null)) {
_context.next = 40;
break;
}
rawMap = new Buffer(dataUrlMatch[1], 'base64').toString();
_context.next = 37;
/* eslint-disable no-unused-vars */
_dataUrlMatch = _slicedToArray(dataUrlMatch, 5);
dataUrl = _dataUrlMatch[0];
mimeType = _dataUrlMatch[1];
_dataUrlMatch$ = _dataUrlMatch[2];
charset = _dataUrlMatch$ === undefined ? 'utf8' : _dataUrlMatch$;
_dataUrlMatch$2 = _dataUrlMatch[3];
encoding = _dataUrlMatch$2 === undefined ? 'base64' : _dataUrlMatch$2;
data = _dataUrlMatch[4];
/* eslint-enable */
_context.prev = 30;
rawMap = new Buffer(data, encoding).toString(charset);
_context.next = 38;
break;
case 26:
fileName = path.resolve(context, sourceMapURL);
_context.prev = 27;
_context.next = 30;
return readFileAsync(fileName, 'utf8');
case 34:
_context.prev = 34;
_context.t1 = _context['catch'](30);
case 30:
console.error('rollup-plugin-sourcemaps: Failed parsing data url: ' + _context.t1);
return _context.abrupt('return', code);
case 38:
_context.next = 51;
break;
case 40:
sourceMapPath = path.resolve(path.dirname(id), sourceMapURL);
_context.prev = 41;
_context.next = 44;
return readFileAsync(sourceMapPath, 'utf8');
case 44:
rawMap = _context.sent;
_context.next = 37;
_context.next = 51;
break;
case 33:
_context.prev = 33;
_context.t1 = _context['catch'](27);
case 47:
_context.prev = 47;
_context.t2 = _context['catch'](41);
console.error('rollup-plugin-sourcemaps: Could not open source map: ' + _context.t1);
console.error('rollup-plugin-sourcemaps: Could not open source map: ' + _context.t2);
return _context.abrupt('return', code);
case 37:
case 51:
map = void 0;
_context.prev = 38;
_context.prev = 52;
map = JSON.parse(rawMap);
_context.next = 46;
_context.next = 60;
break;
case 42:
_context.prev = 42;
_context.t2 = _context['catch'](38);
case 56:
_context.prev = 56;
_context.t3 = _context['catch'](52);
console.error('rollup-plugin-sourcemaps: Failed parsing raw source map from ' + id + ': ' + _context.t2);
console.error('rollup-plugin-sourcemaps: Failed parsing raw source map from ' + id + ': ' + _context.t3);
return _context.abrupt('return', code);
case 46:
case 60:
return _context.abrupt('return', { code: code, map: map });
case 47:
case 61:
case 'end':

@@ -159,3 +187,3 @@ return _context.stop();

}
}, _callee, _this, [[3, 9], [27, 33], [38, 42]]);
}, _callee, _this, [[3, 9], [30, 34], [41, 47], [52, 56]]);
}))();

@@ -162,0 +190,0 @@ }

{
"name": "rollup-plugin-sourcemaps",
"version": "0.1.0",
"version": "0.1.1",
"description": "Rollup plugin for grabbing source maps from sourceMappingsURLs",

@@ -36,3 +36,3 @@ "author": "Max Davidson <davidsonmax@gmail.com>",

"source-map",
"sourceMappingsURL"
"sourceMappingURL"
],

@@ -39,0 +39,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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