Skip to content

Only use UMD or UMD2 externals for UMD libraryTarget. Resolve #5766#5784

Merged
sokra merged 1 commit intowebpack:masterfrom
NMinhNguyen:bugfix/only-use-umd-externals-for-umd-library-target
Oct 10, 2017
Merged

Only use UMD or UMD2 externals for UMD libraryTarget. Resolve #5766#5784
sokra merged 1 commit intowebpack:masterfrom
NMinhNguyen:bugfix/only-use-umd-externals-for-umd-library-target

Conversation

@NMinhNguyen
Copy link
Copy Markdown
Contributor

@NMinhNguyen NMinhNguyen commented Oct 9, 2017

What kind of change does this PR introduce?

Depending on if the issue I raised can be considered a bug, this is either a bugfix or a feature 😃

This change should remove require/define statements, whose output does not end up being used when using non-UMD externals (such as var) as seen in the diff here: NMinhNguyen/webpack-umd-with-var-externals-example@f0126c5

Did you add tests for your changes?

No, as there weren't any existing tests for UmdMainTemplatePlugin, but I'm happy to add them if necessary - I realise this is quite an important part of the code. All existing tests pass though.

Update: I was looking for a UmdMainTemplatePlugin.test.js file but I now realise this code is actually tested via ConfigTestCases - I need to familiarise myself with the existing tests but I fully intend on converting my repro into a test case, at the very least.

If relevant, link to documentation update:

Summary

Resolves #5766

Does this PR introduce a breaking change?

I don't believe it does - if anything, this should potentially prevent breakages?

Other information

@sokra suggested checking for m.type !== "umd" && m.type !== "umd2", but I went for m.type === "umd" || m.type === "umd2" (the logical opposite of the suggested change)

@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.

Copy link
Copy Markdown
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

Add a test case -> test/configCases

@webpack-bot
Copy link
Copy Markdown
Contributor

@NMinhNguyen Thanks for your update.

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

@sokra Please review the new changes.

@NMinhNguyen
Copy link
Copy Markdown
Contributor Author

NMinhNguyen commented Oct 10, 2017

@sokra Thanks for the review. I've added two test cases: one for UMD and one for UMD2. Please let me know if you require further changes (e.g. if the tests aren't quite right or you'd like to see more tests), I'll happily make them 😃

Copy link
Copy Markdown
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

Great

@NMinhNguyen
Copy link
Copy Markdown
Contributor Author

NMinhNguyen commented Oct 10, 2017

@sokra I've noticed that coverage decreased despite the tests, do you think it's something to worry about? I'm quite worried about this change having unintended side effects 😨

Update: the coverage thing may have been before I added tests? Seems back to normal now 😅

@sokra
Copy link
Copy Markdown
Member

sokra commented Oct 10, 2017

It takes a while until all optional CI test finished. This causes coverage report to be incorrect for some time.

@sokra sokra merged commit 289c19b into webpack:master Oct 10, 2017
@NMinhNguyen NMinhNguyen deleted the bugfix/only-use-umd-externals-for-umd-library-target branch October 10, 2017 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary require/define when using UMD builds with var externals

3 participants