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

Config controller #6001

Merged
merged 24 commits into from
Jun 20, 2024
Merged

Config controller #6001

merged 24 commits into from
Jun 20, 2024

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Jun 10, 2024

What this PR solves / how to test

This change removes some 'passthrough' config options from the BundleController PR and now uses expected StartDevWorkerOptions.

A thin implementation of the config controller has been implemented and integrated into the react-flow behind the existing -x-dev-env flag.

This change is covered by local+remote e2e tests both with+without the –x-dev-env flag. The dev-env fixture tests will be updated in a follow-up PR.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because: refactor behind experimental flag
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because: refactor behind experimental flag
Copy link

changeset-bot bot commented Jun 10, 2024

🦋 Changeset detected

Latest commit: 1cef88e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the e2e Run e2e tests on a PR label Jun 10, 2024
Copy link
Contributor

github-actions bot commented Jun 10, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-wrangler-6001

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6001/npm-package-wrangler-6001

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-wrangler-6001 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-create-cloudflare-6001 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-cloudflare-kv-asset-handler-6001
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-miniflare-6001
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-cloudflare-pages-shared-6001
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9596579703/npm-package-cloudflare-vitest-pool-workers-6001

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.61.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240610.1
workerd 1.20240610.1 1.20240610.1
workerd --version 1.20240610.1 2024-06-10

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@Jay-Cribz

This comment was marked as spam.

name: "worker-name",
},
_additionalModules: [],
script: { path: path.resolve("src/index.ts") },
Copy link
Contributor

Choose a reason for hiding this comment

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

As a user I would expect this filepath to be relative to the cwd. So the user shouldn't have to call path.resolve – the ConfigController should do that on their behalf

@RamIdeas RamIdeas marked this pull request as ready for review June 19, 2024 18:11
@RamIdeas RamIdeas requested a review from a team as a code owner June 19, 2024 18:11
packages/wrangler/src/dev.tsx Outdated Show resolved Hide resolved
packages/wrangler/src/dev/dev.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@andyjessop andyjessop left a comment

Choose a reason for hiding this comment

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

Looks great! A few tiny nits, but nothing to hold it back.

},
_additionalModules: [],
entrypoint: { path: path.resolve("src/index.ts") },
directory: path.resolve("src"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably, directory has some other meaning than just "parent directory of entrypoint"?

assert(config.entrypoint.path);
assert(config.directory);
assert(config.build?.format);
assert(config.build?.moduleRoot);
Copy link
Contributor

Choose a reason for hiding this comment

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

I love seeing these asserts everywhere.

cwd: config.build?.custom.workingDirectory,
command: config.build?.custom.command,
await runCustomBuild(config.entrypoint.path, relativeFile, {
cwd: config.build?.custom?.workingDirectory,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it correct that we can allow an undefined working directory here? I think it will default to the directory that the node process was launched from.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM - let's see how it flies!

@RamIdeas RamIdeas merged commit d39d595 into main Jun 20, 2024
21 checks passed
@RamIdeas RamIdeas deleted the config-controller branch June 20, 2024 13:48
devEnv.proxy.onBundleStart({
type: "bundleStart",
config: startDevWorkerOptions,
});
}, [devEnv, startDevWorkerOptions]);
}, [devEnv, startDevWorkerOptions, props.experimentalDevEnv]);
Copy link
Contributor

@threepointone threepointone Jun 20, 2024

Choose a reason for hiding this comment

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

@RamIdeas @penalosa What is the expected behaviour here? I think your comment was incomplete, so I don't understand this. Did you mean to write if(props.experimentalDevEnv) { devEnv.proxy.onBundleStart(/*...*/) }

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to write if(props.experimentalDevEnv) { devEnv.proxy.onBundleStart(/.../) }

No, explicitly the other way around. The faking of events is what wrangler main was doing. The experimental flag is newer and is the code path of real events within DevEnv.

Slightly confusing, so I put an if statement around it if(!props.experimentalDevEnv) { devEnv.proxy.onBundleStart(/*...*/) } (note the !) to be explicit but Samuel and I then then decided it was unnecessary as onBundleStart is not called unless props.experimentalDevEnv === false. So we settled on a comment instead. The prop left in the dependency array was a mistake but is not an issue since it is static and won't change. I'll make a follow-up PR to remove the extraneous dependency array item.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I'm going to put the if statement back just to be super explicit and avoid confusion. Even if it's redundant, it being code and not a comment will avoid confusion as to whether it is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed here #6116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
6 participants