Comments (9)
@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.
@iammerrick Are you experiencing any issue?
from serviceworker-webpack-plugin.
@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.
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.
Huh. for whatever reason when I require it I just get an empty module.
from serviceworker-webpack-plugin.
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.
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.
@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.
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)
- ServiceWorker script evaluation failed
- DOMException error
- Feature: pass arbitrary data to serviceworker
- Don't detect minification using webpack.optimize HOT 5
- Is there a way to add babel-polyfill using options ? HOT 6
- Serious issues with sourcemaps and multiple webpack configs. HOT 2
- Unexpected using UglifyJSPlugin in development mode HOT 3
- webpack 4 support HOT 3
- The script has an unsupported MIME type ('text/html') HOT 7
- postinstall script requires yarn HOT 1
- import runtime from 'serviceworker-webpack-plugin/lib/runtime'; always throws error HOT 1
- Cannot get the plugin to load the sw.js file inside dist folder HOT 1
- Easy way to disable plugin HOT 1
- Specify absolute path HOT 2
- Eslint dont produce explanation about errors
- Minimizing errors with UglisyJsPlugin HOT 1
- Webpack bootstrap code in sw.js file
- getRegistration
- it doesn't work with nuxt
- typescript definitions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serviceworker-webpack-plugin.