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: types and docs of umd external object #8286

Merged
merged 3 commits into from
Oct 31, 2024
Merged

Conversation

LingyuCoder
Copy link
Collaborator

@LingyuCoder LingyuCoder commented Oct 31, 2024

Summary

relate to #8248

Cause the external object value can only be used when libraryTarget or externalTarget is umd, and if it will throw error when commonjs or commonjs2 or root is not set. So we can use zod to validate the external object value.

The amd field is optional because it can generate define([]) when not set, but there is a bug here in rspack that generated define([null]). This pr also fix it.

Not close the issue because when libraryTarget is not umd, the external object value is also valid but will generate a wired code. For example, libraryTarget: "var" and react: { root: "React", commonjs: "react" } will generate var external_react_root_react_commonjs_react = undefined which can not actually work.

So we may need a better validation here to check libraryTarget and externals.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Oct 31, 2024
Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 9dbb75b
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67233511188cd40008d5d914

@LingyuCoder LingyuCoder changed the title fix: umd library plugin fix: types and docs of umd external object Oct 31, 2024
@LingyuCoder LingyuCoder marked this pull request as ready for review October 31, 2024 08:06
@LingyuCoder LingyuCoder merged commit 4a2ad1c into main Oct 31, 2024
34 checks passed
@LingyuCoder LingyuCoder deleted the fix/umd-library-plugin branch October 31, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants