File tree Expand file tree Collapse file tree 4 files changed +10
-28
lines changed Expand file tree Collapse file tree 4 files changed +10
-28
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ const SVGCompiler = require('svg-baker');
4
4
5
5
const { NAMESPACE } = require ( './config' ) ;
6
6
const configure = require ( './configurator' ) ;
7
- const { getWebpackVersion } = require ( './utils' ) ;
8
7
const Exceptions = require ( './exceptions' ) ;
9
8
10
9
let svgCompiler = new SVGCompiler ( ) ;
@@ -31,13 +30,8 @@ module.exports = function loader(content) {
31
30
32
31
const configObj = { context : loaderContext } ;
33
32
34
- if ( getWebpackVersion . IS_4 ) {
35
- configObj . config = loaderContext . query ;
36
- configObj . target = loaderContext . target ;
37
- } else {
38
- configObj . config = matchedRules ;
39
- configObj . target = loaderContext . options . target || loaderContext . target ;
40
- }
33
+ configObj . config = matchedRules ;
34
+ configObj . target = loaderContext . target ;
41
35
42
36
/**
43
37
* @type {SVGSpriteLoaderConfig }
Original file line number Diff line number Diff line change 9
9
MappedList,
10
10
replaceInModuleSource,
11
11
replaceSpritePlaceholder,
12
- getWebpackVersion,
13
12
getMatchedRule
14
13
} = require ( './utils' ) ;
15
14
16
- const webpackVersion = parseInt ( getWebpackVersion ( ) , 10 ) ;
17
-
18
15
const defaultConfig = {
19
16
plainSprite : false ,
20
17
spriteAttrs : { }
@@ -187,21 +184,15 @@ class SVGSpritePlugin {
187
184
chunks . forEach ( ( chunk ) => {
188
185
let modules ;
189
186
190
- switch ( webpackVersion ) {
191
- case 4 :
192
- modules = Array . from ( chunk . modulesIterable ) ;
193
- break ;
194
- case 3 :
195
- modules = chunk . mapModules ( ) ;
196
- break ;
197
- default :
198
- ( { modules } = chunk ) ;
199
- break ;
187
+ if ( chunk . modulesIterable ) {
188
+ modules = Array . from ( chunk . modulesIterable ) ;
189
+ } else {
190
+ modules = chunk . modules ;
200
191
}
201
192
202
193
modules
203
- // dirty hack to identify modules extracted by extract-text-webpack-plugin
204
- // TODO refactor
194
+ // dirty hack to identify modules extracted by extract-text-webpack-plugin
195
+ // TODO refactor
205
196
. filter ( module => '_originalModule' in module )
206
197
. forEach ( module => replaceInModuleSource ( module , replacements ) ) ;
207
198
} ) ;
Original file line number Diff line number Diff line change 1
- const webpackVersion = require ( './get-webpack-version' ) ;
2
-
3
1
/**
4
2
* Find nearest module chunk (not sure that is reliable method, but who cares).
5
3
* @see http://stackoverflow.com/questions/43202761/how-to-determine-all-module-chunks-in-webpack
@@ -10,9 +8,9 @@ const webpackVersion = require('./get-webpack-version');
10
8
function getModuleChunk ( module , modules ) {
11
9
let chunks ;
12
10
13
- if ( webpackVersion . IS_4 ) {
11
+ if ( module . chunksIterable ) {
14
12
chunks = Array . from ( module . chunksIterable ) ;
15
- } else if ( parseInt ( webpackVersion ( ) , 10 ) >= 3 ) {
13
+ } else if ( module . mapChunks ) {
16
14
chunks = module . mapChunks ( ) ;
17
15
} else {
18
16
chunks = module . chunks ;
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ module.exports.getAllModules = require('./get-all-modules');
5
5
// module.exports.getLoaderOptions = require('./get-loader-options');
6
6
module . exports . getModuleChunk = require ( './get-module-chunk' ) ;
7
7
module . exports . getMatchedRule = require ( './get-matched-rule' ) ;
8
- module . exports . getWebpackVersion = require ( './get-webpack-version' ) ;
9
8
module . exports . isModuleShouldBeExtracted = require ( './is-module-should-be-extracted' ) ;
10
9
module . exports . interpolate = require ( './interpolate' ) ;
11
10
module . exports . isWebpack1 = require ( './is-webpack-1' ) ;
You can’t perform that action at this time.
0 commit comments