You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.7 KiB

4 years ago
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _webpackSources = require('webpack-sources');
  6. class ExtractedModule {
  7. constructor(identifier, originalModule, source, sourceMap, additionalInformation, prevModules) {
  8. this._identifier = identifier;
  9. this._originalModule = originalModule;
  10. this._source = source;
  11. this._sourceMap = sourceMap;
  12. this._prevModules = prevModules;
  13. this.additionalInformation = additionalInformation;
  14. this.chunks = [];
  15. }
  16. getOrder() {
  17. // http://stackoverflow.com/a/14676665/1458162
  18. return (/^@import url/.test(this._source) ? 0 : 1
  19. );
  20. }
  21. addChunk(chunk) {
  22. const idx = this.chunks.indexOf(chunk);
  23. if (idx < 0) {
  24. this.chunks.push(chunk);
  25. }
  26. }
  27. removeChunk(chunk) {
  28. const idx = this.chunks.indexOf(chunk);
  29. if (idx >= 0) {
  30. this.chunks.splice(idx, 1);
  31. chunk.removeModule(this);
  32. return true;
  33. }
  34. return false;
  35. }
  36. rewriteChunkInReasons(oldChunk, newChunks) {} // eslint-disable-line
  37. identifier() {
  38. return this._identifier;
  39. }
  40. source() {
  41. if (this._sourceMap) {
  42. return new _webpackSources.SourceMapSource(this._source, null, this._sourceMap);
  43. }
  44. return new _webpackSources.RawSource(this._source);
  45. }
  46. getOriginalModule() {
  47. return this._originalModule;
  48. }
  49. getPrevModules() {
  50. return this._prevModules;
  51. }
  52. addPrevModules(prevModules) {
  53. prevModules.forEach(m => {
  54. if (this._prevModules.indexOf(m) < 0) {
  55. this._prevModules.push(m);
  56. }
  57. }, this);
  58. }
  59. setOriginalModule(originalModule) {
  60. this._originalModule = originalModule;
  61. }
  62. }
  63. exports.default = ExtractedModule;