@@ -25,43 +25,46 @@ export interface PackageSizeReportOutput {
25
25
26
26
export const getPackageSizeReportRunner =
27
27
( options : PackageSizeReportOptions ) => async ( context : ListrContext , task : ListrTaskWrapper < ListrContext , any > ) => {
28
- task . output = "preparing..." ;
29
- const projectDir = join ( options . tmpDir , options . packageName . replace ( "/" , "_" ) ) ;
30
- await fsPromise . rmdir ( projectDir , { recursive : true } ) ;
31
- await fsPromise . mkdir ( projectDir ) ;
32
- const entryPoint = join ( projectDir , "index.js" ) ;
33
- const bundlersContext = { ...options , entryPoint, projectDir } ;
28
+ try {
29
+ task . output = "preparing..." ;
30
+ const projectDir = join ( options . tmpDir , options . packageName . replace ( "/" , "_" ) ) ;
31
+ await fsPromise . mkdir ( projectDir ) ;
32
+ const entryPoint = join ( projectDir , "index.js" ) ;
33
+ const bundlersContext = { ...options , entryPoint, projectDir } ;
34
34
35
- task . output = "generating project and installing dependencies" ;
36
- await generateProject ( projectDir , options ) ;
35
+ task . output = "generating project and installing dependencies" ;
36
+ await generateProject ( projectDir , options ) ;
37
37
38
- task . output = "calculating npm size" ;
39
- const npmSizeResult = calculateNpmSize ( projectDir , options . packageName ) ;
38
+ task . output = "calculating npm size" ;
39
+ const npmSizeResult = calculateNpmSize ( projectDir , options . packageName ) ;
40
40
41
- const skipBundlerTests = bundlersContext . packageContext . skipBundlerTests ;
41
+ const skipBundlerTests = bundlersContext . packageContext . skipBundlerTests ;
42
42
43
- task . output = "calculating webpack 5 full bundle size" ;
44
- const webpackSize = skipBundlerTests ? undefined : await getWebpackSize ( bundlersContext ) ;
43
+ task . output = "calculating webpack 5 full bundle size" ;
44
+ const webpackSize = skipBundlerTests ? undefined : await getWebpackSize ( bundlersContext ) ;
45
45
46
- task . output = "calculating rollup full bundle size" ;
47
- const rollupSize = skipBundlerTests ? undefined : await getRollupSize ( bundlersContext ) ;
46
+ task . output = "calculating rollup full bundle size" ;
47
+ const rollupSize = skipBundlerTests ? undefined : await getRollupSize ( bundlersContext ) ;
48
48
49
- task . output = "calculating esbuild full bundle size" ;
50
- const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize ( bundlersContext ) ;
49
+ task . output = "calculating esbuild full bundle size" ;
50
+ const esbuildSize = skipBundlerTests ? undefined : await getEsbuildSize ( bundlersContext ) ;
51
51
52
- task . output = "output results" ;
53
- const packageVersion = JSON . parse (
54
- await fsPromise . readFile (
55
- join ( options . workspacePackages . filter ( ( pkg ) => pkg . name === options . packageName ) [ 0 ] . location , "package.json" ) ,
56
- "utf8"
57
- )
58
- ) . version ;
59
- options . output . push ( {
60
- name : options . packageName ,
61
- version : packageVersion ,
62
- ...npmSizeResult ,
63
- webpackSize,
64
- esbuildSize,
65
- rollupSize,
66
- } ) ;
52
+ task . output = "output results" ;
53
+ const packageVersion = JSON . parse (
54
+ await fsPromise . readFile (
55
+ join ( options . workspacePackages . filter ( ( pkg ) => pkg . name === options . packageName ) [ 0 ] . location , "package.json" ) ,
56
+ "utf8"
57
+ )
58
+ ) . version ;
59
+ options . output . push ( {
60
+ name : options . packageName ,
61
+ version : packageVersion ,
62
+ ...npmSizeResult ,
63
+ webpackSize,
64
+ esbuildSize,
65
+ rollupSize,
66
+ } ) ;
67
+ } catch ( e ) {
68
+ e . message = `[${ options . packageName } ]` + e . message ;
69
+ }
67
70
} ;
0 commit comments