Blame view

node_modules/extract-text-webpack-plugin/dist/lib/ExtractedModule.js 3.08 KB
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  var _webpackSources = require('webpack-sources');
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  var ExtractedModule = function () {
    function ExtractedModule(identifier, originalModule, source, sourceMap, addtitionalInformation, prevModules) {
      _classCallCheck(this, ExtractedModule);
  
      this._identifier = identifier;
      this._originalModule = originalModule;
      this._source = source;
      this._sourceMap = sourceMap;
      this._prevModules = prevModules;
      this.addtitionalInformation = addtitionalInformation;
      this.chunks = [];
    }
  
    _createClass(ExtractedModule, [{
      key: 'getOrder',
      value: function getOrder() {
        // http://stackoverflow.com/a/14676665/1458162
        return (/^@import url/.test(this._source) ? 0 : 1
        );
      }
    }, {
      key: 'addChunk',
      value: function addChunk(chunk) {
        var idx = this.chunks.indexOf(chunk);
        if (idx < 0) {
          this.chunks.push(chunk);
        }
      }
    }, {
      key: 'removeChunk',
      value: function removeChunk(chunk) {
        var idx = this.chunks.indexOf(chunk);
        if (idx >= 0) {
          this.chunks.splice(idx, 1);
          chunk.removeModule(this);
          return true;
        }
        return false;
      }
    }, {
      key: 'rewriteChunkInReasons',
      value: function rewriteChunkInReasons(oldChunk, newChunks) {} // eslint-disable-line
  
    }, {
      key: 'identifier',
      value: function identifier() {
        return this._identifier;
      }
    }, {
      key: 'source',
      value: function source() {
        if (this._sourceMap) {
          return new _webpackSources.SourceMapSource(this._source, null, this._sourceMap);
        }
        return new _webpackSources.RawSource(this._source);
      }
    }, {
      key: 'getOriginalModule',
      value: function getOriginalModule() {
        return this._originalModule;
      }
    }, {
      key: 'getPrevModules',
      value: function getPrevModules() {
        return this._prevModules;
      }
    }, {
      key: 'addPrevModules',
      value: function addPrevModules(prevModules) {
        var _this = this;
  
        prevModules.forEach(function (m) {
          if (_this._prevModules.indexOf(m) < 0) {
            _this._prevModules.push(m);
          }
        }, this);
      }
    }, {
      key: 'setOriginalModule',
      value: function setOriginalModule(originalModule) {
        this._originalModule = originalModule;
      }
    }]);
  
    return ExtractedModule;
  }();
  
  exports.default = ExtractedModule;