shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.75k stars 312 forks source link

Compatibility with old browsers #307

Open mmdalix opened 2 years ago

mmdalix commented 2 years ago

Hi guys

We need our project to be supported on old browsers. All the code is compatible with Chrome 30+ except Next PWA script in the main.js output file. `// CONCATENATED MODULE: ./node_modules/next-pwa/register.js

if (typeof window !== 'undefined' && 'serviceWorker' in navigator && typeof caches !== 'undefined') { if (true) { caches.has('start-url').then(function(has) { if (!has) { caches.open('start-url').then(c => c.put('/', new Response('', {status: 200}))) } }) }`

As you can see, the arrow functions were not converted by the babel. Although I have used arrow functions in the entire project, there are no arrow functions in other places in the output js file. It seems the Next PWA is just skipping babel.

The project is written in typescript next-pwa@5.4.4 next@11.1.2

Sajad-Imani commented 2 years ago

hi This is exactly what we have

Sajad-Imani commented 2 years ago

internet explorer not work please check

Sajad-Imani commented 2 years ago

I did not test previous versions


From: MohamadAli Zeraatkar @.> Sent: Wednesday, January 5, 2022 9:02 AM To: shadowwalker/next-pwa @.> Cc: imani013 @.>; Comment @.> Subject: Re: [shadowwalker/next-pwa] Compatibility with old browsers (Issue #307)

Does this apply also to previous versions of next-pwa?

On Wed, Jan 5, 2022 at 8:56 AM imani013 @.***> wrote:

hi This is exactly what we have

— Reply to this email directly, view it on GitHub https://github.com/shadowwalker/next-pwa/issues/307#issuecomment-1005393415, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGJE4TO7VCHDMTNZ74J4JLUUPI7XANCNFSM5KY5W6MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/shadowwalker/next-pwa/issues/307#issuecomment-1005395586, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXAC262STGNB3Y223LZ4XTUUPJWTANCNFSM5KY5W6MQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

chrishelgert commented 2 years ago

you can use next-transpile-modules to keep your js working in older browsers (e.g. IE11)

// next.config.js
const withPWA = require('next-pwa')
const withTranspileModules = require('next-transpile-modules')(['next-pwa'])

// ...

module.exports = withPWA(withTranspileModules(config))
Sajad-Imani commented 2 years ago

you can use next-transpile-modules to keep your js working in older browsers (e.g. IE11)

// next.config.js
const withPWA = require('next-pwa')
const withTranspileModules = require('next-transpile-modules')(['next-pwa'])

// ...

module.exports = withPWA(withTranspileModules(config))
Sajad-Imani commented 2 years ago

Thanks for the tips but the problem was not solved