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

AMD modules unnecessarily uses exports when preservedModules is enabled #3258

Closed
mgol opened this issue Nov 25, 2019 · 1 comment · Fixed by #3265
Closed

AMD modules unnecessarily uses exports when preservedModules is enabled #3258

mgol opened this issue Nov 25, 2019 · 1 comment · Fixed by #3265

Comments

@mgol
Copy link

mgol commented Nov 25, 2019

Expected Behavior / Situation

When compiling source from ES modules to AMD with --preserveModules, I'd expect default exports in the module to be transformed into unwrapped return values in the resulting AMD module. An example:

Input:

export default window.document;

Output:

define( function() {
	"use strict";

	return window.document;
} );

Actual Behavior / Situation

The module using a default export is converted to one putting what was exported into exports.default:

Input:

export default window.document;

Output:

define(['exports'], function (exports) { 'use strict';

	var document = window.document;

	exports.default = document;

});

Check with Rollup 1.25.2 & 1.27.5.

Modification Proposal

At least when a module doesn't use named exports but only default ones, I'd expect the generated AMD modules to be using the usual return-style exports.

This is, in particular, important to jQuery which wants to transform its new ES modules-based source back to AMD keeping previous idiomatic semantics of those modules.

Ref #2979 (comment)

@lukastaegert
Copy link
Member

Fix at #3265

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

Successfully merging a pull request may close this issue.

2 participants