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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pnp does not use
node_modules
directories for resolution. Package location can't be assumed (see.pnp.cjs
example below). Using context paths here simply prevents pnp from resolving the package.Initially I intended to use
pnpapi
to lookip the package that owns the path (not thenode_modules
but the location with.storybook/main.js
) and from the context of that package lookupreact/jsx-runtime
, which would resolve to react instance required by user.However, I see no way to get storybook application location from here.
So, the option I opted for is to attempt to resolve
react
first and if it can't be resolved at all then attempt to resolve without context, so pnp can kick in. This will always resolve to the react required by storybook but, still, it is better than automatic JSX detection not working at all for yarn pnp.Normally, if
react
can be resolved (with npm or yarn v1) as originally implemented with context then it can attempt to resolve jsx runtime from that foundreact
package.Take note of the
packageLocation
field in this.pnp.cjs
excerpt:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example has patched version with this change applied locally. Unpatched version is next to it in
.yarn/cache/@storybook-react-npm-6.1.18-e398bb22b4-f1d86f8c2c.zip
No way that can be resolved with existing code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm well aware of how PnP works, the solution here is to change what the context is, it should be the file that is getting transformed as shown in #12899 (comment)