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

{{ROOT_URL}} (for registration) not getting replaced during build #125

Closed
NullVoxPopuli opened this issue Aug 12, 2018 · 10 comments
Closed

Comments

@NullVoxPopuli
Copy link
Contributor

all I have is this (in my ember-cli-config):

    'ember-service-worker': {  },

but in the output, I'm getting:

(function(){"use strict"
function n(n){e.push(n)}var e=[],r=[]
"serviceWorker"in navigator&&navigator.serviceWorker.register("{{ROOT_URL}}sw.js",{scope:"{{ROOT_URL}}"}).
@NullVoxPopuli
Copy link
Contributor Author

this is what I'm doing to avoid the issue in the mean time.

sed -i -e 's/{{ROOT_URL}}/\//g' dist/index.html

with the inline registration option.

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Aug 12, 2018

this is reproducible running on my host machine:
image

here is my project if you guys ever decide to look https://gitlab.com/NullVoxPopuli/emberclear/tree/master/packages/frontend

running with

ENABLE_SW=true yarn start

;p

@bracke
Copy link

bracke commented Sep 24, 2018

I'm also getting this.

@NullVoxPopuli
Copy link
Contributor Author

Started some work on this here: #130

@stukalin
Copy link
Contributor

Tried to upgrade the Ember from v3.4 to 3.5 today and received the same issue... Looking forward to see a fix

@NullVoxPopuli
Copy link
Contributor Author

@stukalin how good are you at debugging rollup builds? #130 :D

@balinterdi
Copy link

I have the same issue but in my case even replacing {{ROOT_URL}} with /' doesn't fix it. The sw.js` request still has the encoded form prepended to it:

screen shot 2018-10-18 at 16 01 54

I also just bumped into this when upgrading to 3.5.

@NullVoxPopuli Unfortunately, I'm very untalented when it comes to debugging rollup builds :(

@erkie
Copy link

erkie commented Oct 20, 2018

Found it:

https://github.com/DockYard/ember-service-worker/blob/master/lib/service-worker-builder.js#L88

Needs to be changed to:

-      include: ['**/ember-service-worker/**/*.js'],
+      include: ['/**/ember-service-worker/**/*.js'],

Note the leading slash. Then it works!

Need to run out for a couple of hours, but can make a PR with some tests later today or tomorrow. If nobody beats me to it :D

@NullVoxPopuli
Copy link
Contributor Author

@erkie thanks! in #132, I've made your change and it fixed my issue in emberclear.io .

@eshtadc
Copy link
Contributor

eshtadc commented Nov 6, 2018

Fixed in #132

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 a pull request may close this issue.

6 participants