Skip to content
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

Merged
merged 3 commits into from Sep 29, 2022

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Sep 28, 2022

Description

Closes #1928

This makes tests in https://github.com/Shopify/hydrogen/pull/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 create dist/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:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@frandiox frandiox requested review from blittle and a team September 28, 2022 10:09
Copy link
Contributor

@lordofthecactus lordofthecactus left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sadness

Copy link
Contributor

@frehner frehner left a 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.

@frandiox frandiox merged commit f2e15b6 into v1.x-2022-07 Sep 29, 2022
@frandiox frandiox deleted the fd-fix-experimental-export branch September 29, 2022 07:53
This was referenced Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] <Form> component is not included in the production client bundle
5 participants