File tree 4 files changed +30
-4
lines changed
4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ getMajorVersion : ( version ) =>
3
+ typeof version === 'string' && version . includes ( '.' ) ? version . split ( '.' ) [ 0 ] : false
4
+ } ;
Original file line number Diff line number Diff line change 8
8
The above copyright notice and this permission notice shall be
9
9
included in all copies or substantial portions of this Source Code Form.
10
10
*/
11
- const { HotModuleReplacementPlugin } = require ( 'webpack' ) ;
11
+ const { HotModuleReplacementPlugin, version } = require ( 'webpack' ) ;
12
+
13
+ const { getMajorVersion } = require ( '../helpers' ) ;
12
14
13
15
const { PluginExistsError } = require ( '../errors' ) ;
14
16
@@ -18,10 +20,17 @@ const addPlugin = (compiler) => {
18
20
} ;
19
21
20
22
const init = function init ( compiler , log ) {
23
+ const webpackMajorVersion = getMajorVersion ( version ) ;
21
24
// eslint-disable-next-line no-param-reassign
22
25
compiler . options . output = Object . assign ( compiler . options . output , {
23
- hotUpdateChunkFilename : `${ compiler . wpsId } -[id]-wps-hmr.js` ,
24
- hotUpdateMainFilename : `${ compiler . wpsId } -wps-hmr.json`
26
+ hotUpdateChunkFilename :
27
+ webpackMajorVersion >= 5
28
+ ? `[runtime]-${ compiler . wpsId } -[id]-wps-hmr.js`
29
+ : `${ compiler . wpsId } -[id]-wps-hmr.js` ,
30
+ hotUpdateMainFilename :
31
+ webpackMajorVersion >= 5
32
+ ? `[runtime]-${ compiler . wpsId } -wps-hmr.json`
33
+ : `${ compiler . wpsId } -wps-hmr.json`
25
34
} ) ;
26
35
27
36
const hasHMRPlugin = compiler . options . plugins . some (
Original file line number Diff line number Diff line change 16
16
"ci:coverage" : " nyc npm run test && nyc report --reporter=text-lcov > coverage.lcov" ,
17
17
"ci:lint" : " npm run lint && npm run security" ,
18
18
"ci:lint:commits" : " commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}" ,
19
- "ci:test" : " npm run test -- --verbose" ,
19
+ "ci:test" : " npm run test -- --verbose --timeout=30000 " ,
20
20
"commitlint" : " commitlint" ,
21
21
"commitmsg" : " commitlint -e $GIT_PARAMS" ,
22
22
"dev" : " npm run dev:clean && node node_modules/webpack-nano/bin/wp --config test/fixtures/simple/webpack.config.js" ,
Original file line number Diff line number Diff line change
1
+ const test = require ( 'ava' ) ;
2
+
3
+ const { getMajorVersion } = require ( '../lib/helpers' ) ;
4
+
5
+ test ( 'Get major version with correct value' , ( t ) => {
6
+ const majorVersion = getMajorVersion ( '5.2.3' ) ;
7
+ t . true ( majorVersion === '5' ) ;
8
+ } ) ;
9
+
10
+ test ( 'Get major version with incorrect value' , ( t ) => {
11
+ const majorVersion = getMajorVersion ( '5' ) ;
12
+ t . true ( majorVersion === false ) ;
13
+ } ) ;
You can’t perform that action at this time.
0 commit comments