Skip to content

Maximum call stack size exceeded #58

@WesleyEdwards

Description

@WesleyEdwards

Versions

  • @originjs/vite-plugin-commonjs: v1.0.3
  • node: v22.17.1 (also reproduced on v18.13.1 and v22.17.1)

Reproduction

This bug was found while using vite-plugin-commonjs in the Kotlin-Vite library.

Steps to reproduce

Details and Steps to reproduce can be found here:
https://gitlab.com/opensavvy/automation/kotlin-vite/-/issues/57

I believe that the issue is within the removeComments function in libs.ts file. Refer to this attached file to see an isolated example

What is actually happening?

Right now when using this plugin and running vite with a sufficiently large project, it throws this error:

[vite] Internal server error: Maximum call stack size exceeded
  Plugin: originjs:commonjs
  File: /home/wesley/projects/kiteui/example-app/build/vite/dev/child/kotlin/kiteui-example-app.js
      at RegExpStringIterator.next (<anonymous>)
      at removeComments (/home/wesley/projects/kiteui/build/js/node_modules/@originjs/vite-plugin-commonjs/lib/lib.js:51:14)
      at Object.transformRequire (/home/wesley/projects/kiteui/build/js/node_modules/@originjs/vite-plugin-commonjs/lib/lib.js:19:12)
      at TransformPluginContext.transform (/home/wesley/projects/kiteui/build/js/node_modules/@originjs/vite-plugin-commonjs/lib/index.js:40:32)
      at EnvironmentPluginContainer.transform (file:///home/wesley/projects/kiteui/build/js/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:47598:19)
      at async loadAndTransform (file:///home/wesley/projects/kiteui/build/js/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:41305:27)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions