Comments (4)
@DuCanhGH I tried to reproduce the issue in the Sandbox, but unfortunately I couldn't get it to throw the same error I was getting. I will close this issue, as there is no way to know what really went wrong (maybe someone in the future stumbles upon the issue and can reproduce it). Thanks for taking the time to look into it, though.
from serwist.
Right, disabling Serwist works, but I don't see how that means this is related to it. This issue just screams Next.js or Webpack. There's nothing in @serwist/webpack-plugin
that can cause such a horrendous issue. It simply creates separate child compilations to compile its own things. @serwist/next
can't be related either. It intercepts main-app
and main.js
, which are the main entrypoints of your app, to add its own code, but it doesn't touch anything else, including the file in the error. I don't think it is really related to JSON modules, since you, too, can't reproduce it. Maybe you should try removing the JSON modules to verify, if that's possible? Perhaps there're some deeper issues with your actual app, but I don't have access to it so here we are.
P/s: I don't see why you have to hide the JSON part to be honest. It ends up in the client bundle anyway, so there shouldn't be any secret in it, should there be?
from serwist.
@DuCanhGH You are right, the packages you mentioned were not the issue.
To your argument, I could also say the same. Serwist was the only variable in the equation, how is it not an issue with Serwist (maybe not directly, but there is something).
Anyway, I tried every combination possible for package configuration (in next.config.js
) and service worker configuration (in service-worker.ts
), and I narrowed the issue down to this:
The issue I mentioned with JSON loading happens only if I configure precacheOptions.urlManipulation
when I call installSerwist()
function.
I was trying to provide alternative URLs for a resource from another language if it exists.
So you know what I am trying to do, (maybe it's wrong, this is at least what I understood from code documentation), here is a code snippet:
const i18n = { defaultLocale: 'en', locales: ['en', 'de'] };
installSerwist({
// other options ...
precacheOptions: {
// other options ...
// this option causes Serwist to fail in production build
urlManipulation: ({ url }: { url: URL }): URL[] => {
const path = url.pathname.replace(new RegExp(`^/(${i18n.locales.join('|')})/`), '/');
return i18n.locales
.filter(locale => locale !== i18n.defaultLocale) // default locale doesn't have prefix (accessible from "/")
.map(locale => new URL('/' + locale + path, url));
},
},
});
from serwist.
@MarwanAlsoltany huh, now that you have narrowed down the issue, would a reproduction be possible? I'd really appreciate it, since there's not much I can do if there's nothing to experiment with...
from serwist.
Related Issues (20)
- [Bug]: Service Worker is installed on a page out of scope. HOT 4
- [Docs]: Next.js, where are the cache expiration settings and similar configuration HOT 8
- [Bug]: Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 2
- [Bug]: serwist tries to install service worker with different name than specified in next config HOT 2
- [Bug]: Problem with old safari version HOT 9
- [Bug]: Logs spammed on console in production HOT 3
- [Bug]: Browser export missing from NextJS package HOT 3
- [Bug]: When using serwist/next with pyodide/webpack-plugin - "TypeError: The 'compilation' argument must be an instance of Compilation" HOT 8
- question about globals in `@serwist/core` and `globals.d.ts` HOT 4
- [Bug]: Type error: An expression of type 'void' cannot be tested for truthiness. HOT 1
- How Can I cache resources from my application to have complete offline feature? HOT 2
- `@serwist/next` - additionalPrecacheEntries prevents automatically precaching public dir files
- [Bug]: Vercel build fails to load next.config.js HOT 4
- Question: Is there a way to disable the precaching? HOT 4
- [Docs]: Build fails if you follow setup guide Next.js HOT 2
- [Bug]: Preload config error HOT 6
- [Docs]: Install button not showing up in browser url bar after following serwist next instructions HOT 2
- [Bug]: next.js dev server not working HOT 7
- [Bug]: next-web-push example not working
- [Bug]: Service worker causing 500 error with Authjs v5 for Google during repeated sign-ins and sign-outs. HOT 1
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 serwist.