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

[Theme] Fix serving local assets that contain non-printable characters #4494

Merged
merged 8 commits into from
Sep 20, 2024

Conversation

frandiox
Copy link
Contributor

WHY are these changes introduced?

Closes #4479

WHAT is this pull request doing?

  • The main issue was caused by non-printable characters, which have a different length in disk vs in memory (string format). By transforming them to Buffer before reading the length we get the real disk value, which is required for content-length header.

  • Unrelated fixes: consider replacing CDN links in JS files with single quotes, etc.

How to test your changes?

Added a unit test to show it.

cc @Shopify/advanced-edits

Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

Copy link
Contributor

github-actions bot commented Sep 20, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.03% (+0.01% 🔼)
8391/11490
🟡 Branches
69.54% (+0.02% 🔼)
4092/5884
🟡 Functions 71.81% 2181/3037
🟡 Lines
73.38% (+0.01% 🔼)
7940/10821

Test suite run success

1890 tests passing in 858 suites.

Report generated by 🧪jest coverage report action from 0a6475b

Copy link
Contributor

@charlespwd charlespwd left a comment

Choose a reason for hiding this comment

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

This LGTM! Curious why we have to figure out the content-length for our server. That seems like a low level detail that the server lib usually provides for us.

(I'm really out of the loop here, so if what we're doing is is pretty low level, I understand!)

Those URL regex do be gnarly af though. Took me a couple of sips of coffee to get why they were modified :P

@frandiox
Copy link
Contributor Author

Thanks for the review! Yeah we are using a lowish level server called h3 and it requires us passing the content-length, otherwise the browser doesn't get the files properly.

Those URL regex do be gnarly af though. Took me a couple of sips of coffee to get why they were modified :P

Yep, just simplifying them a bit 😅 -- I think we'll probably forget about RegExps and just ask AI to change them for us 😂

@frandiox
Copy link
Contributor Author

/snapit

@frandiox frandiox added the #gsd:40767 Fortify local development experience for Liquid themes label Sep 20, 2024
Copy link
Contributor

🫰✨ Thanks @frandiox! Your snapshot has been published to npm.

Test the snapshot by intalling your package globally:

pnpm i -g @shopify/[email protected]

After installing, validate the version by running just shopify in your terminal
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#gsd:40767 Fortify local development experience for Liquid themes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: JS assets no longer work on theme dev on 127.0.0.1 since 3.67.0
2 participants