@@ -10,29 +10,21 @@ var OPTIONAL_COMMA = ',?';
1010
1111// one line string with or without trailing comma
1212function makeStringRegex ( attr ) {
13- return makeRegex (
14- WHITESPACE_BEFORE + attr + ': \'.*\'' + OPTIONAL_COMMA
15- ) ;
13+ return makeRegex ( WHITESPACE_BEFORE + attr + ": '.*'" + OPTIONAL_COMMA ) ;
1614}
1715
1816// joined array of strings with or without trailing comma
1917function makeJoinedArrayRegex ( attr ) {
20- return makeRegex (
21- WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA
22- ) ;
18+ return makeRegex ( WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA ) ;
2319}
2420
2521// array with or without trailing comma
2622function makeArrayRegex ( attr ) {
27- return makeRegex (
28- WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA
29- ) ;
23+ return makeRegex ( WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA ) ;
3024}
3125
3226function makeRegex ( regexStr ) {
33- return (
34- new RegExp ( regexStr , 'g' )
35- ) ;
27+ return new RegExp ( regexStr , 'g' ) ;
3628}
3729
3830const allRegexes = [
@@ -44,15 +36,18 @@ const allRegexes = [
4436 makeStringRegex ( 'hrName' )
4537] ;
4638
47- var esbuildPluginStripMeta = {
39+ const esbuildPluginStripMeta = {
4840 name : 'strip-meta-attributes' ,
4941 setup ( build ) {
5042 const loader = 'js' ;
51- build . onLoad ( { filter : / \. j s $ / } , async file => ( {
52- contents : await fs . promises . readFile ( file . path , 'utf-8' ) . then ( c => {
53- allRegexes . forEach ( r => { c = c . replace ( r , '' ) ; } ) ;
43+ build . onLoad ( { filter : / \. j s $ / } , async ( file ) => ( {
44+ contents : await fs . promises . readFile ( file . path , 'utf-8' ) . then ( ( c ) => {
45+ allRegexes . forEach ( ( r ) => {
46+ c = c . replace ( r , '' ) ;
47+ } ) ;
5448 return c ;
55- } ) , loader
49+ } ) ,
50+ loader
5651 } ) ) ;
5752 }
5853} ;
0 commit comments