-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make brotli-size optional by styfle #220
base: master
Are you sure you want to change the base?
Changes from 11 commits
d783078
0387ea4
c9165fa
52e72bd
589833a
5e89752
088e8f7
eecc3f9
1294f58
95f67ef
4b3654c
6653d73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const { warn } = require('prettycli') | ||
const gzip = require('gzip-size') | ||
const brotli = require('brotli-size') | ||
let brotli | ||
|
||
const getCompressedSize = (data, compression = 'gzip') => { | ||
let size | ||
|
@@ -8,6 +9,12 @@ const getCompressedSize = (data, compression = 'gzip') => { | |
size = gzip.sync(data) | ||
break | ||
case 'brotli': | ||
try { | ||
brotli = require('brotli-size') | ||
} catch (e) { | ||
throw new Error(`Missing optional dependency. Install it with: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you should throw an error here. I would say, the travis build should pass because it only invokes bundlesize and the bundlesize build status should error out with the right message. This should help: https://github.com/siddharthkp/bundlesize/blob/master/src/build.js#L32 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. Do you want to make the change on this branch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, this branch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think siddharthkp was saying that you can make bundlesize exit with non-zero, so travis doesn't fail, but report bundlesize failure status to GitHub In an offshoot version of bundlesize, we've elected to fail the build There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest the way to fail the bundlesize build would be the companion error method: https://github.com/siddharthkp/bundlesize/blob/master/src/build.js#L32 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @siddharthkp Would you like to implement this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind, it might take me some time to get to this though 😅 |
||
npm install --save brotli-size`) | ||
} | ||
size = brotli.sync(data) | ||
break | ||
case 'none': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a CI build error coming due to this line:
Please remove this line.