@@ -35,22 +35,32 @@ function makeRegex(regexStr) {
3535 ) ;
3636}
3737
38- module . exports = function ( ) {
39- var allChunks = [ ] ;
40- return through ( function ( chunk , enc , next ) {
41- allChunks . push ( chunk ) ;
42- next ( ) ;
43- } , function ( done ) {
44- var str = Buffer . concat ( allChunks ) . toString ( 'utf-8' ) ;
45- this . push (
46- str
47- . replace ( makeStringRegex ( 'description' ) , '' )
48- . replace ( makeJoinedArrayRegex ( 'description' ) , '' )
49- . replace ( makeArrayRegex ( 'requiredOpts' ) , '' )
50- . replace ( makeArrayRegex ( 'otherOpts' ) , '' )
51- . replace ( makeStringRegex ( 'role' ) , '' )
52- . replace ( makeStringRegex ( 'hrName' ) , '' )
53- ) ;
54- done ( ) ;
55- } ) ;
38+ module . exports = path => {
39+ const allChunks = [ ] ;
40+ return through (
41+ ( chunk , _ , next ) => {
42+ allChunks . push ( chunk ) ;
43+ next ( ) ;
44+ } ,
45+ function ( done ) {
46+ const str = Buffer . concat ( allChunks ) . toString ( 'utf-8' ) ;
47+
48+ // Return JSON as stringified JSON so that ESBuild will handle transformation
49+ if ( path . toLowerCase ( ) . endsWith ( '.json' ) ) {
50+ this . push ( JSON . stringify ( str ) ) ;
51+ done ( ) ;
52+ }
53+
54+ this . push (
55+ str
56+ . replace ( makeStringRegex ( 'description' ) , '' )
57+ . replace ( makeJoinedArrayRegex ( 'description' ) , '' )
58+ . replace ( makeArrayRegex ( 'requiredOpts' ) , '' )
59+ . replace ( makeArrayRegex ( 'otherOpts' ) , '' )
60+ . replace ( makeStringRegex ( 'role' ) , '' )
61+ . replace ( makeStringRegex ( 'hrName' ) , '' )
62+ ) ;
63+ done ( ) ;
64+ }
65+ ) ;
5666} ;
0 commit comments