This repository was archived by the owner on May 16, 2024. It is now read-only.
File tree 3 files changed +10
-7
lines changed
3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
var ejs = require ( 'ejs' ) ,
2
- uglify = require ( 'uglify-js' ) ,
2
+ UglifyJS = require ( 'uglify-js' ) ,
3
3
utils = require ( 'loader-utils' ) ,
4
4
path = require ( 'path' ) ;
5
5
@@ -22,8 +22,9 @@ module.exports = function (source) {
22
22
23
23
// Beautify javascript code
24
24
if ( ! this . minimize && opts . beautify !== false ) {
25
- var ast = uglify . parser . parse ( template . toString ( ) ) ;
26
- template = uglify . uglify . gen_code ( ast , { beautify : true } ) ;
25
+ var ast = UglifyJS . parse ( template . toString ( ) ) ;
26
+ ast . figure_out_scope ( ) ;
27
+ template = ast . print_to_string ( { beautify : true } ) ;
27
28
}
28
29
29
30
return 'module.exports = ' + template ;
Original file line number Diff line number Diff line change 25
25
"dependencies" : {
26
26
"ejs" : " ^2.0.0" ,
27
27
"loader-utils" : " ^0.2.7" ,
28
- "uglify-js" : " ~1.3.4 "
28
+ "uglify-js" : " ~2.6.1 "
29
29
},
30
30
"devDependencies" : {
31
31
"node-libs-browser" : " ^0.5.0" ,
Original file line number Diff line number Diff line change
1
+ const assert = require ( 'assert' ) ;
2
+
1
3
var tpl = require ( "./template.ejs" ) ;
2
- console . log ( tpl ( { noun : "World" } ) ) ;
4
+ assert . equal ( tpl ( { noun : "World" } ) , 'Hello, World!' ) ;
3
5
4
6
var tpl2 = require ( "!!../?delimiter=?!./template2.ejs" ) ;
5
- console . log ( tpl2 ( { hobbies : [ "food" , "code" ] } ) . trimRight ( ) ) ;
7
+ assert . equal ( tpl2 ( { hobbies : [ "food" , "code" ] } ) . trimRight ( ) , " I like food.\n I like code." ) ;
6
8
7
9
var tpl3 = require ( "./subdir/parent.ejs" ) ;
8
- console . log ( tpl3 ( { foo : "foo" } ) ) ;
10
+ assert . equal ( tpl3 ( { foo : "foo" } ) , "parent: child: foo\n\n" ) ;
You can’t perform that action at this time.
0 commit comments