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

chore: fix entrypoint logic and refactor #6971

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Conversation

andyjessop
Copy link
Contributor

@andyjessop andyjessop commented Oct 15, 2024

What this PR solves / how to test

Fixes #000. This was supposed to fix (but doesn't) #6353. However, it does do a refactor that improves the code base and adds a relevant test case.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because: Small refactor
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Bug fix

Copy link

changeset-bot bot commented Oct 15, 2024

⚠️ No Changeset found

Latest commit: c70c4eb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

github-actions bot commented Oct 15, 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/11364537784/npm-package-wrangler-6971

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

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

Or you can use npx with this latest build directly:

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

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241004.0
workerd 1.20241011.1 1.20241011.1
workerd --version 1.20241011.1 2024-10-11

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

@andyjessop andyjessop marked this pull request as ready for review October 15, 2024 09:28
@andyjessop andyjessop requested a review from a team as a code owner October 15, 2024 09:28
@andyjessop andyjessop added the e2e Run e2e tests on a PR label Oct 15, 2024
@penalosa
Copy link
Contributor

I'm pretty sure the fix for the original issue is to change https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/src/dev/miniflare.ts#L291-L292 to const modulesRoot = config.bundle.entry.moduleRoot;

@andyjessop
Copy link
Contributor Author

I'm pretty sure the fix for the original issue is to change https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/src/dev/miniflare.ts#L291-L292 to const modulesRoot = config.bundle.entry.moduleRoot;

Or better yet, make miniflare respect the config setting? We have build.moduleRoot in the config object, we just don't pass it through when generating the miniflare config.

@penalosa
Copy link
Contributor

Or better yet, make miniflare respect the config setting?

I'm not sure I get the distinction here—config.bundle.entry is the config setting. It comes from https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/src/dev/use-esbuild.ts#L233. Once we get rid of the non --x-dev-env flow we can probably pass it through to miniflare.ts from the LocalRuntimeController more cleanly

@andyjessop
Copy link
Contributor Author

@penalosa ah, got it. Thanks for pointing that out 👍

Config is a bit messy and could do with some consolidation I think.

@andyjessop
Copy link
Contributor Author

I'm pretty sure the fix for the original issue is to change https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/src/dev/miniflare.ts#L291-L292 to const modulesRoot = config.bundle.entry.moduleRoot;

@penalosa, I think this change is causing the E2E tests to fail. From what I can tell, the config.bundle.entry.moduleRoot is referring to the worker definition, but the scriptPath was referring to the bundled code (located at .wrangler/tmp/dev-[hash]/index.js.

@andyjessop
Copy link
Contributor Author

Given that the fix is different from the contents of this PR, I've reverted the last fix so that the branch points to where it was approved.

@andyjessop andyjessop merged commit b5fa4a6 into main Oct 16, 2024
48 of 50 checks passed
@andyjessop andyjessop deleted the aj/entry-point-fix branch October 16, 2024 13:03
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
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants