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

webpack-sources

Package Overview
Dependencies
Maintainers
5
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-sources - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

lib/applySourceMap.js

6

lib/CachedSource.js

@@ -33,4 +33,6 @@ /*

if(typeof this._cachedSize !== "undefined") return this._cachedSize;
if(typeof this._cachedSource !== "undefined")
return this._cachedSize = this._cachedSource.length;
if(typeof this._cachedSource !== "undefined") {
if(Buffer.from.length === 1) return new Buffer(this._cachedSource).length;
return this._cachedSize = Buffer.byteLength(this._cachedSource);
}
return this._cachedSize = this._source.size();

@@ -37,0 +39,0 @@ }

@@ -48,6 +48,23 @@ /*

var node = this._source.node(options);
var append = [this._prefix];
return new SourceNode(null, null, null, [
cloneAndPrefix(node, this._prefix, append)
]);
var prefix = this._prefix;
var output = [];
var result = new SourceNode();
node.walkSourceContents(function(source, content) {
result.setSourceContent(source, content);
});
var needPrefix = true;
node.walk(function(chunk, mapping) {
var parts = chunk.split("\n");
for(var i = 0; i < parts.length; i += 2) {
var nl = i + 1 < parts.length;
var part = parts[i] + (nl ? "\n" : "");
if(part && needPrefix) {
output.push(prefix);
}
output.push(new SourceNode(mapping.line, mapping.column, mapping.source, chunk, mapping.name));
needPrefix = nl;
}
});
result.add(output);
return result;
}

@@ -54,0 +71,0 @@

@@ -9,5 +9,2 @@ /*

var SourceNode = require("source-map").SourceNode;
var SourceListMap = require("source-list-map").SourceListMap;
var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
var SourceMapConsumer = require("source-map").SourceMapConsumer;

@@ -14,0 +11,0 @@ class Replacement {

@@ -17,3 +17,4 @@ /*

size() {
return this.source().length;
if(Buffer.from.length === 1) return new Buffer(this.source()).length;
return Buffer.byteLength(this.source())
}

@@ -20,0 +21,0 @@

@@ -24,3 +24,2 @@ /*

if(options.columns === false) {
//console.log(this.listMap(options).debugInfo());
return this.listMap(options).toStringWithSourceMap({

@@ -27,0 +26,0 @@ file: "x"

@@ -13,5 +13,6 @@ /*

var Source = require("./Source");
var applySourceMap = require("./applySourceMap");
class SourceMapSource extends Source {
constructor(value, name, sourceMap, originalSource, innerSourceMap) {
constructor(value, name, sourceMap, originalSource, innerSourceMap, removeOriginalSource) {
super();

@@ -23,2 +24,3 @@ this._value = value;

this._innerSourceMap = innerSourceMap;
this._removeOriginalSource = removeOriginalSource;
}

@@ -31,13 +33,10 @@

node(options) {
var sourceMap = this._sourceMap;
var node = SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
node.setSourceContent(this._name, this._originalSource);
var innerSourceMap = this._innerSourceMap;
var sourceMap = this._sourceMap;
if(innerSourceMap) {
sourceMap = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(sourceMap));
if(this._originalSource)
sourceMap.setSourceContent(this._name, this._originalSource);
innerSourceMap = new SourceMapConsumer(innerSourceMap);
sourceMap.applySourceMap(innerSourceMap, this._name);
sourceMap = sourceMap.toJSON();
node = applySourceMap(node, new SourceMapConsumer(innerSourceMap), this._name, this._removeOriginalSource);
}
return SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
return node;
}

@@ -44,0 +43,0 @@

{
"name": "webpack-sources",
"version": "1.3.0",
"version": "1.4.0",
"description": "Source code handling classes for webpack",

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

@@ -16,3 +16,3 @@ # webpack-sources

``` js
Source.prototype.source() -> String
Source.prototype.source() -> String | ArrayBuffer
```

@@ -47,3 +47,3 @@

Source.prototype.sourceAndMap(options: Object) -> {
code: String,
source: String,
map: Object

@@ -123,3 +123,4 @@ }

originalSource?: String,
innerSourceMap?: Object | String
innerSourceMap?: Object | String,
removeOriginalSource?: boolean
)

@@ -133,3 +134,7 @@ ```

* `innerSourceMap`: The SourceMap for the `originalSource`/`name`.
* `removeOriginalSource`: Removes the source code for `name` from the final map, keeping only the deeper mappings for that file.
The `SourceMapSource` supports "identity" mappings for the `innerSourceMap`.
When original source matches generated source for a mapping it's assumed to be mapped char by char allowing to keep finer mappings from `sourceMap`.
## `LineToLineMappedSource`

@@ -172,3 +177,3 @@

Concatenate mulitple `Source`s or strings to a single source.
Concatenate multiple `Source`s or strings to a single source.

@@ -189,3 +194,3 @@ ``` js

Adds an item to the source.
Adds an item to the source.

@@ -196,2 +201,5 @@ ## `ReplaceSource`

The `ReplaceSource` supports "identity" mappings for child source.
When original source matches generated source for a mapping it's assumed to be mapped char by char allowing to split mappings at replacements/insertions.
### Public methods

@@ -198,0 +206,0 @@

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