fix: required amd in umd external object#8369
Merged
LingyuCoder merged 3 commits intomainfrom Nov 8, 2024
Merged
Conversation
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
chenjiahan
reviewed
Nov 7, 2024
chenjiahan
reviewed
Nov 8, 2024
chenjiahan
approved these changes
Nov 8, 2024
5 tasks
This was referenced Jun 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
https://github.com/web-infra-dev/rspack/pull/8286/files#r1831012797
Cause lots of projects use object item of
externalswhen notumdand it can actually work well. For example:so if we just add a strict object validation to object item of
externals, it will be a breaking change to these projects.The object item of
externalsshould be validate according to the values ofoutput.library.type/output.libraryTargetandexternalsType. Only ifoutput.library.type/output.libraryTargetis set toumdandexternalsTypeis not set or also set toumd, the object item inexternalsshould be handle as an umd dependency.We can add a new ZodType named
ZodCrossFieldsOptionsto validate the object item inexternals. In its_parsemethod we can get the zod context, and then get its root context through itsparentfield. Then we can do some checking cross configuration options and make sure that the object item inexternalsshould only be validated when it is really handle as an umd dependency.But there is a trick in
ZodUnion. Theparentfield is set tonullhere. Not sure if it is a bug or not. So we need to override theZodUnion._parseto pass theparentcontext to children like otherZodTypedoes.Checklist