Socket
Socket
Sign inDemoInstall

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 2.0.0-beta.8 to 2.0.0-beta.9

lib/CompatSource.js

8

lib/applySourceMap.js

@@ -11,3 +11,3 @@ /*

const applySourceMap = function(
const applySourceMap = function (
sourceNode,

@@ -42,3 +42,3 @@ sourceMapConsumer,

sourceMapConsumer.eachMapping(
function(mapping) {
function (mapping) {
(m2rMappingsByLine[mapping.generatedLine] =

@@ -52,3 +52,3 @@ m2rMappingsByLine[mapping.generatedLine] || []).push(mapping);

// Store all source contents
sourceNode.walkSourceContents(function(source, content) {
sourceNode.walkSourceContents(function (source, content) {
middleSourceContents["$" + source] = content;

@@ -61,3 +61,3 @@ });

// Walk all left to middle mappings
sourceNode.walk(function(chunk, middleMapping) {
sourceNode.walk(function (chunk, middleMapping) {
// Find a mapping from middle to right

@@ -64,0 +64,0 @@ if (

@@ -104,3 +104,3 @@ /*

null,
this._children.map(function(item) {
this._children.map(function (item) {
if (typeof item.node === "function") return item.node(options);

@@ -107,0 +107,0 @@ const sourceAndMap = item.sourceAndMap(options);

@@ -30,1 +30,2 @@ /*

defineExport("SizeOnlySource", () => require("./SizeOnlySource"));
defineExport("CompatSource", () => require("./CompatSource"));

@@ -64,3 +64,3 @@ /*

null,
lines.map(function(line, idx) {
lines.map(function (line, idx) {
let pos = 0;

@@ -76,3 +76,3 @@ if (options && options.columns === false) {

_splitCode(line + (idx !== lines.length - 1 ? "\n" : "")).map(
function(item) {
function (item) {
if (/^\s*$/.test(item)) {

@@ -79,0 +79,0 @@ pos += item.length;

@@ -53,7 +53,7 @@ /*

const result = new SourceNode();
node.walkSourceContents(function(source, content) {
node.walkSourceContents(function (source, content) {
result.setSourceContent(source, content);
});
let needPrefix = true;
node.walk(function(chunk, mapping) {
node.walk(function (chunk, mapping) {
const parts = chunk.split(/(\n)/);

@@ -88,3 +88,3 @@ for (let i = 0; i < parts.length; i += 2) {

let prefixNextLine = true;
return map.mapGeneratedCode(function(code) {
return map.mapGeneratedCode(function (code) {
let updatedCode = code.replace(REPLACE_REGEX, "\n" + prefix);

@@ -91,0 +91,0 @@ if (prefixNextLine) updatedCode = prefix + updatedCode;

@@ -92,3 +92,3 @@ /*

if (this._isSorted) return;
this._replacements.sort(function(a, b) {
this._replacements.sort(function (a, b) {
const diff1 = b.end - a.end;

@@ -110,3 +110,3 @@ if (diff1 !== 0) return diff1;

const result = [str];
this._replacements.forEach(function(repl) {
this._replacements.forEach(function (repl) {
const remSource = result.pop();

@@ -145,3 +145,3 @@ const splitted1 = this._splitString(remSource, Math.floor(repl.end + 1));

// because "walk" will not handle it
node.walkSourceContents(function(sourceFile, sourceContent) {
node.walkSourceContents(function (sourceFile, sourceContent) {
result.setSourceContent(sourceFile, sourceContent);

@@ -161,3 +161,3 @@ sources["$" + sourceFile] = sourceContent;

if (!source) return null;
lines = source.split("\n").map(function(line) {
lines = source.split("\n").map(function (line) {
return line + "\n";

@@ -174,3 +174,3 @@ });

node.walk(function(chunk, mapping) {
node.walk(function (chunk, mapping) {
position = replaceInStringNode(chunk, position, mapping);

@@ -198,3 +198,3 @@ });

let removeChars = 0;
map = map.mapGeneratedCode(function(str) {
map = map.mapGeneratedCode(function (str) {
const newCurrentIndex = currentIndex + str.length;

@@ -201,0 +201,0 @@ if (removeChars > str.length) {

{
"name": "webpack-sources",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.9",
"description": "Source code handling classes for webpack",

@@ -8,25 +8,25 @@ "main": "./lib/index.js",

"pretest": "yarn lint",
"test": "mocha --full-trace --check-leaks",
"travis": "yarn cover --report lcovonly",
"lint": "eslint lib test",
"test": "jest",
"travis": "yarn cover",
"lint": "eslint --cache lib test",
"precover": "yarn lint",
"cover": "istanbul cover node_modules/mocha/bin/_mocha"
"cover": "jest --coverage"
},
"dependencies": {
"source-list-map": "^2.0.1",
"source-map": "~0.6.1"
"source-map": "^0.6.1"
},
"devDependencies": {
"coveralls": "^3.0.2",
"eslint": "^5.12.0",
"eslint-config-prettier": "^3.5.0",
"eslint-plugin-mocha": "^5.2.1",
"eslint-plugin-node": "^8.0.1",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-nodeca": "^1.0.3",
"eslint-plugin-prettier": "^3.0.1",
"istanbul": "^0.4.1",
"mocha": "^5.2.0",
"prettier": "^1.15.3",
"should": "^13.2.3",
"sourcemap-validator": "^1.1.0"
"jest": "^26.4.0",
"prettier": "^2.0.5",
"sourcemap-validator": "^2.1.0"
},

@@ -52,3 +52,13 @@ "files": [

},
"homepage": "https://github.com/webpack/webpack-sources#readme"
"homepage": "https://github.com/webpack/webpack-sources#readme",
"jest": {
"forceExit": true,
"testMatch": [
"<rootDir>/test/*.js"
],
"transformIgnorePatterns": [
"<rootDir>"
],
"testEnvironment": "node"
}
}

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

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

@@ -24,3 +24,3 @@ ```

```js
```typescript
Source.prototype.buffer() -> Buffer

@@ -33,3 +33,3 @@ ```

```js
```typescript
Source.prototype.size() -> Number

@@ -42,3 +42,3 @@ ```

```js
```typescript
Source.prototype.map(options?: Object) -> Object | null

@@ -56,3 +56,3 @@ ```

```js
```typescript
Source.prototype.sourceAndMap(options?: Object) -> {

@@ -70,3 +70,3 @@ source: String | Buffer,

```js
```typescript
Source.prototype.updateHash(hash: Hash) -> void

@@ -81,3 +81,3 @@ ```

```js
```typescript
new RawSource(sourceCode: String)

@@ -90,3 +90,3 @@ ```

```js
```typescript
new OriginalSource(

@@ -107,3 +107,3 @@ sourceCode: String,

```js
```typescript
new SourceMapSource(

@@ -129,3 +129,2 @@ sourceCode: String,

## `CachedSource`

@@ -136,3 +135,3 @@

```js
```typescript
new CachedSource(source: Source)

@@ -145,3 +144,3 @@ ```

```js
```typescript
new PrefixSource(

@@ -157,3 +156,3 @@ prefix: String,

```js
```typescript
new ConcatSource(

@@ -168,3 +167,3 @@ ...items?: Source | String

```js
```typescript
ConcatSource.prototype.add(item: Source | String)

@@ -186,3 +185,3 @@ ```

```js
```typescript
ReplaceSource.prototype.replace(

@@ -201,3 +200,3 @@ start: Number,

```js
```typescript
ReplaceSource.prototype.insert(

@@ -216,1 +215,15 @@ pos: Number,

Get decorated `Source`.
## `CompatSource`
Converts a Source-like object into a real Source object.
### Public methods
#### static `from`
```typescript
CompatSource.from(sourceLike: any | Source)
```
If `sourceLike` is a real Source it returns it unmodified. Otherwise it returns it wrapped in a CompatSource.
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