Open mantou132 opened 7 years ago
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 ?
@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?
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
I am pretty sure this related to
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
Sorry but ^6.* will get you latest version of autoprefixer. Uninstalling cssnext and reinstalling it will not make this bug a thing.
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.
TypeError: Cannot read property 'stats' of undefined at /home/upyun/impress-website/node_modules/caniuse-api/dist/index.js:78:16