caniuse-api icon indicating copy to clipboard operation
caniuse-api copied to clipboard

`caniuse.isSupported('transform-box', 'ie 10') ` an error occurred

Open mantou132 opened this issue 8 years ago • 6 comments

TypeError: Cannot read property 'stats' of undefined at /home/upyun/impress-website/node_modules/caniuse-api/dist/index.js:78:16

mantou132 avatar Dec 28 '16 10:12 mantou132

Looks like a bug that could be prevented... Maybe some data source have a different format that what we expect. Mind taking a look for a PR @mantou132 ?

MoOx avatar Jan 02 '17 08:01 MoOx

@Nyalab it seems here https://github.com/Nyalab/caniuse-api/blob/ca59a968f4f96963c8a60cfd188f0d885b8320fa/src/index.js#L52 data are not verified (and can be undefined). This tests approve this https://github.com/Nyalab/caniuse-api/blob/ca59a968f4f96963c8a60cfd188f0d885b8320fa/test/index.js#L60

But caniuse.isSupported('transform-box', 'ie 10') does not looks like a silly thing. Thoughts?

MoOx avatar Feb 01 '17 07:02 MoOx

I ran into the same issue with another feature: css-rrggbbaa

Would be awesome if we could just display a warning when stats are not present, since simply the caniuse-db is to old in my dependency chain.

The source of the issue I guess is that postcss-cssnext has a pretty "old" autoprefixer version. --> https://github.com/MoOx/postcss-cssnext/blob/master/package.json#L24

axe312ger avatar Mar 31 '17 23:03 axe312ger

I am pretty sure this related to

  • https://github.com/MoOx/postcss-cssnext/issues/357
  • and might be fixed via https://github.com/MoOx/postcss-cssnext/pull/359 :)

Edit: Updating autoprefixer in a fork of postcss-cssnext also fixed the issie for me. Also making https://github.com/Nyalab/caniuse-api/blob/ca59a968f4f96963c8a60cfd188f0d885b8320fa/src/index.js#L52 throw a warning when the feature is missing the stats

axe312ger avatar Mar 31 '17 23:03 axe312ger

Sorry but ^6.* will get you latest version of autoprefixer. Uninstalling cssnext and reinstalling it will not make this bug a thing.

MoOx avatar Apr 01 '17 05:04 MoOx

Whoot yeah, you are totally right.

I deleted node_modules multiple times, but that didn't help. My issue was, that I was using yarn to lock down my dependencies. Thats what caused the old caniuse-db to be present on my system.

Might be worth a info in the readme, that postcss-cssnext relies on caniuse-db/data.json and with locked dependencies with shrinkwrap/yarn you may get errors since your database is out of date.

I still think showing a warning instead of provoking an error would be the better behaviour for caniuse-api. Locked down dependencies are not that super special and I will not be the last person running into this.

axe312ger avatar Apr 01 '17 10:04 axe312ger