webpack-sources
Advanced tools
Comparing version 2.0.0-beta.9 to 2.0.0-beta.10
@@ -81,8 +81,11 @@ /* | ||
originalLazy() { | ||
return this._source; | ||
} | ||
original() { | ||
if (typeof this._source === "function") this._source = this._source(); | ||
return this._source; | ||
} | ||
_ensureSource() {} | ||
source() { | ||
@@ -95,3 +98,3 @@ if (this._cachedSource !== undefined) return this._cachedSource; | ||
} else { | ||
return (this._cachedSource = this._source.source()); | ||
return (this._cachedSource = this.original().source()); | ||
} | ||
@@ -108,4 +111,4 @@ } | ||
} | ||
if (typeof this._source.buffer === "function") { | ||
return (this._cachedBuffer = this._source.buffer()); | ||
if (typeof this.original().buffer === "function") { | ||
return (this._cachedBuffer = this.original().buffer()); | ||
} | ||
@@ -127,3 +130,3 @@ const bufferOrString = this.source(); | ||
} | ||
return (this._cachedSize = this._source.size()); | ||
return (this._cachedSize = this.original().size()); | ||
} | ||
@@ -139,3 +142,3 @@ | ||
if (cacheEntry === undefined) { | ||
const map = this._source.map(options); | ||
const map = this.original().map(options); | ||
this._cachedMaps.set(key, { map, bufferedMap: undefined }); | ||
@@ -154,7 +157,7 @@ return { | ||
return { | ||
source: (this._cachedSource = this._source.source()), | ||
source: (this._cachedSource = this.original().source()), | ||
map: cacheEntry.map | ||
}; | ||
} else { | ||
const result = this._source.sourceAndMap(options); | ||
const result = this.original().sourceAndMap(options); | ||
this._cachedSource = result.source; | ||
@@ -175,3 +178,3 @@ this._cachedMaps.set(key, { map: result.map, bufferedMap: undefined }); | ||
} | ||
const map = this._source.map(options); | ||
const map = this.original().map(options); | ||
this._cachedMaps.set(key, { map, bufferedMap: undefined }); | ||
@@ -182,3 +185,3 @@ return map; | ||
updateHash(hash) { | ||
this._source.updateHash(hash); | ||
this.original().updateHash(hash); | ||
} | ||
@@ -185,0 +188,0 @@ } |
{ | ||
"name": "webpack-sources", | ||
"version": "2.0.0-beta.9", | ||
"version": "2.0.0-beta.10", | ||
"description": "Source code handling classes for webpack", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -127,4 +127,21 @@ # webpack-sources | ||
new CachedSource(source: Source) | ||
new CachedSource(source: Source | () => Source, cachedData?: CachedData) | ||
``` | ||
Instead of passing a `Source` object directly one can pass an function that returns a `Source` object. The function is only called when needed and once. | ||
### Public methods | ||
#### `getCachedData()` | ||
Returns the cached data for passing to the constructor. All cached entries are converted to Buffers and strings are avoided. | ||
#### `original()` | ||
Returns the original `Source` object. | ||
#### `originalLazy()` | ||
Returns the original `Source` object or a function returning these. | ||
## `PrefixSource` | ||
@@ -131,0 +148,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53390
1589
230