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-commonjs: ReferenceError: commonjsHelpers is not defined #468

Closed
vvanpo opened this issue Jun 22, 2020 · 6 comments
Closed

plugin-commonjs: ReferenceError: commonjsHelpers is not defined #468

vvanpo opened this issue Jun 22, 2020 · 6 comments

Comments

@vvanpo
Copy link

vvanpo commented Jun 22, 2020

  • Rollup Plugin Name: commonjs
  • Rollup Plugin Version: 13.0.0
  • Rollup Version: 2.17.0
  • Operating System (or Browser): macOS 10.15.5, Chrome 83
  • Node Version: 12.18.0

How Do We Reproduce?

Not being able to open issues without a reproduction is a burden. I'm working on a proprietary codebase that I can't just copy-paste here. I don't know the exact scenario that is causing some, not all, of my produced bundles to contain a reference to a nested property of a non-existent global variable. I would like to at least be able to open an issue so that we can discuss and investigate the problem.

What I can tell you is that for the bundles that have this problem, and cannot be loaded in the browser, they all contain the exact same line of code:

var freeGlobal = _typeof_1(commonjsGlobal) == 'object' && commonjsGlobal && commonjsHelpers.commonjsGlobal.Object === Object && commonjsGlobal;

If I alter the produced bundle to by changing the expression to remove this reference:

var freeGlobal = _typeof_1(commonjsGlobal) == 'object' && commonjsGlobal;

The bundle loads in the browser just fine and works as expected. Grepping through the bundles identifies the above line as the only reference to commonjsHelpers anywhere. There is no var commonjsHelpers = or the like anywhere to be found. Am I missing some kind of external dependency that bundles made using this plugin expect to be loaded?

Expected Behavior

Loading a Rollup bundle created using @rollup/plugin-commonjs should not cause reference errors.

Actual Behavior

ReferenceError: commonjsHelpers is not defined thrown in the console.

@shellscape
Copy link
Collaborator

Well you're a major version behind. Unfortunately reproductions are required for us to triage issues. If they're truly a burden, that means you're asking people who donate their free time to take on your burden, and that's not really fair. Please let us know if/when you add a repro and we'll reopen.

@vvanpo
Copy link
Author

vvanpo commented Jun 22, 2020

I wonder if this has something to do with the problem:

// TODO technically wrong since globals isn't populated yet, but ¯\_(ツ)_/¯

@shellscape What package am I behind on? The latest version of @rollup/plugin-commonjs is 13.0.0, which is the version I'm on. The latest version of rollup is 2.18.0, I'm on 2.17.0.

I would love to open a reproduction. But I'm not familiar with the codebase, I don't understand the problem, so I have no idea how to open a reproduction. I'll do my best to come up with one, but I imagine that will require me to find the source of the bug first, and at that point I would just open a PR.

Bug reports are a two-way street. You're asking a reporter to donate their time to write a good bug report, which isn't always easy, and the reporter is asking the maintainers to triage and help with the problem. When not enough information is known, like not being able to define a minimal reproduction, for example, being able to open an issue is still useful. It allows others to find the issue and understand that they're not the only ones with the problem, and it allows contributors who understand the codebase the chance to shed some light on possible causes. Even without repros I think allowing your users to open reports without friction is still valuable. Bug reporters are only trying to help the project improve, after all.

@shellscape
Copy link
Collaborator

Whoops, was looking at your node version.

Bug reports are a two-way street. You're asking a reporter to donate their time to write a good bug report, which isn't always easy, and the reporter is asking the maintainers to triage and help with the problem.

No, they aren't. This has been bikeshed'd a million times in open source and the project has set its standard. Please, I beg of you not to argue this point. (also light reading
https://liberamanifesto.com/)

If/when you're able to add a reproduction we'll happily dive in. Until then, the issue will remain closed but other users may comment.

@vvanpo
Copy link
Author

vvanpo commented Jun 23, 2020

I have a working reproduction: https://repl.it/repls/AliceblueFluffyMicroprogramming#input.js

After isolating the code that provokes the bug, I found that this was fixed the other day in rollup@2.17.1, I was on 2.17.0.

@jesse23
Copy link

jesse23 commented Jul 3, 2020

Same symptom but after upgrade all roll up dep to latest it woks for me

@lukastaegert
Copy link
Member

This was fixed in Rollup core via rollup/rollup#3643

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

No branches or pull requests

4 participants