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

Extract workerd logic in mini-oxygen package #1891

Merged
merged 39 commits into from
Apr 1, 2024
Merged

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Mar 22, 2024

This PR moves shared logic related to workerd into @shopify/mini-oxygen. This package used to contain the Node.js sandbox logic and it was soft-deprecated. With these changes, it now contains both Node.js sandbox and workerd runtimes. Some of the benefits:

  • The CLI does not require installing the runtime anymore, which makes it faster to create projects globally because we are not installing 60-120mb for the runtime.
  • The future Vite plugin package will also depend on this runtime package instead of copying code.
  • If a developer wants to deploy to other platforms, they can choose not to install MiniOxygen and still use the CLI for other utilities.
  • Also, as a side effect, it's possible to run other apps using MiniOxygen standalone without Hydrogen CLI.

Copy link
Contributor

shopify bot commented Mar 22, 2024

Oxygen deployed a preview of your fd-workerd-mini-oxygen branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM
vite ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment April 1, 202411:06 AM

Learn more about Hydrogen's GitHub integration.

@frandiox frandiox requested a review from a team March 25, 2024 18:49
@frandiox frandiox marked this pull request as ready for review March 25, 2024 18:49
Comment on lines -24 to -25
"@types/recursive-readdir": "^2.2.1",
"@types/stack-trace": "^0.0.30",
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is what you were saying yesterday, all of these deps can be removed from the CLI, which will make npm create @shopify/hydrogen faster? And instead they are deps to the new package, which is a peer dep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. The main dependency here is miniflare (123MB): https://pkg-size.dev/miniflare@3
Now this is only installed when doing npm i in the template, not when the CLI is installed globally with npm create @shopify/hydrogen.

Comment on lines +200 to 202
const liveReload = shouldLiveReload
? await setupLiveReload(remixConfig.dev?.port ?? 8002)
: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth being a part of the changeset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, this is only used in the tests to make them more robust (it failed if you already had a dev server up locally because port 8002 is occupied).

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

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

I'm seeing these [object Object] console.log's when I dev startup (not preview) the skeleton template:

image

packages/cli/src/lib/mini-oxygen/workerd.ts Show resolved Hide resolved
packages/cli/src/lib/mini-oxygen/workerd.ts Show resolved Hide resolved
packages/mini-oxygen/README.md Show resolved Hide resolved
@frandiox
Copy link
Contributor Author

I'm seeing these [object Object] console.log's when I dev startup (not preview) the skeleton template:

Fixed 👍

@frandiox frandiox merged commit 140e476 into main Apr 1, 2024
13 checks passed
@frandiox frandiox deleted the fd-workerd-mini-oxygen branch April 1, 2024 11:10
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.

2 participants