File tree 4 files changed +27
-8
lines changed
4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -11,22 +11,30 @@ const yargs = require('yargs')
11
11
type : 'string' ,
12
12
description : 'Source Map File'
13
13
} )
14
- . option ( 'a' , {
15
- type : 'boolean' ,
16
- description : 'Exports amd style (require.js)' ,
17
- alias : 'amd'
14
+ . option ( 'esm' , {
15
+ type : 'string' ,
16
+ description :
17
+ 'Exports ECMAScript module style, path to Handlebars module (eg. "handlebars/lib/handlebars")' ,
18
+ default : null
18
19
} )
19
20
. option ( 'c' , {
20
21
type : 'string' ,
21
22
description : 'Exports CommonJS style, path to Handlebars module' ,
22
23
alias : 'commonjs' ,
23
24
default : null
24
25
} )
26
+ . option ( 'a' , {
27
+ type : 'boolean' ,
28
+ description : 'Exports AMD style (require.js)' ,
29
+ alias : 'amd' ,
30
+ deprecated : true
31
+ } )
25
32
. option ( 'h' , {
26
33
type : 'string' ,
27
- description : 'Path to handlebar.js (only valid for amd -style)' ,
34
+ description : 'Path to handlebar.js (only valid for AMD -style)' ,
28
35
alias : 'handlebarPath' ,
29
- default : ''
36
+ default : '' ,
37
+ deprecated : true
30
38
} )
31
39
. option ( 'k' , {
32
40
type : 'string' ,
Original file line number Diff line number Diff line change @@ -206,6 +206,8 @@ module.exports.cli = function(opts) {
206
206
) ;
207
207
} else if ( opts . commonjs ) {
208
208
output . add ( 'var Handlebars = require("' + opts . commonjs + '");' ) ;
209
+ } else if ( opts . esm ) {
210
+ output . add ( `import handlebars from "${ opts . esm } ";` ) ;
209
211
} else {
210
212
output . add ( '(function() {\n' ) ;
211
213
}
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ Options:
5
5
--help Outputs this message [boolean]
6
6
-f, --output Output File [string]
7
7
--map Source Map File [string]
8
- -a, --amd Exports amd style (require.js) [boolean]
8
+ --esm Exports ECMAScript module style, path to Handlebars module (eg. "handlebars/lib/handlebars")
9
+ [string] [default: null]
9
10
-c, --commonjs Exports CommonJS style, path to Handlebars module [string] [default: null]
10
- -h, --handlebarPath Path to handlebar.js (only valid for amd-style) [string] [default: ""]
11
+ -a, --amd Exports AMD style (require.js) [deprecated] [boolean]
12
+ -h, --handlebarPath Path to handlebar.js (only valid for AMD-style) [deprecated] [string] [default: ""]
11
13
-k, --known Known helpers [string]
12
14
-o, --knownOnly Known helpers only [boolean]
13
15
-m, --min Minimize output [boolean]
Original file line number Diff line number Diff line change @@ -197,6 +197,13 @@ describe('precompiler', function() {
197
197
equal ( / r e t u r n H a n d l e b a r s \. p a r t i a l s \[ / . test ( log ) , false ) ;
198
198
equal ( / t e m p l a t e \( a m d \) / . test ( log ) , true ) ;
199
199
} ) ;
200
+ it ( 'should output es module templates' , function ( ) {
201
+ Handlebars . precompile = function ( ) {
202
+ return 'esm' ;
203
+ } ;
204
+ Precompiler . cli ( { templates : [ emptyTemplate ] , esm : true } ) ;
205
+ equal ( / t e m p l a t e \( e s m \) / . test ( log ) , true ) ;
206
+ } ) ;
200
207
it ( 'should output commonjs templates' , function ( ) {
201
208
Handlebars . precompile = function ( ) {
202
209
return 'commonjs' ;
You can’t perform that action at this time.
0 commit comments