Ignore resolve requests that start with ! #1359
Merged
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.
This PR fixes an issue where the
@embroider/webpack
plugin is trying to resolve things that it probably shouldn't. This problem and the proposed solution was discussed at the webpack weekly meetings and I only have a vague understanding of the cause but I'll do my best to explain in the background section below.Note: I know that this implementation is likely a bit naive and we can probably fix it a better way.
I will also spend a little bit of time to see if I can create a failing test that this will actually fix but I have a feeling I might need a bit of help considering I don't fully understand the issue 🙈Edit: this PR now has a failing test that is fixed with the implementation 🎉
Background
To replicate this issue you can run this reproduction repo https://github.com/mainmatter/embroider-peerdependency-bug against the current
main
of embroider. When you follow the steps in that reproduction you will get the following error:dropping a debugger where the error is being thrown you can check the call stack and the issue is related to the fact that the
preHandleExternal()
is called with arequest.specifier
of the following:This issue seems to have been created due to recent refactoring and the consensus seems to be that we just don't want this webpack plugin to deal with anything that starts with a
!
and it should fall back to the other resolvers in the stack.Note: we first said that we should add this to the ignore list in
embroider/packages/webpack/src/webpack-resolver-plugin.ts
Line 108 in 22d54eb
When I first came across this bug I was able to identify that it was first introduced in this commit: 6f56f0d which is titled
improved self-name resolution
. I'm not sure exactly what this is trying to do 🤷 but it's the info I was able to glean.