bundlesize icon indicating copy to clipboard operation
bundlesize copied to clipboard

Make brotli-size optional by styfle

Open siddharthkp opened this issue 6 years ago • 14 comments

Description

  1. Remove brotli-size from dependencies
  2. Add try-catch around require('brotli-size')
  3. Warn if using brotli option but missing brotli-size

Motivation and Context

It turns out the brotli-size (#194) is quite big and doesn't install very nicely on Windows.

See the following issues:

Fixes #202 Fixes #213

siddharthkp avatar May 02 '18 11:05 siddharthkp

Eventually, we might even get brotli support in Node Core. See https://github.com/nodejs/node/pull/20458

styfle avatar May 02 '18 15:05 styfle

@siddharthkp: I currently have downgraded bundlesize to 0.15. This should be squashed and merged ASAP.

Node.js 10.0.0 is out for quite some time.

XhmikosR avatar May 02 '18 22:05 XhmikosR

@styfle Do you think the build should error out instead of passing if brotli-size is not installed?

(Check out the result of the build)

I have added you as a collaborator so you can commit directly to this branch (instead of a fork)

siddharthkp avatar May 03 '18 10:05 siddharthkp

@siddharthkp That's a good point since they specifically said they wanted to use brotli. Maybe the correct thing to do is fail fast and just throw instead of a warning:

throw new Error('Missing optional dependency. Install it with: npm install --save brotli-size')

Thoughts?

styfle avatar May 03 '18 12:05 styfle

I agree with you guys Requesting to check the size based on brotli compression and getting an OK return code seems wrong

eseliger avatar May 03 '18 12:05 eseliger

@siddharthkp Ok the build is failing as expected now that there is a throw.

How should we fix the tests so that brotli-size is installed? Add to devDependencies?

styfle avatar May 03 '18 15:05 styfle

how about running it once and checking for failure and then running npm i brotli-size and running again and check for success?

eseliger avatar May 03 '18 15:05 eseliger

@eseliger That was my first thought but I don't see a test harness so I'm not sure how to assert that and error was thrown with the current test commands.

styfle avatar May 03 '18 15:05 styfle

hmm maybe some script like this will work

bundlezise

if [ $? -eq 0 ]
then
  echo "Should have failed"
  exit 1
else
  exit 0
fi

eseliger avatar May 03 '18 15:05 eseliger

Hey, guys. Any news? I'm still using a downgraded version due to no node.js 10.x support.

XhmikosR avatar Jul 04 '18 21:07 XhmikosR

I think @siddharthkp still wanted to make a change here.

Another related issue worth pursuing is to get brotli support in Node Core. Put a 👍 on this issue: https://github.com/nodejs/node/issues/18964

styfle avatar Jul 05 '18 14:07 styfle

@siddharthkp: friendly ping!

XhmikosR avatar Sep 10 '18 19:09 XhmikosR

Is the package abandoned @siddharthkp ?

XhmikosR avatar Nov 20 '18 10:11 XhmikosR

FYI, brotli support landed in Node core and should be in the next release.

styfle avatar Jan 06 '19 15:01 styfle