twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
949 stars 67 forks source link

Regex not compatible IOS / Safari #55

Closed GautheyValentin closed 2 years ago

GautheyValentin commented 4 years ago

Hello,

issuer: /\.\w+(?<!(s?c|sa)ss)$/i,

Create JS crash on Safari / IOS

To tempory fix, i use @1.3.0

If you have a other solution

arefaslani commented 4 years ago

@GautheyValentin Can I ask which versions of Safari are you using?

GautheyValentin commented 4 years ago

@arefaslani Hello 14.0 on macOS You want i provide some screen with error ?

arefaslani commented 4 years ago

@GautheyValentin Yeah that'd be also nice 👍

GautheyValentin commented 4 years ago

@arefaslani Capture d’écran 2020-10-20 à 08 09 51

arefaslani commented 3 years ago

Have you been successful in solving this issue by now? Sorry, I just came back to check the issues. Seems like I need to change the regex to make it also compatible with the browsers you mentioned.

GautheyValentin commented 3 years ago

Hi,

I just downgraded to 1.3.0 because it was an old regex and i didn't fixe this issue.

But maybe is my fault, what is your tsconfig ?

arefaslani commented 3 years ago

Hi,

I just downgraded to 1.3.0 because it was an old regex and i didn't fixe this issue.

But maybe is my fault, what is your tsconfig ?

Actually, I don't work with Typescript, but I'll definitely try to see what's wrong...

arefaslani commented 3 years ago

@GautheyValentin Have you been successful in solving this problem?

GautheyValentin commented 3 years ago

No :(

message commented 3 years ago

Why this script is included in _app.js? It's a webpack script that should be executed in build phase only. You should require next-images from next.config.js.

GautheyValentin commented 3 years ago

It is already only in next.config.js

const widthImages = require("next-images");
const { nextI18NextRewrites } = require("next-i18next/rewrites");

const localeSubpaths = {
  fr: "fr",
  nl: "nl",
};

module.exports = {
  default: widthImages({
    webpackDevMiddleware: (config) => {
      config.watchOptions = {
        aggregateTimeout: 200,
        poll: 1000,
      };
      return config;
    },
    rewrites: async () => nextI18NextRewrites(localeSubpaths),
  }),
  localeSubpaths,
  env: {
    NEXT_PUBLIC_RECAPTCHA_SITE_KEY: process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,
  },
};
alexthewilde commented 3 years ago

Same here. next-images is required from within next.config.js, but its code is added to the app bundle.

lvancraen commented 3 years ago

When wrapping the regex /\.\w+(?<!(s?c|sa)ss)$/i with RegExp as such new RegExp('\.\w+(?<!(s?c|sa)ss)$', 'i') the error is resolved in Safari.