* @param {string} context the compilation context * @param {string | Buffer} content the content * @param {(string | RawSourceMap | null)=} sourceMap an optional source map * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching * @returns {Source} the created source
(context, content, sourceMap, associatedObjectForCache)
| 1416 | * @returns {Source} the created source |
| 1417 | */ |
| 1418 | createSource(context, content, sourceMap, associatedObjectForCache) { |
| 1419 | if (Buffer.isBuffer(content)) { |
| 1420 | return new RawSource(content); |
| 1421 | } |
| 1422 | |
| 1423 | // if there is no identifier return raw source |
| 1424 | if (!this.identifier) { |
| 1425 | return new RawSource(content); |
| 1426 | } |
| 1427 | |
| 1428 | // from here on we assume we have an identifier |
| 1429 | const identifier = this.identifier(); |
| 1430 | |
| 1431 | if (this.useSourceMap && sourceMap) { |
| 1432 | return new SourceMapSource( |
| 1433 | content, |
| 1434 | contextifySourceUrl(context, identifier, associatedObjectForCache), |
| 1435 | contextifySourceMap(context, sourceMap, associatedObjectForCache) |
| 1436 | ); |
| 1437 | } |
| 1438 | |
| 1439 | if (this.useSourceMap || this.useSimpleSourceMap) { |
| 1440 | return new OriginalSource( |
| 1441 | content, |
| 1442 | contextifySourceUrl(context, identifier, associatedObjectForCache) |
| 1443 | ); |
| 1444 | } |
| 1445 | |
| 1446 | return new RawSource(content); |
| 1447 | } |
| 1448 | |
| 1449 | /** |
| 1450 | * @param {WebpackOptions} options webpack options |
no test coverage detected