MCPcopy
hub / github.com/webpack/webpack / createSourceForAsset

Method createSourceForAsset

lib/NormalModule.js:1094–1127  ·  view source on GitHub ↗

* @param {string} context the compilation context * @param {string} name the asset name * @param {string | Buffer} content the content * @param {(string | RawSourceMap)=} sourceMap an optional source map * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching * @re

(
		context,
		name,
		content,
		sourceMap,
		associatedObjectForCache
	)

Source from the content-addressed store, hash-verified

1092 * @returns {Source} the created source
1093 */
1094 createSourceForAsset(
1095 context,
1096 name,
1097 content,
1098 sourceMap,
1099 associatedObjectForCache
1100 ) {
1101 if (sourceMap) {
1102 if (
1103 typeof sourceMap === "string" &&
1104 (this.useSourceMap || this.useSimpleSourceMap)
1105 ) {
1106 return new OriginalSource(
1107 content,
1108 contextifySourceUrl(context, sourceMap, associatedObjectForCache)
1109 );
1110 }
1111
1112 if (this.useSourceMap) {
1113 return new SourceMapSource(
1114 content,
1115 name,
1116 contextifySourceMap(
1117 context,
1118 /** @type {RawSourceMap} */
1119 (sourceMap),
1120 associatedObjectForCache
1121 )
1122 );
1123 }
1124 }
1125
1126 return new RawSource(content);
1127 }
1128
1129 /**
1130 * @private

Callers 2

_createLoaderContextMethod · 0.95

Calls 2

contextifySourceUrlFunction · 0.85
contextifySourceMapFunction · 0.85

Tested by

no test coverage detected