-
Notifications
You must be signed in to change notification settings - Fork 463
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
Playground New ReScript JS API 2020 #4518
Conversation
I took the chance and also expand the scope of this PR to tackle the new API as discussed in #4450. The first commit to make the new API possible revolves around following changes:
Introduce a bs_platform namespace Before we were independently adding language support via With one unified Reduce global state / allow different settings We wanted to introduce different settings for different instances of the Therefore we needed to introduce a factory function that looks like this:
Internally, the API is still relying on one global compiler state, but we are now Make super_errors reporting the default Previously we offered functions like The goal is to make super_errors really solid, and it's probably the best default experience |
@bobzhang Would be great to get some review on this. The main work happened all in |
Note you own the playground module, so I won't block this merge. It seems the new version of playground relies on a much larger surface API from both jsoo and our compiler internal,
I suggest we not play with the idea of changing settings dynamically, it may or may not After remove unneeded surface API, can you make a module in the jscomp/core directory to list which APIs are |
Thanks for the feedback! Too many compiler internals
I am happy to reduce them, can you tell me what specific parts are critical in your opinion? @cristianoc once mentioned that it would be a good idea to factor code in a way that I spent quite some time not overusing internal compiler modules too much, these are the minimal requirements I had basically. I think @chenglou wanted to dedupe the super_error reporting within the compiler and the syntax, so maybe we can reduce the super_error overriding at least? Dynamic Settings / Global State
For a proper playground experience we need a way to manipulate the compiler settings (especially for warning flags / module system). The solution at hand already works as advertised (even handles the precompiled module cache correctly so it doesn't take 2 seconds to build code that uses React). In the end we are basically doing the same state reset management like the toploop module. In fact, we actually need to reset the compiler state on each run, otherwise the playground will only show warnings once (when compiling similar code twice). So I am aware of the risk of having bugs, but ultimately, it's not like the playground bundle will break any main workflows of our users when there is a subtle compiler state bug in our web playground / code snippets. The upsides outweigh the downsides and the risk is very low IMO. I wished the OCaml compiler would allow easier re-entrance, but this is probably something that will never be redesigned I guess.
The JSOO bundle uses the in memory filesystem to store the build artifacts (as far as I could observe). Other than that, JSOO bundle insertion (for the compiler and dependend libraries) is handled by our React-Hooks api (to make sure the JSOO filesystem creates cmt / cmi files correctly). I don't think that there's any global JSOO state that can otherwise mess with the compiler. Other
Yes, will do that after my vacation 👍 |
Still need to set \cc @IwanKaramazow |
…ame_in_cmi various improvements over incremental build
Signed-Off-By: Paul Tsnobiladzé <paul.tsnobiladze@gmail.com>
rescript implementation of Js Array.prototype.join() Signed-Off-By: Paul Tsnobiladzé <paul.tsnobiladze@gmail.com>
…belt Add Array.joinWith to Belt
move interpolated variable the later as much as possible
Fixed typo in Changes.md
experimental changes so that only cmi/j changes will trigger a rebuild
Rebasing onto the 8.4.2 tag today to cut a release |
…/bucklescript into playground-napkin-support
I missed the PR, would you do a rebase against master? |
This squashes all the changes from rescript-lang#4518
Closed in favor of #4947 (for a cleaner diff to review) |
For reference on the previous work in 2020, refer to rescript-lang#4518
For reference on the previous work in 2020, refer to rescript-lang#4518
For reference on the previous work in 2020, refer to rescript-lang#4518
For reference on the previous work in 2020, refer to rescript-lang#4518
For reference on the previous work in 2020, refer to #4518
For reference on the previous work in 2020, refer to #4518
* Add all relevant changes from previous 2020 bundle API For reference on the previous work in 2020, refer to #4518 * Add ninja rule for building jsoo_refmt_main * Fix formatting edge-cases when formatting ReScript -> ReScript Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265 * Introduce initial type hints in playground bundle results * Adapt playground to newest internal syntax apis * Make jsoo_refmt_main work again by removing refmt * Rename jsoo_refmt_main to jsoo_playground_main * Move jsoo_playground_main to jscomp/main * Remove irrelevant code * Remove Refmt_api * Make repl.js more reliable with missing .mli files * repl.js: Log target compiler file, set js_playground_main as default * Update CONTRIBUTING to align with the renamed playground jsoo entrypoint Co-authored-by: Patrick Stapfer <ryyppy@users.noreply.github.com>
* Add all relevant changes from previous 2020 bundle API For reference on the previous work in 2020, refer to rescript-lang#4518 * Add ninja rule for building jsoo_refmt_main * Fix formatting edge-cases when formatting ReScript -> ReScript Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265 * Introduce initial type hints in playground bundle results * Adapt playground to newest internal syntax apis * Make jsoo_refmt_main work again by removing refmt * Rename jsoo_refmt_main to jsoo_playground_main * Move jsoo_playground_main to jscomp/main * Remove irrelevant code * Remove Refmt_api * Make repl.js more reliable with missing .mli files * repl.js: Log target compiler file, set js_playground_main as default * Update CONTRIBUTING to align with the renamed playground jsoo entrypoint Co-authored-by: Patrick Stapfer <ryyppy@users.noreply.github.com>
This PR keeps track of the changes for building our current playground bundle. It introduces following changes in the bundle API:
errors
attribute with multiple error objects (instead of just a flat error object)row - 1
, since 0 based row doesn't make sense for this apitype: "success"
attribute, to make the return value of each compile function an discriminated union to switch on more easilyFor the rest of the changes, follow the comments that were made over the last few months.