-
-
Notifications
You must be signed in to change notification settings - Fork 13
add a function to construct a url, and change how to two libs are built #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| (modes melange) | ||
| (public_name server-reason-react.url_js) | ||
| (libraries melange.js) | ||
| (wrapped false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot remove the wrapped false as it enables the library to function as "universal".
If you don't have it the usage becomes Url_js.Url instead of only Url, which missmatches with the native library Url_native.Url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its still unwrapped because it implements url which is a unwrapped library. If you try to add it back you get an error message.
| @@ -0,0 +1,5 @@ | |||
| (library | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't work with melange as it doesn't have the universal structure. Take a look here: https://ml-in-barcelona.github.io/server-reason-react/server-reason-react/how-to-organise-universal-code.html
| include URL_impl | ||
|
|
||
| let construct ?protocol ~hostname ?port ?pathname ?search ?hash ?password ?username () = | ||
| let apply_opt f o = match o with None -> Fun.id | Some x -> fun u -> f u x in | ||
| "https://example.com" |> makeExn |> apply_opt setProtocol protocol |> Fun.flip setHostname hostname | ||
| |> apply_opt setPort port |> apply_opt setPathname pathname |> apply_opt setSearch search |> apply_opt setHash hash | ||
| |> apply_opt setPassword password |> apply_opt setUsername username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about the motivation of this feature. Can you explain better in the PR description?
| (library | ||
| (name url_native) | ||
| (public_name server-reason-react.url_native) | ||
| (wrapped false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (pps melange.ppx)) | ||
| (implements url)) | ||
|
|
||
| (copy_files# "../URL.rei") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also don't like copy_files, but until we have the dune single-context feature, we need it.
(Related https://github.com/ml-in-barcelona/server-reason-react/pull/317/files#r2453920368)
|
I with trying to write tests and I stubbled on a lot of annoying issues, like Then reading the implementation I realised Uri was mostly what I wanted already, so I will probably use that. |
The function works in a weird way because apparently there no way to get an empty url object in javascript.
Also no more copying files around which should improve editor integration