nuxt / typescript

TypeScript Support for Nuxt 2

Home Page:https://typescript.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consola got RangeError because of circular structure conversion in @nuxt/typescript-build

japboy opened this issue · comments

Describe the bug

Trying to create an Nuxt module for custom consola reporter using winston in my Nuxt app, then I got an error below when I run yarn dev:

error: RangeError: Maximum call stack size exceeded
    at mergeObject (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:79:21)
    at deepmerge (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:117:10)
    at cloneUnlessOtherwiseSpecified (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:34:5)
    at /path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:94:23
    at Array.forEach (<anonymous>)
    at mergeObject (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:86:18)
    at deepmerge (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:117:10)
    at cloneUnlessOtherwiseSpecified (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:34:5)
    at /path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:94:23
    at Array.forEach (<anonymous>)
    at mergeObject (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:86:18)
    at deepmerge (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:117:10)
    at cloneUnlessOtherwiseSpecified (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:34:5)
    at /path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:94:23
    at Array.forEach (<anonymous>)
    at mergeObject (/path/to/nuxt-app/node_modules/deepmerge/dist/cjs.js:86:18)","args":[]}

tl;dr It was because of fork-ts-checker-webpack-plugin. It uses deepmerge to merge option objects since v5.0.0 and deepmerge doesn't support circular structure which @nuxt/typescript-build depends.

I don't know how this should be fixed, but for now, I cannot create any custom loggers using JSON serialization.

Hopefully my English is good enough to explain the situation. Thanks.

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom consola reporter Nuxt module depending on JSON.stringify (like consola.JSONReporter)
  2. Run the Nuxt application
  3. See error
import consola from 'consola'
consola.setReporters([
  new consola.JSONReporter(),
])

Expected behavior
RangeError should not be occured with custom Consola Reporters.