Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECMAScript Usage with NextConfig #17

Open
Pfed-prog opened this issue Mar 21, 2024 · 6 comments
Open

ECMAScript Usage with NextConfig #17

Pfed-prog opened this issue Mar 21, 2024 · 6 comments

Comments

@Pfed-prog
Copy link

Pfed-prog commented Mar 21, 2024

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 });
@jaywcjlove
Copy link
Member

@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
Copy link
Author

@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

@jaywcjlove
Copy link
Member

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: function(config) {
config.module.rules.push({
test: /\.md$/,
use: 'raw-loader',
})
return config
},
})

@Pfed-prog If you provide a reproducible example, I can help you take a look.

@Pfed-prog
Copy link
Author

Pfed-prog commented Mar 22, 2024

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

@jaywcjlove
Copy link
Member

image

@Pfed-prog Not sure what happened.

@Pfed-prog
Copy link
Author

image @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants