Git Product home page Git Product logo

Comments (9)

oliviertassinari avatar oliviertassinari commented on June 1, 2024

@iammerrick Yes, it's.
The documentation is using it.
And I'm using it in production (click on the try button to install the sw.js).

from serviceworker-webpack-plugin.

oliviertassinari avatar oliviertassinari commented on June 1, 2024

@iammerrick Are you experiencing any issue?

from serviceworker-webpack-plugin.

iammerrick avatar iammerrick commented on June 1, 2024

@oliviertassinari Yeah, when I npm install the plugin and require the runtime as shown in the documentation, I get an empty object. If you look at the package on NPM it is publishing an empty file for the runtime.

from serviceworker-webpack-plugin.

oliviertassinari avatar oliviertassinari commented on June 1, 2024

Yes indeed, this plugin is hijacking the require to add his own template. So you don't have to write sw.js twice (single source of truth).

from serviceworker-webpack-plugin.

iammerrick avatar iammerrick commented on June 1, 2024

Huh. for whatever reason when I require it I just get an empty module.

from serviceworker-webpack-plugin.

oliviertassinari avatar oliviertassinari commented on June 1, 2024

Could you console.log the two variables here https://github.com/oliviertassinari/serviceworker-webpack-plugin/blob/master/src/index.js#L56?

from serviceworker-webpack-plugin.

sabinmarcu avatar sabinmarcu commented on June 1, 2024

Ran into the same issue just now.

I ran the same code for the /docs and my own app, with console.logs at each step (at the script's root, to see if it's loaded, after apply(compiler), after nmf, at each after-resolve with the variables printed. In the /docs example it works just fine, and in my build I only find that I only get the file loaded print.

Will keep looking for a reason (configuration / conflicts)

// edit

On a hunch, I checked the sw.js output (served through webpack, and it contains the pure contents of the original script, no webpack wrapper, or files list).

// edit2

On a second hunch, I checked configurations, and if the plugin was loaded after all. It sounded like the plugin wasn't being loaded at all, and I was right.

@iammerrick , check your webpack config. In my case, I was checking if the service worker for a build had a sw.js file (couple apps with a lot of shared code), and if so, add the plugin. That check failed on my mistake, and didn't include the plugin. As a direct result, the runtime was empty, and the file was bare-bones (not wrapped).

Note: fixing the plugin managed to fix the runtime issue, but the sw.js is still outside the loader (and does not pass through babel or any other loaders... probably still a configuration glitch)

I'm leaving a trail of what problems I had, and how I fixed them, maybe it will clear the issue :)

from serviceworker-webpack-plugin.

oliviertassinari avatar oliviertassinari commented on June 1, 2024

@sabinmarcu Thanks for the feedback. I'm gonna see If I can't add a warning for your wrong set-up case.

from serviceworker-webpack-plugin.

oliviertassinari avatar oliviertassinari commented on June 1, 2024

I have added an explicit failing message https://github.com/oliviertassinari/serviceworker-webpack-plugin/blob/master/src/runtime.js. I hope that it will help.

from serviceworker-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.