Skip to content
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

Add Service Worker support to module.cljs #8

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Zaphodious
Copy link

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}

@Zaphodious
Copy link
Author

Zaphodious commented Apr 21, 2018

As an aside, this is so far the easiest way I've found to get figwheel to run alongside a service worker build. Usually it gripes with me until I beat it into submission or give up.

@Zaphodious
Copy link
Author

Hello there! Was there a problem with this pull request? Should I change something?

@weavejester
Copy link
Contributor

Hi, sorry for the late response! This managed to slip off my todo list. Can you adjust your PR so that it adheres to the new contributing guidelines that I intend to add to my repositories?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants