Jss: Replace warning with smaller version

Created on 5 Nov 2018  Â·  27Comments  Â·  Source: cssinjs/jss

warning package is published as a strong mirror of fbjs thing. Maintainer even do not want to support esm. This requires to transpile more packages from commonjs when bundling app with rollup.

There is a smaller alternative https://github.com/alexreardon/tiny-warning. It doesn't allow passing arguments and interpolation should be used instead. It's distributed as esm and has flow types out of the box.

react-router already migrated to it.
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/package.json#L50-L51

enhancement

Most helpful comment

Let’s migrate then?

All 27 comments

We still do support IE 9 same as react does, IE9 doesn't implement console unless devtools are open and this package has no fallback. So to do this we need to officially deprecate IE9 or add a fallback to tiny-warning.

I am curious if react-router maintainers know it.

/cc @alexreardon

Do we need to support ie9? IE 9 has 0.13% usage globally

I think we could configure our babel setup to transpile for browsers who have a usage bigger than 0.5%

I personally don't, but I am not sure what the majority does.

Hey, guys. ie9 is dead browser. I think major release is a good reason to stop supporting it.
https://www.microsoft.com/en-us/WindowsForBusiness/End-of-IE-support

So we could drop ie9 and ie10, correct?

Also, we should setup babel to compile only for our supported browsers.

That announcement from microsoft just means they don't ship any updates. Developers community will support or not support a browser based on usage statistics and the question is where to make a cut.

I am happy to drop IE9, not sure regarding 10.

tiny-warning now has IE9 support. We may migrate safely.

cool, thanks for the heads up

I wonder how it is loggin an error in IE9, because the error is thrown inside of a catch block, which does nothing ... I guess I am missing something

Here's the reason of swallowed error. But it's dropped for production, so don't worry.
https://github.com/facebook/react/issues/4216

Chrome allows you to break on caught errors. That's why that try/catch is there. So that you can optionally toggle the breakpoint on and off.

That was the thing I missed

Let’s migrate then?

PR is merged

The tiny wording is misleading 😆

capture d ecran 2018-12-31 a 19 59 38


capture d ecran 2018-12-31 a 19 59 44

A good read: https://github.com/ReactTraining/react-router/pull/6444/files#diff-fd7fba197b7940dbbdbb5c3c64cd5d36R5.

It's esm and has less code. So yes, it's tiny. The size will be smaller in user bundle.

I wonder why bundlephobia shows its bigger

Perhaps uglify version used by service is not able to inline process.env.NODE_ENV
https://unpkg.com/[email protected]/dist/tiny-warning.esm.js

How do you explain the bundle size increase in https://github.com/ReactTraining/react-router/pull/6444/files and in https://github.com/cssinjs/jss/pull/953/files?
I start to think that warning is better suited. In production, the module has close to zero overhead, it's pruned with the process.env.NODE_ENV branch.

@oliviertassinari It was esm bundle. The difference is tiny- word or something.

warning package is not standard. It's an unmaintained mirror of facebook internals which are not used even in react.

And it's cjs. warning package maintainer is not interested in any changes. So tiny-warning is the best here.

After 254473f8ed93c2f1f634241eeae3ad0d5598dca2, the bundle size seems to be smaller with tiny-warning than with warning :).

Lol

On Tue, Jan 1, 2019, 14:28 Olivier Tassinari <[email protected]
wrote:

After 254473f
https://github.com/cssinjs/jss/commit/254473f8ed93c2f1f634241eeae3ad0d5598dca2,
the bundle size seems to be smaller with tiny-warning than with warning :).

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/cssinjs/jss/issues/913#issuecomment-450725991, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AADOWPqFjU0gCdlqfW7jXN-yrHVbwTBaks5u-1RZgaJpZM4YN6oF
.

@kof Using warning & tiny-warning at the same time, doesn't help :).

Yep

On Tue, Jan 1, 2019, 14:54 Olivier Tassinari <[email protected]
wrote:

@kof https://github.com/kof Using warning & tiny-warning at the same
time, doesn't help :).

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/cssinjs/jss/issues/913#issuecomment-450727189, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AADOWES1pSq0zjuE__TNTvVBcGlD1e_5ks5u-1pzgaJpZM4YN6oF
.

Was this page helpful?
0 / 5 - 0 ratings