ECMAScript Usage with NextConfig
https://nextjs.org/docs/pages/api-reference/next-config-js
CommonJS works just fine with the docs provided but the ecma script does not
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
async redirects() {
return [
{
source:
"/2021/06/29/simple-telegram-bot-in-python-hosted-easily-on-heroku",
destination: "/simple-telegram-bot-in-python-hosted-easily-on-heroku",
permanent: true,
},
{
source: "/2021/07/11/easy-proxy-scraper-and-proxy-usage-in-python",
destination: "/easy-proxy-scraper-and-proxy-usage-in-python",
permanent: true,
},
{
source:
"/2021/05/27/panel-data-econometrics-an-introduction-with-an-example-in-python",
destination:
"/panel-data-econometrics-an-introduction-with-an-example-in-python",
permanent: true,
},
{
source: "/2021/06/06/time-series-data-an-easy-introduction",
destination: "/time-series-data-an-easy-introduction",
permanent: true,
},
{
source: "/simple-image-classification-with-efficientnet",
destination: "/efficientnet-classification",
permanent: true,
},
{
source: "/page/3",
destination: "/",
permanent: true,
},
{
source: "/author/fedotovn19/page/3",
destination: "/",
permanent: true,
},
{
source: "/tabular-playground-overfitting-solvers-club",
destination: "/",
permanent: true,
},
{
source: "/data-science-playground-solvers-club",
destination: "/",
permanent: true,
},
{
source: "/honest_protocol_data_analytics",
destination: "/data_analytics",
permanent: true,
},
{
source: "/blog/0",
destination: "/blog",
permanent: true,
},
{
source: "/.Unlock",
destination: "/",
permanent: true,
},
];
},
};
const removeImports = require("next-remove-imports")();
module.exports = removeImports({ ...nextConfig });
@Pfed-prog
// next.config.mjs
import removeImports from 'next-remove-imports'
/** @type {function(import("next").NextConfig): import("next").NextConfig}} */
const removeImportsFun = removeImports({
// test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/,
// matchImports: "\\.(less|css|scss|sass|styl)$"
});
export default removeImportsFun({
webpack(config, options) {
return config
},
});
@Pfed-prog
// next.config.mjs import removeImports from 'next-remove-imports' /** @type {function(import("next").NextConfig): import("next").NextConfig}} */ const removeImportsFun = removeImports({ // test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/, // matchImports: "\\.(less|css|scss|sass|styl)$" }); export default removeImportsFun({ webpack(config, options) { return config }, });
This gives build error
https://github.com/uiwjs/next-remove-imports/blob/243d8483bffde971465ca3c821201cd72d732ef8/example/esm/next.config.mjs#L1-L17
@Pfed-prog If you provide a reproducible example, I can help you take a look.
https://github.com/dspytdao/dspyt-homepage/tree/main/dspyt
https://github.com/dspytdao/dspyt-homepage/blob/main/dspyt/next.config.js
I have translated other configs to ecma as well, but the key part of the project is next config
@Pfed-prog Not sure what happened.
@Pfed-prog Not sure what happened.
Omg, thank you so much for helping. I am trying to convert this file to ecma and it fails.
@Pfed-prog Not sure what happened.