Add Service Worker support to module.cljs #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for service worker compilation. Clojurescript dependency bumped to 1.10 to allow for
:target :webworker
. Separate compiler opts map used for dev and production, with options conducive to service worker development and use. Of special note is:language-in :es6, :rewrite-polyfills true
due to service workers requiring the use of js promises,:output-to (str path "/sw.js")
due to service workers needing to be served from the same directory as the site they control, and:infer-externs true
to assist with development as obscure closure errors are hard to debug when figwheel isn't a thing. (Externs inference is kept for deployment due to the negative impact being either compile-time-only when enabled, or potentially breaking when dev and prod have this set differently). Also of note is that this change is independent of figwheel, as the duct workflow refreshes the service worker file on(reset)
(which can then be updated in whatever way required by the browser being used).As a result of this pull request, adding service worker support to a project is as easy as creating a new cljs namespace and pointing module.cljs to it, like so-
:duct.module/cljs {:sw-main project-name.sw}