@@ -1046,19 +1046,25 @@ function publish( pkg, clbk ) {
1046
1046
deps . push ( '@stdlib/error-tools-fmtprodmsg' ) ;
1047
1047
}
1048
1048
1049
- // Transform error messages and save files to `dist` subdirectory:
1050
- command = 'mkdir dist' ;
1051
- shell ( command , opts ) ;
1052
- command = [
1053
- 'npx esbuild lib/index.js --bundle --format=cjs --target=es5' ,
1054
- '--sourcemap --minify --platform=node --outfile=dist/index.js' ,
1055
- '--external:' + deps . join ( ' --external:' )
1056
- ] . join ( ' ' ) ;
1057
- debug ( 'Executing command: %s' , command ) ;
1058
- shell ( command , opts ) ;
1059
- command = 'rm -rf tmp' ;
1060
- shell ( command , opts ) ;
1049
+ // Minify, bundle, and save files to `dist` subdirectory:
1050
+ try {
1051
+ command = 'mkdir dist' ;
1052
+ shell ( command , opts ) ;
1053
+ command = [
1054
+ 'npx esbuild lib/index.js --bundle --format=cjs --target=es5' ,
1055
+ '--sourcemap --minify --platform=node --outfile=dist/index.js' ,
1056
+ '--external:' + deps . join ( ' --external:' )
1057
+ ] . join ( ' ' ) ;
1058
+ debug ( 'Executing command: %s' , command ) ;
1059
+ shell ( command , opts ) ;
1060
+ } catch ( error ) {
1061
+ debug ( 'Encountered an error when attempting to bundle the package: %s' , error . message ) ;
1061
1062
1063
+ // Copy all source files to the `dist` subdirectory to proceed without bundling:
1064
+ command = 'cp -r lib/* dist' ;
1065
+ shell ( command , opts ) ;
1066
+ }
1067
+ // Apply code transformations:
1062
1068
jscodeshift = join ( rootDir ( ) , 'node_modules' , '.bin' , 'jscodeshift' ) ;
1063
1069
command = 'STDLIB_INPUT_SOURCE_MAP=\'./dist/index.js.map\' STDLIB_PKG=\'@stdlib/' + distPkg + '\' ' + jscodeshift + ' ./dist/index.js -t ' + join ( __dirname , 'transform.js' ) ;
1064
1070
debug ( 'Executing command: %s' , command ) ;
0 commit comments