martpie / next-transpile-modules

Next.js plugin to transpile code from node_modules. Please see: https://github.com/martpie/next-transpile-modules/issues/291
MIT License
1.13k stars 85 forks source link

Transpile @mui/material with this module #297

Closed pereriksson closed 11 months ago

pereriksson commented 11 months ago

Are you trying to transpile a local package or an npm package? npm package @mui/material.

Describe the bug I have successfully used next-transpile-modules to transpile all my imported modules using arrow functions to increase compatibility with older devices. There is one module that won't budge - @mui/material. It has a @mui/material/umd/material-ui.production.min.js that contains arrow-functions that are propagated all the way out to the browser. Any help on this is appreciated.

To Reproduce If anyone request a fully functional next.js demo repo I will provide one.

Expected behavior A clear and concise description of what you expected to happen.

Setup

const withTM = require('next-transpile-modules')([
    '@emotion/cache',
    '@emotion/styled',
    '@mui/material',
    '@mui/system',
    '@emotion/styled',
    '@mui/utils',
    'contentful',
    '@mui/base'
]);

const moduleExports = {
  experimental: {
    scrollRestoration: true,
  },
  eslint: {
    ignoreDuringBuilds: true,
  },
  typescript: {
    ignoreBuildErrors: true,
  }
};

module.exports = withTM(moduleExports);

Thanks a lot for your help. And I will definitely donate 10$ to charity if anyone can help.

martpie commented 11 months ago

Hello, do you need to transpile arrow functions due to IE11?

pereriksson commented 11 months ago

Hey, we have some customers using iPads where Safari hasn't been updated for 5 years :) We also hear some issues from other customers so we guess it might be the site not running properly.

martpie commented 11 months ago

So, as the README says, this plugins serves two purposes:

It is not meant as a way to make the bundle compatible with older browers.

Also, this package is half-deprecated and on what I would call "passive-life-support" only: I'm open to PR but I do not plan to work on this plugin anymore. see The End and the front note in the readme.

Ignoring the fact that safari is the new IE, and your customers should definitely update their devices (without mentioning Next.js only supports Safari 12+), I would recommend checking if the transpilePackages option works for you (I doubt it).

On a side note, I worked with customers with crazy requirements, so I know how frustrating it is to receive this kind of answer, but believe, supporting older browsers is never worth it, and you'd better tell your management to let go older devices, for your own sanity.

martpie commented 11 months ago

you'd better tell your management

(there are plenty of good ways to convince management to let go those (imho) stupid requirements, the best one is: "we cannot guarantee the security of customer information on older browsers due to security vulnerabilities"). I have a bunch of other arguments in case you need some.

😈