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 HMR for files imported into routes #2077

Merged
merged 4 commits into from May 7, 2024
Merged

Fix HMR for files imported into routes #2077

merged 4 commits into from May 7, 2024

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented May 2, 2024

Reported here #2019 (comment)

To reproduce the issue:

Create app/test.ts with:

const MyTestFragment = `#graphql
fragment MyTestFragment on Shop {
  id
  name
  description
}
`;

export const MyTestQuery = `#graphql
${MyTestFragment}

query test {
  shop {
    ...MyTestFragment
  }
}
`;

Import it in root.tsx and use it:

function loader ...
  const test = await context.storefront.query(MyTestQuery);

 return defer({ test, ... })

...

 <div>{JSON.stringify(data.test.shop)}</div>

Change the fields in the fragment. The browser won't update automatically without the changes in this PR.


The real fix is just this line:

...(update.ssrInvalidates ?? []),

@frandiox frandiox requested a review from a team May 2, 2024 07:18
Copy link
Contributor

shopify bot commented May 2, 2024

Oxygen deployed a preview of your fd-fix-hmr branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment May 2, 2024 7:20 AM

Learn more about Hydrogen's GitHub integration.

@frandiox frandiox mentioned this pull request May 2, 2024
@jamalsoueidan
Copy link
Contributor

Which release is this to use it? 👯

@blittle
Copy link
Contributor

blittle commented May 2, 2024

@jamalsoueidan once it's merged to main, it will be available in a next tagged released on NPM. It will ship with our May release, which will be in the next week or two.

@jamalsoueidan
Copy link
Contributor

@jamalsoueidan once it's merged to main, it will be available in a next tagged released on NPM. It will ship with our May release, which will be in the next week or two.

Is it possible to use this locally right now? It's making my head explode....right now the fetcher.data is also cached...

Copy link
Contributor

@juanpprieto juanpprieto left a comment

Choose a reason for hiding this comment

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

Tested and working!

@frandiox frandiox merged commit e9ea189 into main May 7, 2024
13 checks passed
@frandiox frandiox deleted the fd-fix-hmr branch May 7, 2024 02:28
@jamalsoueidan
Copy link
Contributor

@juanpprieto How can I use this? which release version?

@frandiox
Copy link
Contributor Author

frandiox commented May 7, 2024

@jamalsoueidan Try npm i -D @shopify/mini-oxygen@next

@jamalsoueidan
Copy link
Contributor

jamalsoueidan@jamals-macbook-pro booking-store % npm run dev:tunnel

latest-hydrogen@1.0.7 dev:tunnel
shopify hydrogen dev --codegen --customer-account-push__unstable

Port 3000 is in use, trying another one...

Starting tunnel...

╭─ error ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ We couldn't find the cloudflare tunnel plugin │
│ │
│ To investigate the issue, examine this stack trace: │
│ at startTunnelPlugin (@shopify/cli-hydrogen/dist/lib/tunneling.js:12) │
│ throw new BugError(We couldn't find the ${provider} tunnel plugin); │
│ at async startTunnelAndPushConfig (@shopify/cli-hydrogen/dist/lib/dev-shared.js:53) │
│ const tunnel = await startTunnelPlugin(cliConfig, port, "cloudflare"); │
│ at all │
│ at async runViteDev (@shopify/cli-hydrogen/dist/commands/hydrogen/dev-vite.js:173) │
│ const [tunnel, cliCommand] = await Promise.all([ │
│ at run (@shopify/cli-hydrogen/dist/commands/hydrogen/dev.js:70) │
│ const { close } = await hasViteConfig(directory ?? process.cwd()) ? await import('./dev-vite.js').then( │
│ at async runCLI (@shopify/cli-kit/src/public/node/cli.ts:95) │
│ await run(undefined, config) │
│ at async runShopifyCLI (@shopify/cli/src/index.ts:42) │
│ await runCLI({ │

@juanpprieto
Copy link
Contributor

Port 3000 is in use, trying another one...

You have another Hydrogen instance or other process running on this port. Try to stop it and it should be ok

@jamalsoueidan
Copy link
Contributor

Port 3000 is in use, trying another one...

You have another Hydrogen instance or other process running on this port. Try to stop it and it should be ok

I will give it a try, maybe the process didn't terminate, thank you @juanpprieto

@jamalsoueidan
Copy link
Contributor

Port 3000 is in use, trying another one...

You have another Hydrogen instance or other process running on this port. Try to stop it and it should be ok

This was not the issue, this started to happen after:
Try npm i -D @shopify/mini-oxygen@next

@frandiox
Copy link
Contributor Author

frandiox commented May 9, 2024

@jamalsoueidan This has been released in mini-oxygen@3.0.2.

I'd suggest using h2 upgrade to get proper version of packages because the issue you posted sounds related to a version mismatch with other Shopify CLI things (tunneling, etc).

@michenly
Copy link
Contributor

michenly commented May 9, 2024

@jamalsoueidan, mini-oxygen@3.0.2 was released yesterday. Just in case there is a timing confusion on what you tired.

@jamalsoueidan
Copy link
Contributor

I will give it a try @frandiox @michenly

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.

None yet

5 participants