fix: allowDynamicGlobs does not work properly on windows #69402
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.
fixes #51401
What?
This will resolve the issue where
unstable_allowDynamic
in 14.2.x does not meet expectations on Windows most of the time.Why?
This is because #60699 changed the implementation of
isDynamicCodeEvaluationAllowed
frommicromatch.isMatch()
topicomatch()
.Although the code appears identical, micromatch internally relies on
picomatch
version2.3.1
, while the modified next.js depends onpicomatch
version4.0.2
.During the major version changes, an important modification micromatch/picomatch#73 was made, which sometimes no longer automatically sets
opts.windows
, causing the path matching regex to be incorrect on Windows.As shown below:
How?
Alternatively, this library later added a feature to automatically set the windows option when creating a matcher https://github.com/micromatch/picomatch/blob/570df2f8781bc92e5fece2c16d9ff990c4a8d1da/index.js#L10.
So we can either manually pass opts.windows or pass empty opts to trigger the automatic setting.