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

Aggregating modules fails when exporting default from another module along with other named exports #2992

Closed
ravijayaramappa opened this issue Jul 11, 2019 · 3 comments · Fixed by #3084

Comments

@ravijayaramappa
Copy link

ravijayaramappa commented Jul 11, 2019

  • Rollup Version: 1.7.4
  • Operating System (or Browser): macOS Mojave
  • Node Version: 10.16.0

How Do We Reproduce?

When an aggregating module exports the default from another module along with named properties from a different module, the generated output will through a ReferenceError upon invocation.

Example:

export { default } from 'x/foo';
export { namedProp } from 'x/bar';

REPL repro

Importing a default and named export from the same module seems to work fine ✅
Example:

export { default, namedProp } from 'x/foo';

Expected Behavior

amd format

define(['exports', 'x/foo', 'x/bar'], function (exports, foo, bar) { 'use strict';
	foo = foo && foo.hasOwnProperty('default') ? foo['default'] : foo;

	exports.default = foo;
	Object.defineProperty(exports, 'namedProp', {
		enumerable: true,
		get: function () {
			return bar.namedProp;
		}
	});
	Object.defineProperty(exports, '__esModule', { value: true });
});

Actual Behavior

amd format

define(['exports', 'x/foo', 'x/bar'], function (exports, foo, bar) { 'use strict';
	foo = foo && foo.hasOwnProperty('default') ? foo['default'] : foo;

	exports.default = foo__default; // <-- this will result in a ReferenceError
	Object.defineProperty(exports, 'namedProp', {
		enumerable: true,
		get: function () {
			return bar.namedProp;
		}
	});
	Object.defineProperty(exports, '__esModule', { value: true });
});

This could be related to a similar issue reported prior: #2977

@lukastaegert
Copy link
Member

It is certainly related to #2977 but it seems to manifest slightly differently so I will keep it as a separate issue. Hope we can fix them together soon!

@lukastaegert
Copy link
Member

I’m working on a fix for this but due to other issues it may take another week to complete.

@lukastaegert
Copy link
Member

Fix at #3084

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

Successfully merging a pull request may close this issue.

2 participants