How to use the webpack-sources.LineToLineMappedSource function in webpack-sources

To help you get started, we’ve selected a few webpack-sources examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github weixin / Miaow / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if (!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if (this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source,
				identifier,
				asString(resourceBuffer)
			);
		}

		if (this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		if (Buffer.isBuffer(source)) {
			return new RawSource(source);
		}

		return new OriginalSource(source, identifier);
	}
github makuga01 / dnsFookup / FE / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if (!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if (this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source,
				identifier,
				asString(resourceBuffer)
			);
		}

		if (this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		if (Buffer.isBuffer(source)) {
			// @ts-ignore
			// TODO We need to fix @types/webpack-sources to allow RawSource to take a Buffer | string
			return new RawSource(source);
		}
github csxiaoyaojianxian / JavaScriptStudy / 09-Tools / 01-webpack / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if(!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if(this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source, identifier, asString(resourceBuffer));
		}

		if(this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		return new OriginalSource(source, identifier);
	}
github Graphite-Docs / graphite / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if(!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if(this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source, identifier, asString(resourceBuffer));
		}

		if(this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		return new OriginalSource(source, identifier);
	}
github johandb / svg-drawing-tool / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if (!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if (this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source,
				identifier,
				asString(resourceBuffer)
			);
		}

		if (this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		if (Buffer.isBuffer(source)) {
			// @ts-ignore
			// TODO We need to fix @types/webpack-sources to allow RawSource to take a Buffer | string
			return new RawSource(source);
		}
github GoogleChromeLabs / critters / src / index.js View on Github external
setNodeText(style, before);
          // remove any associated external resources/loaders:
          if (style.$$links) {
            for (const link of style.$$links) {
              const parent = link.parentNode;
              if (parent) parent.removeChild(link);
            }
          }
          // delete the webpack asset:
          delete style.$$assets[style.$$assetName];
          return;
        }

        const percent = sheetInverse.length / before.length * 100;
        afterText = `, reducing non-inlined size ${percent | 0}% to ${prettyBytes(sheetInverse.length)}`;
        style.$$assets[style.$$assetName] = new sources.LineToLineMappedSource(sheetInverse, style.$$assetName, before);
      } else {
        this.logger.warn('pruneSource is enabaled, but a style (' + name + ') has no corresponding Webpack asset.');
      }
    }

    // replace the inline stylesheet with its critical'd counterpart
    setNodeText(style, sheet);

    // output stats
    const percent = sheet.length / before.length * 100 | 0;
    this.logger.info('\u001b[32mInlined ' + prettyBytes(sheet.length) + ' (' + percent + '% of original ' + prettyBytes(before.length) + ') of ' + name + afterText + '.\u001b[39m');
  }
}
github xxxgitone / learningProcess / WebPack-Beginner / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if(!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if(this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source, identifier, asString(resourceBuffer));
		}

		if(this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		return new OriginalSource(source, identifier);
	}
github TYRMars / ES6-StepPitGuide / es6 / node_modules / webpack / lib / NormalModule.js View on Github external
createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if(!this.identifier) {
			return new RawSource(source);
		}

		// from here on we assume we have an identifier
		const identifier = this.identifier();

		if(this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source, identifier, asString(resourceBuffer));
		}

		if(this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}

		return new OriginalSource(source, identifier);
	}
github DefinitelyTyped / DefinitelyTyped / webpack-sources / webpack-sources-tests.ts View on Github external
} from 'webpack-sources';
import { RawSourceMap } from 'source-map'

const s1 = new OriginalSource('a', 'b');

const s2 = new CachedSource(s1);

const s3 = new ConcatSource('a', 'b', s1);

const s4 = new RawSource('hey');

const a = {} as RawSourceMap
const b = {} as RawSourceMap

const s5 = new LineToLineMappedSource('a', 'v', 'c');
const s6 = new PrefixSource(s4, s5);
const s7 = new ReplaceSource(s3, 'ha');
const s8 = new SourceMapSource('va', 'vb', a, 'vc', b);