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

element.addExportedVariables is not a function #2750

Closed
MichaelRando opened this issue Mar 12, 2019 · 11 comments
Closed

element.addExportedVariables is not a function #2750

MichaelRando opened this issue Mar 12, 2019 · 11 comments

Comments

@MichaelRando
Copy link

  • Rollup Version: rollup v1.6.0
  • Operating System (or Browser): osx
  • Node Version: v10.15.0

How Do We Reproduce?

I don't have a repro case yet, all I did was take my project output format from 'iife' and tried 'system'. It worked okay for small subset of files; but when I tried to compile my main file I got:

[!] TypeError: element.addExportedVariables is not a function
TypeError: element.addExportedVariables is not a function
    at ArrayPattern.addExportedVariables (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:10824:25)
    at AssignmentExpression.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:11021:27)
    at ExpressionStatement.NodeBase.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:10367:23)
    at ExpressionStatement.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:11794:33)
    at renderStatementList (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:4106:25)
    at BlockStatement.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:10910:13)
    at IfStatement.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:11985:33)
    at renderStatementList (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:4106:25)
    at SwitchCase.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:13284:13)
    at SwitchStatement.NodeBase.render (/Users/mscholz/webclient/node_modules/rollup/dist/rollup.js:10363:31)

I don't have much to go on here; I was wondering if there are flags I could pass on the command line that would tell us more about which file or plugin is failing here, or if any maintainers wanted to guide my hands to reducing this down to a minimal repro.

@lukastaegert
Copy link
Member

Hi @MichaelRando, thanks for the issue. Even though a proper repro would be better, the stack trace already looks very helpful. Will do some poking around array patterns to see if I can identify the issue.

@lukastaegert
Copy link
Member

Ok, so initial poking did not reveal anything yet, but maybe we can find the culprit together. There is a special logic for SystemJS that eventually helps us to update exported variables in pattern assignments which is apparently faulty.

Basically what this stack trace tells me that there is something that can legally be a part of array patterns that I overlooked (or are you using any special acorn plugins to allow advanced syntax?).

More precisely, the culprit appears to be something like

([someVariable] = someOtherVariable);

but with something substantially different inside the pattern on the left side that I apparently overlooked. It could also be nested:

someFunctionCall([someVariable] = someOtherVariable);

Maybe if you search for something like ] = , which should not be too common. What I need is the complete expression that contains the pattern assignment. To test if an expression is the problem, you should be able to just put comments around it and see if Rollup compiles. Maybe the expression appears multiple times? Unfortunately it is not possible to identify the position in the code where this happens without patching Rollup itself. If everything else fails, I could try to create such a patched version that should at least be able to give us the file where this happens and maybe the involved code.

@lukastaegert
Copy link
Member

Actually it was not too difficult to patch the code. Could you try

npm install rollup/rollup#gh-2750-debug-array-pattern

and try to bundle your code to SystemJS? It should now output some additional information before the error occurs.

@MichaelRando
Copy link
Author

So, I've done what I could to investigate the repro; and I've lost it.

My two hypotheses are that either 1. my build setup had an abnormality that cleared up upon a reset or 2. The code I was compiling that day had some errors that were expressed by that callstack, but were not committed to revision control and so going back to that hash and retracing my steps does not yield the same result.

I'm building the codebase with 'esm' and 'system' without errors since Friday against 1.6, this issue should be put away.

@lukastaegert
Copy link
Member

Thanks for checking anyway. If it pops up again, just open another issue. I like to treat Rollup crashes with high priority!

@wessberg
Copy link
Contributor

I'm having this issue as well in Rollup v1.6.0 (breaks CI). Can we please reopen this issue and continue investigation?

Screen Shot 2019-03-19 at 3 54 56 PM

@lukastaegert
Copy link
Member

Sure thing. As mentioned above, could you try

npm install rollup/rollup#gh-2750-debug-array-pattern

try to bundle your code to SystemJS and paste what is logged to the console?

@lukastaegert lukastaegert reopened this Mar 19, 2019
@wessberg
Copy link
Contributor

Yes, of course! Here it is:
Screen Shot 2019-03-19 at 5 03 25 PM

@lukastaegert
Copy link
Member

I can honestly say that after years of JavaScript, I learned something fundamentally new today. Thanks for digging into this. Fix at #2760.

@wessberg
Copy link
Contributor

Wow, that was incredibly fast. Thanks so much for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants