Make Next.js 13 application run in old browser like Chrome 33

360 Views Asked by At

I need to create a Next.js application which uses Next 14+ that runs on a Chrome 33 browser which is supposed to support ES5 only. Given that some packages inside Next dependency like (@next/font) does not support Babel I am trying to use SWC but I can't find any working configuration.

I have tried browsers list:

"browserslist": [
    ">0.3%, defaults, supports es5"
]

but no luck.

I have also tried next.config.js:

const webpack = require('webpack');

module.exports = {
    webpack: (config, { dev, isServer }) => {

        // Use SWC for transpiling JavaScript files
        config.module.rules.push({
            test: /\.(js|jsx|ts|tsx)$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: "swc-loader",
                    options: {
                        jsc: {
                            target: "es5", // Set the target to ES5
                        },
                    },
                },
            ],
        });
        return config;
    }
};

I have tried adding polyfills but no luck.

Anyone with a working Next.js 13+ application in Chrome 33?

The first error I get with a default configuration after using npx create-next-app is:

Uncaught SyntaxError: Use of future reserved word in strict mode

0

There are 0 best solutions below