3.2.3 • Published 3 years ago

webpack-sources v3.2.3

Weekly downloads
14,238,464
License
MIT
Repository
github
Last release
3 years ago

webpack-sources

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.

Public methods

All methods should be considered as expensive as they may need to do computations.

source

Source.prototype.source() -> String | Buffer

Returns the represented source code as string or Buffer (for binary Sources).

buffer

Source.prototype.buffer() -> Buffer

Returns the represented source code as Buffer. Strings are converted to utf-8.

size

Source.prototype.size() -> Number

Returns the size in bytes of the represented source code.

map

Source.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

Source.prototype.sourceAndMap(options?: Object) -> {
	source: String | Buffer,
	map: Object | null
}

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

Source.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.

new RawSource(sourceCode: String | Buffer)

OriginalSource

Represents source code, which is a copy of the original file.

new OriginalSource(
	sourceCode: String | Buffer,
	name: String
)
  • 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.

new SourceMapSource(
	sourceCode: String | Buffer,
	name: String,
	sourceMap: Object | String | Buffer,
	originalSource?: String | Buffer,
	innerSourceMap?: Object | String | Buffer,
	removeOriginalSource?: boolean
)
  • 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.

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

Prefix every line of the decorated Source with a provided string.

new PrefixSource(
	prefix: String,
	source: Source | String | Buffer
)

ConcatSource

Concatenate multiple Sources or strings to a single source.

new ConcatSource(
	...items?: Source | String
)

Public methods

add

ConcatSource.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.

Public methods

replace

ReplaceSource.prototype.replace(
	start: Number,
	end: Number,
	replacement: String
)

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

ReplaceSource.prototype.insert(
	pos: Number,
	insertion: String
)

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.

Public methods

static from

CompatSource.from(sourceLike: any | Source)

If sourceLike is a real Source it returns it unmodified. Otherwise it returns it wrapped in a CompatSource.

terser-webpack-pluginwebpacklast-call-webpack-pluginwebpack-manifest-pluginworkbox-webpack-pluginlicense-webpack-pluginuglifyjs-webpack-plugin@xdn/nextfree-mincomponennentt@layer0/next@ishopee/cli-servicevuedragdropuploadimagesaerolito-next@zzappie/bigchaindb-driveroptimize-css-classnames-plugin@nhatle/react-build-tools@intrnl/extract-css-chunks-webpack-pluginrtlcss-laravel-mixnext-sheertex@piekarski/brotli-webpack-pluginnext-sitemapswxapp-webpack-plugin-improvement@mtgroup/jest-webpackdrg-clibb-chat@nghiepuit/sdk-builderbase-sdk-buildernghiepuit-build-tools@nghiepuit/react-build-tool@frxf/frxf@primal/operator-pwa@webdeveric/anti-theft-device@texttree/demo-bsa-reference-rclalex-d.js@fundefund/funde_ck@compassdigital/project-mhares-nextgql_din_modfe-blessxrdc@memoryai/frontend-config@l1nyanm1ng/react-picture-viewer@electron.land/electron-scriptscthpb-plugin-socialeditable-assets-webpack-plugincbmis-ai-toolboxconvert-es5-pluginweapp-tailwind-plugin@triply/babel-engine-pluginlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29js4cytoscapewebpack-i18n-pluginwebpack-toolboxtest-react-scripts-condunblock-block-save-variables@elwood-studio/distribute-nextjscclibyarntest@saaspe/componentshyperpass-sdkweboptimizersklif-ui-kitsklif-api@explodingcamera/next@everything-registry/sub-chunk-3133pretty-output-webpack-pluginuserscript-webpack-plugin@deepakorg/test@deepak757/testondp149-tablesklif-ui@pushengineering/slate-sections-pluginlapture-ui-complaptureuicomposizedrpdwn-mntaman-baca-masyarakattargets-webpack-plugintbhag-nextsymphony-joytemplated-assets-webpack-pluginsw-nexttest-carosello-campuswind-autodll-webpack-pluginwinx-form-winxwip-overall-departed-scorebook-paralyze-genrewhitegarddenwepy-actwinkey-tinyimg-pluginwongterrencew-fork-phenomicvvpay-loader
3.2.3

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.2

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.3.1

3 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-beta.10

4 years ago

2.0.0-beta.9

4 years ago

2.0.0-beta.8

5 years ago

2.0.0-beta.7

5 years ago

2.0.0-beta.6

5 years ago

2.0.0-beta.5

5 years ago

2.0.0-beta.4

5 years ago

2.0.0-beta.3

5 years ago

1.4.3

5 years ago

2.0.0-beta.2

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

2.0.0-beta.1

6 years ago

2.0.0-beta.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago