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

interopRequireDefault called with undefined argument #3054

Open
camille-hdl opened this issue Aug 12, 2019 · 2 comments
Open

interopRequireDefault called with undefined argument #3054

camille-hdl opened this issue Aug 12, 2019 · 2 comments

Comments

@camille-hdl
Copy link

  • Rollup Version: 1.19.4
  • Operating System (or Browser): OSX
  • Node Version: 12.8.0

How Do We Reproduce?

Clone https://github.com/camille-hdl/rollup-yaml-bug and
follow the instructions in the readme (nothing weird: install, build, run)

In the yaml package, Collection and Pair are modules dependent on each other.
Pair requires Collection and Collection requires Pair.

Expected Behavior

In the output, Collection is available in Pair.

Actual Behavior

In var Pair_1 = createCommonjsModule(function (module, exports) {,
there is var _Collection = interopRequireDefault(Collection_1$1); when Collection_1$1 is undefined.

var Collection_1$1 = createCommonjsModule(function (module, exports) {... is defined later.

At some point in the execution of code inside Pair_1, this statement someVar instanceof _Collection.default throws, because _Collection.default is undefined.

Thank you for your time!

@lukastaegert
Copy link
Member

I think this is more an issue for rollup-plugin-commonjs than for Rollup core. The problem is that the current logic there does not work well for circuler references in commonjs modules. Unfortunately there is no easy fix, or to put it differently, there is a proposed solution by @guybedford but it will mean that tree-shaking will no longer work well for CommonJS code at the moment.

Still, I think at some point it would make sense to start implementing it, maybe in form of an alternative CJS plugin, and then later look at how we can get the tree-shaking up to speed here.

@camille-hdl
Copy link
Author

camille-hdl commented Aug 14, 2019

I understand, thanks for the explanation.

Should I open an issue in rollup-plugin-commonjs, or is this a known problem and opening another issue won't help?

edit: by that I mean: look for a workaround for now

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

2 participants