-
Notifications
You must be signed in to change notification settings - Fork 10
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
Graceful lumo exit on compiler failure. Support lumo >= 1.8.0. #22
Conversation
b9218f8
to
95f8e32
Compare
compiler-opts | ||
nil | ||
#(let [promise-fn (if (:error %) reject resolve)] | ||
(promise-fn %)))))) |
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 would be clearer if the only statement inside the promise was:
(js/Promise.
(fn [resolve reject]
(lumo.build.api/build
...
(fn [result]
(if (:error result)
(reject result)
(resolve result))))
What happens if the user doesn't have the latest lumo?
Yep I will change it and yes that is why I think we should wait for a merge/release. Unfortunately the old versions cannot be made to work as well. Note that lumo compilation has always been experimental so I don't think we can rely on version numbers these. The good news is that the next release will probably be at par with JVM cljs.
…On September 13, 2017 1:35:24 AM PDT, Moe Aboulkheir ***@***.***> wrote:
moea commented on this pull request.
> - (run! classpath/add! inputs)
- (lumo.build.api/build
- (apply lumo.build.api/inputs inputs)
- compiler-opts))
+ (js/Promise.
+ (fn [resolve reject]
+ (js/console.info
+ "Invoking the Lumo compiler w/ inputs"
+ (.stringify js/JSON (clj->js inputs)))
+ (run! classpath/add! inputs)
+ (lumo.build.api/build
+ (apply lumo.build.api/inputs inputs)
+ compiler-opts
+ nil
+ #(let [promise-fn (if (:error %) reject resolve)]
+ (promise-fn %))))))
This would be clearer if the only statement inside the promise was:
```clojure
(js/Promise.
(fn [resolve reject]
(lumo.build.api/build
...
(fn [result]
(if (:error result)
(reject result)
(resolve result))))
```
What happens if the user doesn't have the latest lumo?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#22 (review)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
95f8e32
to
9b68bd3
Compare
My PR is not in |
ec18af7
to
f29937a
Compare
So this is now in |
f29937a
to
ead676d
Compare
On second thought, this one now should work for older lumos as well because the compiler function probably throws on errors, making the promise reject anyways. |
Yeah, but if the signature doesn't include a callback argument, presumably it'll be a problem? |
Oh right, well what do you think is the best approach? I think lumo compilation before this version is not worth keeping compatibility with, as you have probably guess it was very experimental. |
If we clearly document the status of the lumo dependency in the README (either a commit hash or version #, whatever's applicable), then I'm fine with the change. |
Ok I will add that, there is an actual version published on npm, |
If you get a moment, can you address the previous review comment which suggested removing everything from the Promise monad except for the final build call? |
Sure, do you mean the console.log? The |
If it throws outside the promise, the process will exit irregularly in any case. |
09cdeb3
to
68e601e
Compare
README.md
Outdated
[compiler](https://anmonteiro.com/2017/02/compiling-clojurescript-projects-without-the-jvm/). | ||
|
||
Note that `serverless-cljs-plugin` needs _Lumo >= 1.8.0_. |
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.
Done, let me know if you would like me to change the style of this.
68e601e
to
a99a65f
Compare
@@ -69,7 +77,6 @@ | |||
{:source-paths ["src"] | |||
:compiler {:output-to (.format path #js {:dir "out" :base "lambda.js"}) | |||
:output-dir "out" | |||
:source-map false ;; lumo bug |
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 is not needed anymore given that it has been solved in Lumo 1.8.0-beta1
(build! opts (merge-maps default-config (read-conf!))))) | ||
(.then (build! opts (merge-maps default-config (read-conf!))) | ||
lumo/exit | ||
#(lumo/exit 2)))) |
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 put 2
in order to differentiate it from the normal exit code for throws, which is 1
.
a99a65f
to
f044d29
Compare
This patch fixes the fact that `serverless` could not display compilation ailures because `lumo` was not returning anything. Now `lumo.build.api` accepts a callback that returns the error. This feature is only available in the latest lumo (>= 1.8.0) so the README now makes clear that other versions won't be supported.
f044d29
to
18ac066
Compare
So I think that thanks to anmonteiro/lumo@80192d1 this patch can be entirely dropped. The build api is sync now. |
This patch fixes the fact that
serverless
could not display compilation ailures becauselumo
was not returning anything. Nowlumo.build.api
accepts a callback that returns the error.This feature is only available in the latest lumo (>= 1.8.0) so the README now makes clear that other versions won't be supported.