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

Import prettier statically for bundling #2146

Merged
merged 3 commits into from
May 24, 2024
Merged

Import prettier statically for bundling #2146

merged 3 commits into from
May 24, 2024

Conversation

isaacroldan
Copy link
Contributor

@isaacroldan isaacroldan commented May 23, 2024

WHY are these changes introduced?

  • Importing prettier dynamically (with import('prettier')) doesn't work well with esbuild bundling

WHAT is this pull request doing?

  • Change prettier from dynamic import to static import.

HOW to test your changes?

npx shopify hydrogen init should trigger this code and work

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor

shopify bot commented May 23, 2024

Oxygen deployed a preview of your fix-prettier-import branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM
vite ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment May 23, 202410:42 AM

Learn more about Hydrogen's GitHub integration.

@isaacroldan isaacroldan changed the title Use prettier.default to call prettier functions Import prettier statically for bundling May 23, 2024
@isaacroldan isaacroldan marked this pull request as ready for review May 23, 2024 10:44
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run npm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

@graygilmore graygilmore requested a review from frandiox May 23, 2024 16:22
Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

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

Makes sense to me but would love for @frandiox to weigh in since he did it this way in the beginning.

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

Yeah, the reason to import it dynamically is that Prettier v2 is in CJS and it would slow down CLI startup. But since we are going to bundle it, it doesn't matter anymore 👍

@frandiox frandiox merged commit 53cc94d into main May 24, 2024
14 checks passed
@frandiox frandiox deleted the fix-prettier-import branch May 24, 2024 05:16
michenly pushed a commit that referenced this pull request May 24, 2024
* Use prettier.default to call prettier

* Import prettier as a module

* Format code
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.

3 participants