10
10
*/
11
11
'use strict' ;
12
12
13
- var babel = require ( 'babel-core' ) ;
14
- var UglifyJs = require ( 'uglify-js' ) ;
15
- var testMinificationUsedDCE ;
13
+ const babel = require ( 'babel-core' ) ;
14
+ const UglifyJs = require ( 'uglify-js' ) ;
15
+ let testMinificationUsedDCE ;
16
16
17
17
describe ( 'in the production environment' , ( ) => {
18
18
let oldProcess ;
@@ -49,12 +49,12 @@ describe('in the production environment', () => {
49
49
describe ( 'when envified first, then minification with *no* DCE' , ( ) => {
50
50
it ( 'should throw' , ( ) => {
51
51
// envify: change `process.env.NODE_ENV` to `"production"`
52
- var rawCode = testMinificationUsedDCE
52
+ const rawCode = testMinificationUsedDCE
53
53
. toString ( )
54
54
. replace ( / p r o c e s s \. e n v \. N O D E _ E N V / , '"production"' ) ;
55
- var code = { 'file.js' : rawCode } ;
56
- var options = { fromString : true , parse : { dead_code : false } } ;
57
- var result = UglifyJs . minify ( code , options ) ;
55
+ const code = { 'file.js' : rawCode } ;
56
+ const options = { fromString : true , parse : { dead_code : false } } ;
57
+ const result = UglifyJs . minify ( code , options ) ;
58
58
const minifiedWithNoDCE = ( ) => eval ( '(' + result . code + ')()' ) ;
59
59
expect ( ( ) => {
60
60
minifiedWithNoDCE ( ) ;
@@ -69,12 +69,12 @@ describe('in the production environment', () => {
69
69
describe ( 'when envified first, then minified and *yes* successful DCE' , ( ) => {
70
70
it ( 'should not throw' , ( ) => {
71
71
// envify: change `process.env.NODE_ENV` to `"production"`
72
- var rawCode = testMinificationUsedDCE
72
+ const rawCode = testMinificationUsedDCE
73
73
. toString ( )
74
74
. replace ( / p r o c e s s \. e n v \. N O D E _ E N V / g, '"production"' ) ;
75
- var code = { 'file.js' : rawCode } ;
76
- var options = { fromString : true , parse : { dead_code : true } } ;
77
- var result = UglifyJs . minify ( code , options ) ;
75
+ const code = { 'file.js' : rawCode } ;
76
+ const options = { fromString : true , parse : { dead_code : true } } ;
77
+ const result = UglifyJs . minify ( code , options ) ;
78
78
const minifiedWithNoDCE = ( ) => eval ( '(' + result . code + ')()' ) ;
79
79
expect ( ( ) => {
80
80
minifiedWithNoDCE ( ) ;
@@ -85,11 +85,11 @@ describe('in the production environment', () => {
85
85
86
86
describe ( 'when minified first with *unsuccessful* DCE, then envified' , ( ) => {
87
87
it ( 'should throw' , ( ) => {
88
- var code = { 'file.js' : testMinificationUsedDCE . toString ( ) } ;
89
- var options = { fromString : true , parse : { dead_code : true } } ;
90
- var result = UglifyJs . minify ( code , options ) ;
88
+ const code = { 'file.js' : testMinificationUsedDCE . toString ( ) } ;
89
+ const options = { fromString : true , parse : { dead_code : true } } ;
90
+ const result = UglifyJs . minify ( code , options ) ;
91
91
// late envify: change `process.env.NODE_ENV` to `"production"`
92
- var resultCode = result . code . replace (
92
+ const resultCode = result . code . replace (
93
93
/ p r o c e s s \. e n v \. N O D E _ E N V / g,
94
94
'"production"' ,
95
95
) ;
0 commit comments