Skip to content

fix: types and docs of umd external object#8286

Merged
LingyuCoder merged 3 commits intomainfrom
fix/umd-library-plugin
Oct 31, 2024
Merged

fix: types and docs of umd external object#8286
LingyuCoder merged 3 commits intomainfrom
fix/umd-library-plugin

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

@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
@netlify
Copy link
Copy Markdown

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 force-pushed the fix/umd-library-plugin branch from 30fbdb1 to 1756c28 Compare October 31, 2024 07:10
@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 requested a review from ahabhgk October 31, 2024 08:06
@LingyuCoder LingyuCoder merged commit 4a2ad1c into main Oct 31, 2024
@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