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

[!] (plugin Typescript) RangeError: Maximum call stack size exceeded #116

Open
domoritz opened this issue Sep 7, 2020 · 12 comments
Open
Labels
Bug Something isn't working

Comments

@domoritz
Copy link
Contributor

domoritz commented Sep 7, 2020

  • Version: 1.3.4
  • Rollup Version: 2.26.10
  • Operating System and version (if applicable): macOS
  • Node Version (if applicable): 14.9.0
  • Does it work with tsc (if applicable): yes

Reproduction

Happening with https://github.com/vega/vega-lite/tree/0889ccc6a33a789f985ce0fb08f11f087a245ee4.

Expected Behavior

I expect to get a compiled bundle.

Actual Behavior

$ yarn build
yarn run v1.22.5
$ yarn build:only
$ rollup -c

src/index.ts → build/vega-lite.module.js...
(!) Circular dependencies
src/channeldef.ts -> src/bin.ts -> src/channeldef.ts
src/compile/common.ts -> src/channeldef.ts -> src/compile/common.ts
src/channeldef.ts -> src/compile/format.ts -> src/channeldef.ts
...and 43 more
[!] (plugin Typescript) RangeError: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at Object.includeSourceFile (/Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/module-merger.ts:117:21)
    at visitImportSpecifier (/Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/visitor/visit-import-specifier.ts:23:34)
    at visitNode (/Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/visitor/visit-node.ts:26:11)
    at /Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/module-merger.ts:40:8
    at visitNodes (/Users/dominik/Code/vega-lite/node_modules/typescript/lib/typescript.js:78371:48)
    at Object.visitEachChild (/Users/dominik/Code/vega-lite/node_modules/typescript/lib/typescript.js:78740:57)
    at Object.childContinuation (/Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/module-merger.ts:36:16)
    at visitNode (/Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/visitor/visit-node.ts:30:19)
    at /Users/dominik/Code/vega-lite/node_modules/@wessberg/rollup-plugin-ts/src/service/transformer/declaration-bundler/transformers/module-merger/module-merger.ts:40:8
    at visitNode (/Users/dominik/Code/vega-lite/node_modules/typescript/lib/typescript.js:78318:23)

Are the circular dependencies a problem here?

Note that compiling this code with rollup hasn't been a problem in the past. I used to compile typescript -> javascript and then use rollup to bundle the generated files.

@wessberg
Copy link
Owner

wessberg commented Sep 9, 2020

Hey there. Circular dependencies shouldn't be a problem, and in fact I have some passing tests for circular dependencies already. But yeah, it does look like something to do with circular deps. Thanks for spotting this. I would greatly appreciate it if you could narrow this down into a minimal repro that I can set up a simple test case for, as that will make it a lot easier for me track this down. In any case I'll see if I can make sense of it by cloning your repo and debugging a bit.

@domoritz
Copy link
Contributor Author

domoritz commented Sep 9, 2020

Thanks for looking into this. For now, I switched to a combination of rollup-plugin-typescript2 and babel in https://github.com/vega/vega-lite/pull/6852/files#diff-ff6e5f22a9c7e66987b19c0199636480. However, since I use your plugin in https://github.com/vega/vega-embed/blob/master/rollup.config.js, https://github.com/vega/vega-tooltip/blob/master/rollup.config.js, and https://github.com/vega/vega-themes/blob/master/rollup.config.js, it would be great to switch to your bundler for Vega-Lite as well.

Since the traceback shows declaration-bundler, I guess this problem may be related to declaration bundling. I'm having some separate issues with declaration bundles (#117) and wonder whether I am doing something wrong that causes these two issues.

@wessberg
Copy link
Owner

wessberg commented Sep 9, 2020

I won't be able to investigate it based on your repro if there is no active branch or PR on which the error is reproducible using @wessberg/rollup-plugin-ts. Is there a way for you to either push a new branch to git based on the state before your last commit or, preferably, prepare a smaller repro (in case you have one) so that I can investigate? :-)

@domoritz
Copy link
Contributor Author

domoritz commented Sep 9, 2020

I made vega/vega-lite#6859 for you. Does that work?

@wessberg wessberg added the Bug Something isn't working label Sep 9, 2020
@wessberg
Copy link
Owner

wessberg commented Sep 9, 2020

Yes, that looks good. Thanks, I'll look into it!

@wessberg
Copy link
Owner

wessberg commented Sep 9, 2020

Thanks to your repo, I've managed to reproduce the problem. Feel free to close the PR now, since I have what I need and have prepared a test case. I'll fix it as soon as possible.

@domoritz
Copy link
Contributor Author

domoritz commented Sep 9, 2020

Awesome!

@lolleko
Copy link

lolleko commented Jun 22, 2021

Encountering the same issue on latest version (1.4.0), any update on this?

@ghost
Copy link

ghost commented Jul 22, 2021

Any updates?

@darklight9811
Copy link

@wessberg this is still occuring and I'm trying to make sense out of this, but the deeper I look, the weirder it gets

@archfz
Copy link

archfz commented Mar 26, 2022

I also have this issue. This is only reproducing for commonjs output format. But I suppose that is because of esm + preserveModules declarations aren't merged. On 1.2.27 it doesn't reproduce. Is it possible to merge declarations even in preserveModules?

@AndriiSherman
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants