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

Doesn't correctly handle NextJS config function #1040

Closed sambauers closed 1 month ago

sambauers commented 1 month ago

What version of million are you using?

1.0.0-rc.1

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

None

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Safari

Describe the Bug

My NextJS config is setup as a function, as outlined here - https://nextjs.org/docs/app/api-reference/next-config-js

E.g.:

const MillionLint = require('@million/lint')

const nextConfig = async (phase, { defaultConfig }) => {
  const config = {
    /* config options here */
  }
  return config
}

module.exports = MillionLint.next({ rsc: true })(nextConfig)

Looking at the source of Million, it appears that this is not a supported configuration option.

What's the expected result?

I expected Million to accept the configuration.

Link to Minimal Reproducible Example

http://example.com

Participation

github-actions[bot] commented 1 month ago

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

sambauers commented 1 month ago

I quickly realised the workaround. Simply wrap the return for the function instead. E.g.:

const MillionLint = require('@million/lint')

const nextConfig = async (phase, { defaultConfig }) => {
  const config = {
    /* config options here */
  }
  return MillionLint.next({ rsc: true })(config)
}

module.exports = nextConfig

It would be good to document this.

johnjyang commented 1 month ago

Noted. Thanks for providing the snippet!