-
Notifications
You must be signed in to change notification settings - Fork 110
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
next-offline is incompatible with next-compose-plugins #69
Comments
I was one of those original reporters, but FWIW I haven't had any problems since using |
@NathanielHill ahh, interesting. That'll be what I suggest until get to the bottom of it.
|
I'm having less luck with this problem myself. I made a repo dedicated to getting to the bottom of this, and although that repo reproduces the problem, the problem disappears when I reproduce it in test form. Anyone want to take a look and see if they can figure out what I'm doing wrong? |
@shawninder I should be able to take a look either tonight or this weekend. Thanks for creating the repo! |
@NathanielHill can you share the snippet you have for disabling |
Here's an example
|
In the process of investigating #69, I made a [reproduction repo](https://github.com/shawninder/next-manifest-sw-clash) which would call `next build` and then read the produced files to validate stuff. Strangely, the files didn't exist yet; somehow `next.build` was resolving before the files had been written. This PR fixes that issue. Now, the files I expect to exist as soon as next.build resolves (including main.js) always do indeed exist. What it means for my own reproduction repo is that now the tests match the manual repro.
@shawninder those tests are super helpful, I've actually gone ahead and cleaned them up a big and added them to this repo under the Whats kind of blowing my mind is it seems that everything works fine when running locally
but not remotely (when deploying to now). Running |
That version doesn't work for me locally either. Just to rule out the obvious:
|
@hanford Just FYI: I'm running |
@NathanielHill yeah my bad! I released a broken version and panicked |
@shawninder what's crazy is that adding However, when having I am working in a totally clean environment without any globals/caches etc etc |
My understanding of why If another plugin assigns an async function to However, if your own plugin replaces So to fix the tests (and other scripts using the Next.js build tools programmatically), all plugins in the plugin chain need to make sure they support async I would have thought that returning whatever Perhaps the Next.js build tools have a way of checking whether a function is async but don't detect when it returns a promise? Anyways, maybe these ramblings will help you in your reflections as well. |
I've created this repo In the entry directory we have a That's why I had to revert #73 b/c next-offline was no longer adding |
@NathanielHill is this still an issue for you? @MarkLyck said it's working for him, and it appears to be working okay for me in the test suite |
@hanford, not having any problems here! |
Although, I always disable |
that would be great @NathanielHill During development Let me know if you run into anything though! |
@hanford, I can confirm that the noop Perhaps it needs to be put in the build manifest or some such to be properly served in dev mode at |
ahh you know what @NathanielHill I don't think our dev service worker gets the same exact treatment as the service worker that we end up building for production. Let's keep this open until that is fixed. (it's probably pretty trivial, but it's lower priority than the documentation rewrite I'm working on for now 1.0 and now 2.0) Thanks again for double checking! Hopefully won't be too long until we resolve that |
Sounds good. It looks like the noop |
@NathanielHill with When my next.config.js looks like this https://gist.github.com/hanford/5375852981aa3db89abfdc7af46cacfe things appear to work as normal Might be helpful if you could create a little repo where this issue is happening so i can pull it down and try to fix the use case. Really appreciate the back and forth btw! |
I'm not invoking it, just passing to This is a typical setup for me: https://gist.github.com/NathanielHill/f433b993e5ce0bee4d34e1573be36e29 |
Appreciate you working on this @hanford 👌 |
I can create a next app with the above config and try to get things working — currently on holiday so I’ll try to report back in a week or so. Happy New Years! |
In the meantime @NathanielHill could you try invoking the next offline plugin when you pass it to compose .. similar to how I do it In the above test app? .. I’ve seen some other plugins require this too, not certain how/when next compose plugins invokes these 😅 |
Invoking before passing doesn't make any difference for me. Again, the problem is not that the After a (development) build, I get the following two files:
But I get 404s from Everything works in production 👍 |
I saw many advices to disable next-offline during development phase. But in that case how do we test other features of SW? |
@efleurine you can still test sw features by running your app in production mode locally. And thats npm run build && npm run start. |
Just to add (not a domain expert so feel free to correct the approach), but using a simple pipe function like Perhaps this could be adapted to provide a native way to create such a function. |
@elken I think that's a fine approach as well. |
you can wrap only config object to withOffline: |
Hi, I am not getting the PWA install prompt on mobile or desktop. This is my next.config.js file. `const { PHASE_DEVELOPMENT_SERVER } = require("next/constants"); const config = { const hasSass = withSass(config); module.exports = hasOffline; // module.exports = withPlugins([ I am checking it on an https production server. This is my server.js file ` const { createServer } = require("http"); const port = parseInt(process.env.PORT, 10) || 3000; const handler = routes.getRequestHandler(app, ({ req, res, route, query }) => { const { pathname } = parsedUrl; if (pathname === "/service-worker.js") { app.prepare().then(() => { This is my routes.js file `const nextRoutes = require("next-routes"); routes.add("Home", "/", "/");` When I am checking browser console, SW is registered there. This is the SW object I got Can anyone please help me out. |
I think it should be like this. module.exports = withPlugins(
[withOffline, configOffline],
[withCSS, configWithCSS],
...
) |
For anyone who runs into the problem with
|
I'm getting the same problem, i installed and configured this as the examples, but it does not work.
It does work in this way.
This does not work in this way even when it should do. @hanford Is there any way to do this with the |
In the process of investigating hanford/next-offline#69, I made a [reproduction repo](https://github.com/shawninder/next-manifest-sw-clash) which would call `next build` and then read the produced files to validate stuff. Strangely, the files didn't exist yet; somehow `next.build` was resolving before the files had been written. This PR fixes that issue. Now, the files I expect to exist as soon as next.build resolves (including main.js) always do indeed exist. What it means for my own reproduction repo is that now the tests match the manual repro.
This issue has been reported a few times on the old Zeit slack, along with in some other places like #67
I'm fairly sure this problem a
next-offline
specific issue that we should either fix or find a work aroundThe text was updated successfully, but these errors were encountered: