@@ -4,33 +4,32 @@ const path = require('path');
44const _ = require ( 'underscore' ) ;
55const gzip = require ( 'gzip-size' ) ;
66
7- const publishDateString = ( new Date ( ) ) . toISOString ( ) ;
7+ const publishDateString = new Date ( ) . toISOString ( ) ;
88const config = getJSON ( path . resolve ( __dirname , '../package.json' ) ) ;
99const paths = {
1010 entry : path . resolve ( __dirname , '../src/two.js' ) ,
1111 umd : path . resolve ( __dirname , '../build/two.js' ) ,
1212 esm : path . resolve ( __dirname , '../build/two.module.js' ) ,
1313 min : path . resolve ( __dirname , '../build/two.min.js' ) ,
14- license : path . resolve ( __dirname , '../LICENSE' )
14+ license : path . resolve ( __dirname , '../LICENSE' ) ,
1515} ;
1616
1717async function buildModules ( ) {
18-
1918 esbuild . buildSync ( {
2019 entryPoints : [ paths . entry ] ,
2120 outfile : paths . umd ,
2221 bundle : true ,
2322 minify : false ,
2423 format : 'iife' ,
25- globalName : 'Two'
24+ globalName : 'Two' ,
2625 } ) ;
2726
2827 esbuild . buildSync ( {
2928 entryPoints : [ paths . entry ] ,
3029 outfile : paths . esm ,
3130 bundle : true ,
3231 target : 'es6' ,
33- format : 'esm'
32+ format : 'esm' ,
3433 } ) ;
3534
3635 esbuild . buildSync ( {
@@ -39,10 +38,12 @@ async function buildModules() {
3938 bundle : true ,
4039 minify : true ,
4140 format : 'iife' ,
42- globalName : 'Two'
41+ globalName : 'Two' ,
4342 } ) ;
4443
45- const license = await fs . promises . readFile ( paths . license , { encoding : 'utf-8' } ) ;
44+ const license = await fs . promises . readFile ( paths . license , {
45+ encoding : 'utf-8' ,
46+ } ) ;
4647 const licenseComment = [ '/*' , license . trim ( ) , '*/' ] . join ( '\n' ) ;
4748
4849 const umdOutput = await fs . promises . readFile ( paths . umd ) ;
@@ -52,19 +53,27 @@ async function buildModules() {
5253 const moduleExports = `(function(){if(typeof exports==='object'&&typeof module!=='undefined'){module.exports=Two}})()` ;
5354
5455 return Promise . all ( [
55- fs . promises . writeFile ( paths . umd , [ licenseComment , template ( umdOutput , true ) , moduleExports ] . join ( '\n' ) ) ,
56- fs . promises . writeFile ( paths . esm , [ licenseComment , template ( esmOutput , false ) ] . join ( '\n' ) ) ,
57- fs . promises . writeFile ( paths . min , [ licenseComment , template ( minOutput , true ) , moduleExports ] . join ( '\n' ) )
56+ fs . promises . writeFile (
57+ paths . umd ,
58+ [ licenseComment , template ( umdOutput , true ) , moduleExports ] . join ( '\n' )
59+ ) ,
60+ fs . promises . writeFile (
61+ paths . esm ,
62+ [ licenseComment , template ( esmOutput , false ) ] . join ( '\n' )
63+ ) ,
64+ fs . promises . writeFile (
65+ paths . min ,
66+ [ licenseComment , template ( minOutput , true ) , moduleExports ] . join ( '\n' )
67+ ) ,
5868 ] ) ;
59-
6069}
6170
6271function template ( buffer , isExposed ) {
6372 const code = buffer . toString ( ) ;
6473 const generate = _ . template ( code ) ;
6574 let result = generate ( {
6675 version : config . version ,
67- publishDate : publishDateString
76+ publishDate : publishDateString ,
6877 } ) ;
6978 if ( isExposed ) {
7079 result = result . replace ( / \} \) \( \) ; / , '})().default;' ) ;
@@ -73,7 +82,6 @@ function template(buffer, isExposed) {
7382}
7483
7584function publishModule ( ) {
76-
7785 let size ;
7886 const result = { } ;
7987
@@ -87,7 +95,6 @@ function publishModule() {
8795 const outputPath = path . resolve ( __dirname , './file-sizes.json' ) ;
8896
8997 return fs . promises . writeFile ( outputPath , contents ) ;
90-
9198}
9299
93100function getFileSize ( filepath ) {
@@ -106,7 +113,6 @@ function formatFileSize(v) {
106113}
107114
108115async function build ( ) {
109-
110116 let startTime , elapsed ;
111117
112118 startTime = Date . now ( ) ;
@@ -124,8 +130,11 @@ async function build() {
124130 } catch ( error ) {
125131 console . log ( error ) ;
126132 }
127- console . log ( 'Published additional statistics to wiki:' , elapsed / 1000 , 'seconds' ) ;
128-
133+ console . log (
134+ 'Published additional statistics to wiki:' ,
135+ elapsed / 1000 ,
136+ 'seconds'
137+ ) ;
129138}
130139
131140function getJSON ( filepath ) {
0 commit comments