pcb
pcb copied to clipboard
Plugin's runtime wasn't added to one of your bundle entries.
Hey, I'm getting this error
ERROR in OfflinePlugin: Plugin's runtime wasn't added to one of your bundle entries. See this https://goo.gl/YwewYp for details.
I've gone through older issues and made sure that all loaders have the -loader
part in webpack.config. I'm also not using the dev server for production. The entry is a single index.js that includes:
const offline = require('offline-plugin/runtime');
offline.install({
onUpdating: () => {
console.log('SW Event:', 'onUpdating');
},
onUpdateReady: () => {
console.log('SW Event:', 'onUpdateReady');
offline.applyUpdate();
},
onUpdated: () => {
console.log('SW Event:', 'onUpdated');
// window.location.reload(); // Only needed with autoUpdates
},
onUpdateFailed: () => {
console.log('SW Event:', 'onUpdateFailed');
},
});
Also, the browser console will complain about offline-plugin: runtime was installed without OfflinePlugin being added to the webpack.config.js. See https://goo.gl/2Ca7NO for details.
.
Is there anything else I could check? Already tried updating webpack to 3.5.1, to no avail.
Hi @bkniffler can you share your webpack config please?
Yes, the core webpack stuff https://github.com/bkniffler/olymp/blob/master/packages/core/webpack-config.es6
The offline config https://github.com/bkniffler/olymp/blob/master/packages/core/offline.es6
And the babel stuff https://github.com/bkniffler/olymp/blob/master/packages/webpack-babel/index.es6
And the runtime https://github.com/bkniffler/olymp/blob/master/packages/core/web/index.es6
Sounds weird, but unfortunately I don't have time to help you right now. Maybe next week.
I'll try and investigate more, also I'll make the config a bit more easy to read.
How is it going? Were you able to fix the issue?
I still didn't manage to make it work. Its definitely the last plugin added to my webpack config and I've tried a lot of different stuff without success. I have no clue whats going on.
https://github.com/bkniffler/olymp/blob/master/packages/core/offline.es6 https://github.com/bkniffler/olymp/blob/master/packages/core/web/index.es6
If I set the __tests.ignoreRuntime to true, the sw.js file will be created, though still the client complains about offline-plugin: runtime was installed without OfflinePlugin being added to the webpack.config.js. See https://goo.gl/2Ca7NO for details.
Got it! The paths are a problem, like for example
var resource = _path3['default'].resolve(compiler.context, result.resource);
if (resource !== runtimePath) {
return callback(null, result);
}
/* this works =>
if (resource.indexOf('node_modules/offline-plugin/runtime.js') !== -1) {
return callback(null, result);
}
*/
My webpack config is inside a symlinked package, thus the resource path will never match the runtime path currently.
My current workaround is to require offline-plugin by
const OfflinePlugin = require(path.resolve(process.cwd(), 'node_modules', 'offline-plugin'));
@bkniffler interesting. Can you show me what resource
and runtimePath
path you have in that situation? Also I'm glad you were able to solve it :-)
resource = /Users/me/app/node_modules/offline-plugin/runtime.js
runtimePath = /Users/me/framework/packages/core/node_modules/offline-plugin/runtime.js
I got a framework project which is a lerna repo and it holds everything that can be reused between projects (webpack config, react SSR stuff, apollo client, etc). I'm symlinking it to my app so I extend the framework whenever I require and immediately see how it affects my app. This works great for everything (and I really use a lot of plugins), except for the offline plugin. Not sure if its worth to change the plugins behavior, I think it really is an edge case. But then again, maybe tweaking the plugin to only check for the node_modules/offline-plugin/xxx
part of a path might be simple enough.
I had the same issue with a symlinked project using lerna. @bkniffler fix worked for me as well.
I'm going to label this is a bug and maybe solve some day. Thanks for additional info @bkniffler and great the workaround worked for both, you and @nvanselow.
For me this issue was solved by adding
new webpack.EnvironmentPlugin(
NODE_ENV: 'production'
}),
inside the list of plugins (plugins:
) in the file webpack.prod.babel.js
.
If I set the __tests.ignoreRuntime to true, the sw.js file will be created, though still the client complains about offline-plugin: runtime was installed without OfflinePlugin being added to the webpack.config.js. See https://goo.gl/2Ca7NO for details.
This applies to me, and even trying the provided solutions don't work.
I have resolve symlinks turned on because of a similar situation with lerna, packageA
has the webpack configs, offline-plugin dependency and webpack dependency while packageB has the webapp code and a dependency on packageA.
To enable local development, the package.json in packageB has:
"dependencies": {
"packageA": "link:../../packageA",
This project is based on React-boilerplate so the webpack implementation is just like https://github.com/react-boilerplate/react-boilerplate/blob/master/internals/webpack/webpack.prod.babel.js#L89 and the runtime usage is like https://github.com/react-boilerplate/react-boilerplate/blob/master/app/app.js#L94
I just have no clue where to go from here....