ajv icon indicating copy to clipboard operation
ajv copied to clipboard

Replace `uri-js` with `fast-uri`

Open vixalien opened this issue 1 year ago • 12 comments

What issue does this pull request resolve?

This PR fixes issues #2350 and #2343. It removes the (deep) dependency on punycode, a deprecated module.

What changes did you make?

I replaced the default uriResolver to fast-uri instead of uri-js.

Is there anything that requires more attention while reviewing?

This PR supersedes #2377.

It is also worth considering using the web API URL which is defined in URL Living Standard instead of URI which is defined in RFC 3986 and is less prevalent and can resolve the issue raised by @jasoniangreen in the above linked PR:

...I have been speaking to @epoberezkin and he wants me to explore removing uri-js. [..] there is just an open question around browser support. I will update you when I have more.

We can use the native URL API as it is supported with node 10+ and all major browsers and it has 97.68% caniuse score while URI is not standardized afaict.

Thanks!

TODO:

vixalien avatar Apr 13 '24 20:04 vixalien

ajv is a major contributor to the [DEP0040] DeprecationWarning: The punycode module is deprecated issue that is popping up everywhere (since it's used in eslint). Please fix this.

Less dependencies. Better performance. This is the way!

mbtools avatar Apr 27 '24 17:04 mbtools

I would be very happy if there were an initial review or at least a comment from the AJV team.

vixalien avatar Apr 27 '24 23:04 vixalien

how progress of this?

tianyingchun avatar Apr 29 '24 01:04 tianyingchun

@epoberezkin

tianyingchun avatar Apr 29 '24 01:04 tianyingchun

how progress of this?

tianyingchun avatar May 09 '24 22:05 tianyingchun

No feedback from maintainers, can't move forward :(

vixalien avatar May 09 '24 23:05 vixalien

I see that there is still a version of this library released recently,

tianyingchun avatar May 10 '24 00:05 tianyingchun

Yes, other pull requests are getting merged and I believe this one is just ignored.

Some feedback - any feedback - from the maintainers would be appreciated

vixalien avatar May 10 '24 16:05 vixalien

Hi all, I will try and get some guidance from @epoberezkin on this one. Sorry I missed your activity here.

jasoniangreen avatar May 14 '24 22:05 jasoniangreen

Haha, merge and release a version as soon as possible 😁

tianyingchun avatar May 14 '24 22:05 tianyingchun

Ready

vixalien avatar May 16 '24 22:05 vixalien

Update: After discussing with @epoberezkin, we want to get one more minor release out with some bug fixes and then will release this change as 9.0.0.

jasoniangreen avatar May 22 '24 21:05 jasoniangreen

Update: After discussing with @epoberezkin, we want to get one more minor release out with some bug fixes and then will release this change as 9.0.0.

Actually after discussing with EP and understanding the swap, we've decided this can go out as a minor release. I'm going to give it all one last check and do that next.

jasoniangreen avatar May 31 '24 09:05 jasoniangreen

Hmm, something broke the build to master, I think it's related to a bug in the get_contributors script. Investigating.

jasoniangreen avatar Jun 01 '24 09:06 jasoniangreen

Well I did just publish 8.15.0 with fast-uri but it's failing to build browser bundles because for some reason fast-uri has this line require('node:url')? I have no idea why it's not just require('url') but I think I'll have to roll forward with a revert of this change. Will discuss with @epoberezkin.

jasoniangreen avatar Jun 03 '24 20:06 jasoniangreen

FYI fast-uri is not officially said browser-incompatible module itself, so it's no wonder it uses node: prefix.

Webpack error message

Module build failed: UnhandledSchemeError: Reading from "node:url" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

yuki-js avatar Jun 04 '24 02:06 yuki-js

Related: https://github.com/fastify/fast-uri/issues/21

voxpelli avatar Jun 04 '24 04:06 voxpelli

We are having the same issue with 8.15.0. Since pulling this package our builds have been failing with the following error:

Module build failed: UnhandledSchemeError: Reading from "node:url"

fcma-bbientz avatar Jun 04 '24 18:06 fcma-bbientz

In package.json, we had "^18.12.0" and builds worked yesterday, failed today. Finally tracked it down to this update from 8.14.0 to 8.15.0

fcma-bbientz avatar Jun 04 '24 18:06 fcma-bbientz

See https://github.com/ajv-validator/ajv/issues/2446

silverwind avatar Jun 04 '24 18:06 silverwind