aidenybai / million

Optimize React performance and make your React 70% faster in minutes, not months.
https://million.dev
MIT License
15.87k stars 554 forks source link

Lint broken with Next.js URL rewrites - TypeError: prevRewrites is not iterable #1036

Closed AugusDogus closed 1 month ago

AugusDogus commented 1 month ago

What version of million are you using?

1.0.0-rc.0

Are you using an SSR adapter? If so, which one?

N/A

What package manager are you using?

pnpm

What operating system are you using?

Windows

What browser are you using?

Chrome

Describe the Bug

Making use of fallback URL rewrites appears to break million lint.

import MillionLint from "@million/lint";
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  async rewrites() {
    return {
      fallback: [
        {
          source: "/:path*",
          destination: `https://example.com/:path*`,
        },
      ],
    };
  },
};
export default MillionLint.next()(nextConfig);
$ pnpm dev

TypeError: prevRewrites is not iterable
    at Object.rewrites (file:///C:/Users/augie/dev/playground/million-rewrites-example/node_modules/.pnpm/@million+lint@1.0.0-rc.1/node_modules/@million/lint/dist/compiler/index.mjs:3085:14)
    at async loadRewrites (C:\Users\augie\dev\playground\million-rewrites-example\node_modules\.pnpm\next@14.2.3_@babel+core@7.24.5_react-dom@18.3.1_react@18.3.1\node_modules\next\dist\lib\load-custom-routes.js:382:23)
    at async Promise.all (index 1)
    at async loadCustomRoutes (C:\Users\augie\dev\playground\million-rewrites-example\node_modules\.pnpm\next@14.2.3_@babel+core@7.24.5_react-dom@18.3.1_react@18.3.1\node_modules\next\dist\lib\load-custom-routes.js:435:44)
    at async setupFsCheck (C:\Users\augie\dev\playground\million-rewrites-example\node_modules\.pnpm\next@14.2.3_@babel+core@7.24.5_react-dom@18.3.1_react@18.3.1\node_modules\next\dist\server\lib\router-utils\filesystem.js:245:24)
    at async initialize (C:\Users\augie\dev\playground\million-rewrites-example\node_modules\.pnpm\next@14.2.3_@babel+core@7.24.5_react-dom@18.3.1_react@18.3.1\node_modules\next\dist\server\lib\router-server.js:61:23)
    at async Server.<anonymous> (C:\Users\augie\dev\playground\million-rewrites-example\node_modules\.pnpm\next@14.2.3_@babel+core@7.24.5_react-dom@18.3.1_react@18.3.1\node_modules\next\dist\server\lib\start-server.js:249:36)

What's the expected result?

The million lint server should start normally.

Ex - rewrites commented out:

import MillionLint from "@million/lint";
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  // async rewrites() {
  //   return {
  //     fallback: [
  //       {
  //         source: "/:path*",
  //         destination: `https://example.com/:path*`,
  //       },
  //     ],
  //   };
  // },
};
export default MillionLint.next()(nextConfig);
$ pnpm dev

▲ Next.js 14.2.3
  - Local:        http://localhost:3000

 ✓ Starting...

 ⚡ Million Lint v1.0.0-rc.1
 - Local server: http://localhost:42423

 ✓ Ready in 0.31ms
 ✓ Ready in 2.6s

Link to Minimal Reproducible Example

https://stackblitz.com/github/AugusDogus/million-rewrites-example

Participation

github-actions[bot] commented 1 month ago

Thanks for opening this issue! A maintainer will review it soon.

aidenybai commented 1 month ago

Hey @AugusDogus, we just pushed a fix. Can you try upgrading to latest?

npm i @million/lint@latest
AugusDogus commented 1 month ago

Thanks for the quick turnaround! I can confirm the fix works.