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

fix: produces correct code when 'output.iife' is false & 'output.library.type' is 'umd', & it gives a warning to the users. #18929

Merged
merged 5 commits into from
Nov 20, 2024

Conversation

arkapratimc
Copy link
Contributor

fixes: #18687

What kind of change does this PR introduce?
This PR adds an IIFE wrapper around the returned code when a user sets output.iife = false & output.library.type = "umd".

Did you add tests for your changes?
Yes

Does this PR introduce a breaking change?
No

What needs to be documented once your changes are merged?
A warning note under https://webpack.js.org/configuration/output/#type-umd

fix: produces correct code when 'output.iife' is false & 'output.library.type' is 'umd', & it gives a warning to the users.
@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

return (
this.outputOptions.iife ||
(this.outputOptions.library && this.outputOptions.library.type === "umd")
);
Copy link
Member

@alexander-akait alexander-akait Nov 5, 2024

Choose a reason for hiding this comment

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

Don't change it, move check to the place where we have isIIFE check

external: "./non-external"
}
},
ignoreWarnings: [error => error.name === "FalseIifeUmdWarning"]
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test case where we check that a library works fine?

@alexander-akait alexander-akait merged commit b041f7a into webpack:main Nov 20, 2024
36 of 57 checks passed
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.

output.iife and output.library.type = 'umd' used together will generate wrong code
3 participants