-
Notifications
You must be signed in to change notification settings - Fork 465
Proposal to add bs-stdlib #2171
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
Proposal to add bs-stdlib #2171
Conversation
jscomp/core/js_packages_info.ml
Outdated
@@ -238,7 +238,9 @@ let string_of_module_id | |||
else | |||
begin match module_system with | |||
| AmdJS | NodeJS | Es6 -> | |||
dep_package_name // dep_path // js_file | |||
(* HACK - TODO Replace bs-stdlib upstream and not here *) | |||
let upd_dep_package_name = if dep_package_name = "bs-platform" then "bs-stdlib" else dep_package_name in |
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.
@bobzhang I tried to come up with a better solution than this, happy to take any pointers to where or how this replacement should be done.
@chenglou @bobzhang I was taking a look at this PR to see if there is anything recoverable. If we apply this same approach to Belt, then there would be a The tricky part comes when it comes to what will be included in this So then, we'd need a way to conditionally change the printer to generate
instead of the current:
Whenever a function that belongs to a module published with Does that sound right to you? If yes, could you point me to the part of the code handles this? Is it |
My naive thought was to just snatch lib/js or lib/es6 and publish it. Would that not work? |
you'd also need to change the package name that is My theory is |
Ah! |
well that's where this PR uses a string match to rename the require statements. The difference between my theory and this PR is it puts the dependency in the template; I figure that's not necessary if |
I am going to try and change the paths of the import / require statements before falling back to the redex. Changing this line in @TheSpyder Right, if we include |
@bobzhang @chenglou this is ready for a review. The PR does the following things:
If this PR goes forward, we'll have to make sure that when users update the version of Side note: once |
I think making templates include both platform and stdlib leads to unnecessary overhead if the project doesn't need the separation - the calls for this are still fairly infrequent. I suspect merging this would also break existing projects until they add How about:
|
@@ -238,7 +238,9 @@ let string_of_module_id | |||
else | |||
begin match module_system with | |||
| AmdJS | NodeJS | Es6 -> | |||
dep_package_name // dep_path // js_file | |||
(* HACK - TODO Replace belt-js upstream and not here *) | |||
let upd_dep_package_name = if dep_package_name = "bs-platform" then "belt-js" else dep_package_name in |
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.
This really does seem like the wrong place to make the swap, and it also breaks -global
module system users (of which I am one)
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.
Happy to move it somewhere else, if you have suggestions. I'll try to fix the -global
platform.
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 wish I could help, but I sadly haven't looked at the BuckleScript code much at all.
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 also thought about this package_name
in bs_version
, that gets generated from build_version
. @bobzhang would that be better? I'm unsure if that'd break other things.
@TheSpyder Good idea, I updated the PR to do that, so existing projects don't break. Removed the deps from templates too. |
Hah the build fails now of course, as |
hmm, yeah now the build depends on |
I think it's fine, it's just this first time. In the future, when there would be a new version, calling In any case, the tests are still running against |
making belt consumable to js devs is indeed the goal we want to achieve, but we still need polish it a bit (to make it stable enough to allow somewhat API backwards compatibility guarantee ). |
I would like to use it to replace some immutable libs in JS. I also wanted to help the folks that use Node-In-Reason, who need a simple way to deploy the stdlib as a dependency without having to manually extricate it from the bs-platform package. I was talking to @chenglou about having |
The idea is I want to:
This has little to do with the stability of belt, more that the BuckleScript compiled JS depends on files that currently only ship with Personally this is the main thing holding me back from trying to get more reasonml into my big JS codebase. It's split across multiple packages, which is ideal for replacing small components, but the number of times |
@TheSpyder makes a good point. I think there is a conflation between Probably both issues will require different solutions, as they have nothing to do with each other. Belt will require a lot of effort to polish the JS story (docs etc), while the second case will have to include other packages that are not Belt (stdlib, curry and such). We could keep this PR about |
This PR publishes the entire |
How do you publish your nodejs to production server? This is the workflow I imagined: you do npm install and bsb -make-world on your dev server. When publish, you have a script to prune those ocaml binaries and gzip your current directory to AWS(or your internal server) I assume you don't do |
Ah perhaps now we're hitting the crux of the issue. I'm talking libraries, not applications. For production, yes, I bundle and publish the application without any dependencies. For development, though, my application has a large tree of library dependencies. If I add BuckleScript to one of the core libraries, even though I can publish the https://www.npmjs.com/browse/depended/@ephox/katamari That's a lot of copies of |
I think there are two different target audiences, and maybe the fact that i've been confusing both cases didn't help: 😅 A. Reason / OCaml devs that want to have a way of expressing a dependency on What this PR is trying to solve is actually A, so I'll change the PR name back to the original. @bobzhang If you think this is something interesting and potentially mergeable, I can keep working on this PR. Option B (a polished JavaScript version of Belt) will be happening, but definitely not in this PR. |
Is option B actually something we want? I thought Belt would only really be useful to BuckleScript-compiled code, not developers working in pure JS. The module interfaces seem very ocaml-specific. |
Option B is a very explicitly but intuitionally under-promoted goal. This exposes a very usable library for pure JS users: This way they can adopt the data structures of BS/Reason without needing to switch their whole language. Then value proposition of converting to BS/Reason thus increases because the cost of conversion would have been drastically lowered. |
Oh interesting! Yeah I can see that being beneficial. It's not like people need to know how the structures in Immutable.js work either :) |
@bobzhang: We're using bucklescript on Node for our backend. Issue with doing pruning is that it doesn't really work for docker containers. When running |
Just throwing into the mix, I really appreciate the work being done here on this issue. Including I hacked around this by extracting the |
It is easy to publish the same version for the compiler and stdlib, how do you make sure that it is the same when people consume it? |
@bobzhang Not sure, but probably the most reasonable path is the compiler having a For example,
That way, any package management tool will warn if users are missing the right version of stdlib for the version of the compiler they're using. The other way around ( |
Simplest is to just declare a peerDependency in the compiler. Each release
of the compiler peerDepends on a very specific version of the runtime. User
devDeoendency’s the compiler, and direct-depends on the runtime; npm warns
(as, presumably, the compiler) the user if the runtime-peer is missing.
Worst failure-mode there is if the user installs the runtime as a devDep
just like the compiler, instead of a runtime dep; can be mitigated by
documentation and package.json-linting during compilation by bsb …
Meanwhile, *runtime* checks are one option, overhead wouldn’t be much
(monotonic integer version, perhaps?) … but I don’t like adding to the
compiler output, personally.
On Thu, May 23, 2019 at 01:17 Hongbo Zhang ***@***.***> wrote:
@jchavarri <https://github.com/jchavarri>
The idea is to include a new npm package in lib that gets automatically
published every time the main package bs-platform gets published.
It is easy to publish the same version for the compiler and stdlib, how do
you make sure that it is the same when people consume it?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2171>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAABSF7EPNAIWNERGUX2GTPWYZGZANCNFSM4EAOF3GQ>
.
--
⁓ ELLIOTTCABLE — fly safe.
http://ell.io/tt
|
Hah! Beat to it by one minute.
Real-world example: I follow exactly this pattern with my ppx ports; for
instance, “ppx-deriving” peerDepends on the runtime “bs-deriving” package;
and all this is then documented in the install-instructions for the package.
On Thu, May 23, 2019 at 02:26 Elliott Cable ***@***.***> wrote:
Simplest is to just declare a peerDependency in the compiler. Each release
of the compiler peerDepends on a very specific version of the runtime. User
devDeoendency’s the compiler, and direct-depends on the runtime; npm warns
(as, presumably, the compiler) the user if the runtime-peer is missing.
Worst failure-mode there is if the user installs the runtime as a devDep
just like the compiler, instead of a runtime dep; can be mitigated by
documentation and package.json-linting during compilation by bsb …
Meanwhile, *runtime* checks are one option, overhead wouldn’t be much
(monotonic integer version, perhaps?) … but I don’t like adding to the
compiler output, personally.
On Thu, May 23, 2019 at 01:17 Hongbo Zhang ***@***.***>
wrote:
> @jchavarri <https://github.com/jchavarri>
>
> The idea is to include a new npm package in lib that gets automatically
> published every time the main package bs-platform gets published.
>
> It is easy to publish the same version for the compiler and stdlib, how
> do you make sure that it is the same when people consume it?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#2171>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAAABSF7EPNAIWNERGUX2GTPWYZGZANCNFSM4EAOF3GQ>
> .
>
--
⁓ ELLIOTTCABLE — fly safe.
http://ell.io/tt
--
⁓ ELLIOTTCABLE — fly safe.
http://ell.io/tt
|
For people who are interested, this is landed in master: #2772 (comment) |
100% wip. Related to #2127.
Still many things missing, but hopefully serves as a base for discussion.
The idea is to include a new npm package in
lib
that gets automatically published every time the main packagebs-platform
gets published. This is an attempt to implement a poor man's version of the fixed / locked mode in Lerna 😁