Skip to content

Use add() to append items to activeExports set in HarmonyExportImporedSpecifierDependency - #6950

Merged
sokra merged 8 commits into
webpack:masterfrom
mohsen1:set-concat
Apr 9, 2018
Merged

sokra merged 8 commits into
webpack:masterfrom
mohsen1:set-concat

Conversation

@mohsen1

@mohsen1 mohsen1 commented Apr 4, 2018

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?
Bug fix

Did you add tests for your changes?
no

If relevant, link to documentation update:
n/a

Summary
This is part of #6862

TypeScript compiler found that we're calling concat on a Set here

Does this PR introduce a breaking change?
No

Other information

@ooflorent

Copy link
Copy Markdown
Contributor

What about the length test just above it?

content +=
"if(" +
JSON.stringify(activeExports.concat("default")) +
JSON.stringify(activeExports.add("default")) +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeExports must be serialized into an array:

Array.from(activeExports).concat("default")

ooflorent
ooflorent previously approved these changes Apr 4, 2018

@sokra sokra left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this fixes a bug, which was previously undiscovered, we should add a test case

content +=
"if(" +
JSON.stringify(activeExports.concat("default")) +
JSON.stringify(Array.from(activeExports.add("default"))) +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is correct, but using the return value of add is kind of weird to me.

Better use JSON.stringify(Array.from(activeExports).concat("default"))

@ooflorent ooflorent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use concat instead of add

@webpack-bot

Copy link
Copy Markdown
Contributor

@mohsen1 Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@ooflorent Please review the new changes.

return "dynamic-reexport";
}
};
should(instance.getContent(dep)).to.eql("???");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where can I learn what this module does? I'm absolutely clueless how this code is structured

@sokra

sokra commented Apr 6, 2018

Copy link
Copy Markdown
Member

Only integration test contribute to coverage. Unittests are just for fun.

Code like this could trigger that change:

export var x = 1;
export * from ",/cjs";
// cjs.js
module.exports = { x: 2, y: 3 };


import {x, y} from "./a";

it("namespace export as from commonjs should override named export", function() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sokra @domenic
Actually I'm not sure what the spec is here. Should namespace export override the named export?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the spec says * export should have lower precedence than direct export. Order of exports doesn't matter here.

So the correct result would be x = 1

@mohsen1 mohsen1 mentioned this pull request Apr 8, 2018
27 tasks done

import {x, y} from "./a";

it("namespace export as from commonjs should override named export", function() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the spec says * export should have lower precedence than direct export. Order of exports doesn't matter here.

So the correct result would be x = 1

@sokra

sokra commented Apr 9, 2018

Copy link
Copy Markdown
Member

I fixed it for you

@webpack-bot

Copy link
Copy Markdown
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra
sokra merged commit 1d35f36 into webpack:master Apr 9, 2018
@sokra

sokra commented Apr 9, 2018

Copy link
Copy Markdown
Member

Thanks

mhegazy added a commit to mhegazy/webpack that referenced this pull request Apr 23, 2018
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 this pull request may close these issues.

4 participants