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

RenderedModule.removedExports is wrong when using export declarations #2834

Closed
Swatinem opened this issue May 3, 2019 · 2 comments · Fixed by #2835
Closed

RenderedModule.removedExports is wrong when using export declarations #2834

Swatinem opened this issue May 3, 2019 · 2 comments · Fixed by #2835

Comments

@Swatinem
Copy link
Contributor

Swatinem commented May 3, 2019

I’m not really sure if this is actually a bug or intended behavior.

The removedExports metadata refers to the export declaration that was removed.
However, if you have explicit export { foo } declarations, instead of export function foo() {}, it reports them as removed, since the export declaration itself will be rewritten by rollup, but the function declaration itself is still included and rendered.

In other words, export function foo() {} correctly reflects in removedExports / renderedExports whether the function is included in the output or not, however function foo() {} export { foo } will always list foo inside removedExports.

If this is indeed intended instead of a bug, it would be nice to provide a different implementation that really refers to the function/class/const/whatever that is being removed.

  • Rollup Version: 1.11.0
  • Operating System (or Browser): linux
  • Node Version: 11.14

How Do We Reproduce?

// main.js
export { a, c as b } from "./a";

// a.js
function a() {}
function b() {}
function c() {}

export { a, b, c };
// the `module` has: { "removedExports": ["a", "b", "c"] }

REPL Link

Expected Behavior

For the testcase above, removedExports for a.js should list only ["b"], corresponding to the function declaration which was actually removed.

Actual Behavior

For the testcase above, removedExports for a.js lists ["a", "b", "c"], which is kind of wrong, depending on your expectation on how removedExports should work.

It correctly lists all the export declarations, since they will be re-written by rollup someplace else, but the function declarations are still there.

@lukastaegert
Copy link
Member

Hi @Swatinem, indeed this is not intended. Hope to be able to look into this soon.

@Swatinem
Copy link
Contributor Author

Swatinem commented May 3, 2019

PR coming up in a sec :-)

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