-
Notifications
You must be signed in to change notification settings - Fork 188
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
RFC: ecmascript modules as primary build artifact #1161
Comments
Thanks for taking the time to write all this. I want to clarify one aspect for people reading this RFC
One of the reason for the size of the included runtime is that we try hard to keep the same semantic as regular OCaml. |
Thanks for the clarification, I’ll have to go back and revisit why the artifact I produced was so far off. |
There are two ways to compile with jsoo: Separate compilation (probably what you used), it is the default when using dune. Whole program compilation, used in dune when |
I discovered that any consumption of the $ ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml-ppx -linkpkg js/main.ml -o js/main.bc
$ js_of_ocaml compile --opt=3 js/main.bc
$ ls -h js/ Tried various other optimization flags to Nonetheless, I still lobby that yielding ESM would be an improved artifact to offer users :) |
The
As you can see things related to format are rather big. |
related to #551 |
context
JSOO has long been the sole, defacto provider mapping OCaml input to JavaScript output. This project has existed for well over a decade, and has the primary function of taking users' ML and converting it to immediately invocable or effectful JavaScript. This continues to be a great accomplishment.
Over the passed few years, the ECMAScript spec has evolved and developed a proper module system.
This module system development is of interest, because its stabilization enables a greater opportunity for ML to participate in the JavaScript ecosystem.
proposal
Provide a first class compile target to ESM.
justification
elm
's compiler, the moreocaml
features that user code consumes, the more of the runtime we can incrementally include in the output<script src="..." module></script>
), bundlers, analyzers, dead-code analyzers, minifiers, pretty printers--the works!)hypothetical
The following hypothetical cases may be completely bogus. Consider these my temporary, envisioned target state, even if they are not necessarily achievable.
case - empty
Input:
Output:
No source, no dist! 75k worth of savings, vs status quo :)
case - hello world
Input:
Output (a):
Output (b):
case - reduce
Input:
Output:
Where the runtime is partitioned into ESM modules as well. E.g.:
If may be the case that the emitted modules is more along the lines of:
And the fully
runtime
is implemented by a plain, super ES module.What's nice about this, is that only the bare minimum import graph gets used, versus a full runtime!
omissions
Omitted from this discussion are
We could crack into all of these as interested!
user experience
With an ESModule target, browser-friendly ML code could be achievable anywhere ESM is used!
npm install @jsoo/runtime
, then setup a ML loader OR precompile.ml
to modules!I didn't see such conversations on this topic in github, but may have missed it. Sorry if this is duplicated! If this is duped conversation, please feel free to eagerly close!
The text was updated successfully, but these errors were encountered: