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

fix: add parser metadata for eslint 9 cache #74791

Merged
merged 2 commits into from
Jan 28, 2025
Merged

Conversation

CvX
Copy link
Contributor

@CvX CvX commented Jan 11, 2025

When using eslint-config-next on eslint 9.x with a flat config (as per next.js docs) and with the --cache flag - eslint would fail:

> ./node_modules/.bin/eslint --cache

Oops! Something went wrong! :(

ESLint: 9.17.0

TypeError: Cannot serialize key "parse" in parser: Function values are not supported.
    at languageOptionsToJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:113:23)
    at languageOptionsToJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:107:35)
    at Config.toJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:260:30)
    at stringify (.../next-eslint-issue/node_modules/json-stable-stringify-without-jsonify/index.js:25:25)
    at module.exports (.../next-eslint-issue/node_modules/json-stable-stringify-without-jsonify/index.js:68:7)
    at hashOfConfigFor (.../next-eslint-issue/node_modules/eslint/lib/cli-engine/lint-result-cache.js:50:75)
    at LintResultCache.getCachedLintResults (.../next-eslint-issue/node_modules/eslint/lib/cli-engine/lint-result-cache.js:116:30)
    at .../next-eslint-issue/node_modules/eslint/lib/eslint/eslint.js:783:41
    at async Promise.all (index 0)
    at async ESLint.lintFiles (.../next-eslint-issue/node_modules/eslint/lib/eslint/eslint.js:759:25)

(see a minimal repro here: https://github.com/CvX/next-eslint-issue)

This happens because eslint is unable to serialize the parser object in the config. Adding metadata fixes that.

The issue was originally reported over at eslint repo in: eslint/eslint#19322

@ijjk
Copy link
Member

ijjk commented Jan 11, 2025

Allow CI Workflow Run

  • approve CI run for commit: 1b3bb96

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

claus added a commit to MadeInHaus/next-starter-ts that referenced this pull request Jan 24, 2025
The Next update might break eslint, this is a known issue:
vercel/next.js#74791
When using `eslint-config-next` on eslint 9.x with a flat config (as per next.js [docs](https://nextjs.org/docs/app/api-reference/config/eslint#specifying-a-root-directory-within-a-monorepo)) and with the `--cache` flag - eslint would fail:

```
> ./node_modules/.bin/eslint --cache

Oops! Something went wrong! :(

ESLint: 9.17.0

TypeError: Cannot serialize key "parse" in parser: Function values are not supported.
    at languageOptionsToJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:113:23)
    at languageOptionsToJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:107:35)
    at Config.toJSON (.../next-eslint-issue/node_modules/eslint/lib/config/config.js:260:30)
    at stringify (.../next-eslint-issue/node_modules/json-stable-stringify-without-jsonify/index.js:25:25)
    at module.exports (.../next-eslint-issue/node_modules/json-stable-stringify-without-jsonify/index.js:68:7)
    at hashOfConfigFor (.../next-eslint-issue/node_modules/eslint/lib/cli-engine/lint-result-cache.js:50:75)
    at LintResultCache.getCachedLintResults (.../next-eslint-issue/node_modules/eslint/lib/cli-engine/lint-result-cache.js:116:30)
    at .../next-eslint-issue/node_modules/eslint/lib/eslint/eslint.js:783:41
    at async Promise.all (index 0)
    at async ESLint.lintFiles (.../next-eslint-issue/node_modules/eslint/lib/eslint/eslint.js:759:25)
```

(see a minimal repro here: https://github.com/CvX/next-eslint-issue)

This happens because eslint is unable to serialize the `parser` object in the config. Adding metadata fixes that.

The issue was originally reported over at eslint repo in: eslint/eslint#19322
Copy link
Member

@devjiwonchoi devjiwonchoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

Confirmed the behavior on local.

@devjiwonchoi devjiwonchoi enabled auto-merge (squash) January 28, 2025 21:33
@ijjk
Copy link
Member

ijjk commented Jan 28, 2025

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary CvX/next.js fix-eslint Change
buildDuration 19.3s 16.9s N/A
buildDurationCached 16s 13.3s N/A
nodeModulesSize 392 MB 392 MB
nextStartRea..uration (ms) 453ms 448ms N/A
Client Bundles (main, webpack)
vercel/next.js canary CvX/next.js fix-eslint Change
5306-HASH.js gzip 54 kB 53.9 kB N/A
8276.HASH.js gzip 169 B 168 B N/A
8377-HASH.js gzip 5.46 kB 5.46 kB N/A
bccd1874-HASH.js gzip 52.9 kB 52.9 kB
framework-HASH.js gzip 57.5 kB 57.5 kB N/A
main-app-HASH.js gzip 240 B 243 B N/A
main-HASH.js gzip 34.5 kB 34.4 kB N/A
webpack-HASH.js gzip 1.71 kB 1.71 kB N/A
Overall change 52.9 kB 52.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary CvX/next.js fix-eslint Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Overall change 39.4 kB 39.4 kB
Client Pages
vercel/next.js canary CvX/next.js fix-eslint Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 193 B 193 B
amp-HASH.js gzip 512 B 510 B N/A
css-HASH.js gzip 343 B 342 B N/A
dynamic-HASH.js gzip 1.84 kB 1.84 kB
edge-ssr-HASH.js gzip 265 B 265 B
head-HASH.js gzip 363 B 362 B N/A
hooks-HASH.js gzip 393 B 392 B N/A
image-HASH.js gzip 4.59 kB 4.58 kB N/A
index-HASH.js gzip 268 B 268 B
link-HASH.js gzip 2.35 kB 2.35 kB N/A
routerDirect..HASH.js gzip 328 B 328 B
script-HASH.js gzip 397 B 397 B
withRouter-HASH.js gzip 323 B 326 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 3.59 kB 3.59 kB
Client Build Manifests
vercel/next.js canary CvX/next.js fix-eslint Change
_buildManifest.js gzip 748 B 747 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary CvX/next.js fix-eslint Change
index.html gzip 524 B 523 B N/A
link.html gzip 539 B 537 B N/A
withRouter.html gzip 520 B 520 B
Overall change 520 B 520 B
Edge SSR bundle Size
vercel/next.js canary CvX/next.js fix-eslint Change
edge-ssr.js gzip 129 kB 129 kB N/A
page.js gzip 210 kB 210 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary CvX/next.js fix-eslint Change
middleware-b..fest.js gzip 670 B 665 B N/A
middleware-r..fest.js gzip 155 B 156 B N/A
middleware.js gzip 31.3 kB 31.3 kB N/A
edge-runtime..pack.js gzip 844 B 844 B
Overall change 844 B 844 B
Next Runtimes
vercel/next.js canary CvX/next.js fix-eslint Change
app-page-exp...dev.js gzip 386 kB 386 kB N/A
app-page-exp..prod.js gzip 131 kB 131 kB
app-page-tur..prod.js gzip 144 kB 144 kB
app-page-tur..prod.js gzip 140 kB 140 kB
app-page.run...dev.js gzip 373 kB 373 kB
app-page.run..prod.js gzip 128 kB 128 kB
app-route-ex...dev.js gzip 39.4 kB 39.4 kB
app-route-ex..prod.js gzip 25 kB 25 kB
app-route-tu..prod.js gzip 25 kB 25 kB
app-route-tu..prod.js gzip 24.8 kB 24.8 kB
app-route.ru...dev.js gzip 41 kB 41 kB
app-route.ru..prod.js gzip 24.8 kB 24.8 kB
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
pages-api-tu..prod.js gzip 8.81 kB 8.81 kB
pages-api.ru...dev.js gzip 11.5 kB 11.5 kB
pages-api.ru..prod.js gzip 8.8 kB 8.8 kB
pages-turbo...prod.js gzip 21.6 kB 21.6 kB
pages.runtim...dev.js gzip 31.3 kB 31.3 kB
pages.runtim..prod.js gzip 21.6 kB 21.6 kB
server.runti..prod.js gzip 73.7 kB 73.7 kB
Overall change 1.27 MB 1.27 MB
build cache Overall increase ⚠️
vercel/next.js canary CvX/next.js fix-eslint Change
0.pack gzip 2.1 MB 2.1 MB ⚠️ +3.51 kB
index.pack gzip 76.3 kB 74.5 kB N/A
Overall change 2.1 MB 2.1 MB ⚠️ +3.51 kB
Diff details
Diff for main-HASH.js

Diff too large to display

Diff for app-page-exp..ntime.dev.js
failed to diff
Diff for app-page.runtime.dev.js
failed to diff
Commit: f849b80

@devjiwonchoi devjiwonchoi merged commit 6ff1336 into vercel:canary Jan 28, 2025
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants