-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix @shopify/hydrogen/experimental
imports
#2198
Conversation
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.
Nice! ✅
@@ -325,7 +325,7 @@ If your Store is based on the "Demo Store" tempate, and you are using the `test: | |||
} from '@shopify/hydrogen/platforms'; | |||
|
|||
// Platform entry handler | |||
export default function(request) { | |||
export default function (request) { |
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.
the sadness
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.
It's like a unique take on the "dual package hazard" haha.
A (probably worse, to be honest) alternative would be to add the "module"
condition, which Vite matches before "import"
and "require"
, but since you've said we don't even output to the node
folder for this, I think your change is better.
Description
Closes #1928
This makes tests in Shopify/hydrogen#2194 pass (cc @juanpprieto )
In-app logic such as components and hooks should always be imported from the
esnext
build. In fact, we don't even createdist/node/<in-app-stuff>
.The RSC plugin at some point runs
require.resolve('@shopify/hydrogen/experimental')
and, since we are running in the CJS version of Vite, it was resolving to@shopify/hydrogen/dist/node/experimental.js
instead of@shopify/hydrogen/dist/esnext/experimental.js
. With this change, it always resolves to the latter.We can't run the ESM version of Vite until we migrate user apps to
type: "module"
.@frehner Tagging you here because I think this might be interesting for you.
Before submitting the PR, please make sure you do the following:
fixes #123
)yarn changeset add
if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning