Gathering detailed insights and metrics for webpack-sources
Gathering detailed insights and metrics for webpack-sources
Gathering detailed insights and metrics for webpack-sources
Gathering detailed insights and metrics for webpack-sources
npm install webpack-sources
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
262 Stars
299 Commits
71 Forks
10 Watching
10 Branches
93 Contributors
Updated on 15 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-3%
6,768,660
Compared to previous day
Last week
3.2%
35,784,843
Compared to previous week
Last month
13.5%
146,423,653
Compared to previous month
Last year
1.4%
1,589,662,921
Compared to previous year
Contains multiple classes which represent a Source
. A Source
can be asked for source code, size, source map and hash.
Source
Base class for all sources.
All methods should be considered as expensive as they may need to do computations.
source
1Source.prototype.source() -> String | Buffer
Returns the represented source code as string or Buffer (for binary Sources).
buffer
1Source.prototype.buffer() -> Buffer
Returns the represented source code as Buffer. Strings are converted to utf-8.
size
1Source.prototype.size() -> Number
Returns the size in bytes of the represented source code.
map
1Source.prototype.map(options?: Object) -> Object | null
Returns the SourceMap of the represented source code as JSON. May return null
if no SourceMap is available.
The options
object can contain the following keys:
columns: Boolean
(default true
): If set to false the implementation may omit mappings for columns.sourceAndMap
1Source.prototype.sourceAndMap(options?: Object) -> { 2 source: String | Buffer, 3 map: Object | null 4}
Returns both, source code (like Source.prototype.source()
and SourceMap (like Source.prototype.map()
). This method could have better performance than calling source()
and map()
separately.
See map()
for options
.
updateHash
1Source.prototype.updateHash(hash: Hash) -> void
Updates the provided Hash
object with the content of the represented source code. (Hash
is an object with an update
method, which is called with string values)
RawSource
Represents source code without SourceMap.
1new RawSource(sourceCode: String | Buffer)
OriginalSource
Represents source code, which is a copy of the original file.
1new OriginalSource( 2 sourceCode: String | Buffer, 3 name: String 4)
sourceCode
: The source code.name
: The filename of the original source code.OriginalSource tries to create column mappings if requested, by splitting the source code at typical statement borders (;
, {
, }
).
SourceMapSource
Represents source code with SourceMap, optionally having an additional SourceMap for the original source.
1new SourceMapSource( 2 sourceCode: String | Buffer, 3 name: String, 4 sourceMap: Object | String | Buffer, 5 originalSource?: String | Buffer, 6 innerSourceMap?: Object | String | Buffer, 7 removeOriginalSource?: boolean 8)
sourceCode
: The source code.name
: The filename of the original source code.sourceMap
: The SourceMap for the source code.originalSource
: The source code of the original file. Can be omitted if the sourceMap
already contains the original source code.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
.
CachedSource
Decorates a Source
and caches returned results of map
, source
, buffer
, size
and sourceAndMap
in memory. updateHash
is not cached.
It tries to reused cached results from other methods to avoid calculations, i. e. when source
is already cached, calling size
will get the size from the cached source, calling sourceAndMap
will only call map
on the wrapped Source.
1new CachedSource(source: Source) 2new 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.
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
Prefix every line of the decorated Source
with a provided string.
1new PrefixSource( 2 prefix: String, 3 source: Source | String | Buffer 4)
ConcatSource
Concatenate multiple Source
s or strings to a single source.
1new ConcatSource( 2 ...items?: Source | String 3)
add
1ConcatSource.prototype.add(item: Source | String)
Adds an item to the source.
ReplaceSource
Decorates a Source
with replacements and insertions of source code.
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.
replace
1ReplaceSource.prototype.replace( 2 start: Number, 3 end: Number, 4 replacement: String 5)
Replaces chars from start
(0-indexed, inclusive) to end
(0-indexed, inclusive) with replacement
.
Locations represents locations in the original source and are not influenced by other replacements or insertions.
insert
1ReplaceSource.prototype.insert( 2 pos: Number, 3 insertion: String 4)
Inserts the insertion
before char pos
(0-indexed).
Location represents location in the original source and is not influenced by other replacements or insertions.
original
Get decorated Source
.
CompatSource
Converts a Source-like object into a real Source object.
from
1CompatSource.from(sourceLike: any | Source)
If sourceLike
is a real Source it returns it unmodified. Otherwise it returns it wrapped in a CompatSource.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/10 approved changesets -- score normalized to 5
Reason
7 existing vulnerabilities detected
Details
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@types/webpack-sources
TypeScript definitions for webpack-sources
adjust-sourcemap-loader
Webpack loader that adjusts source maps
@monaco-editor/loader
the library aims to setup monaco editor into your browser
convert-source-map
Converts a source-map from/to different formats and allows adding/changing properties.