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

refactor(wrangler): generate bundle meta file #7927

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

refactor(wrangler): generate bundle meta file #7927

wants to merge 2 commits into from

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Jan 28, 2025

Fixes #4633

Hey @penalosa or @petebacondarwin, could you please point me to the best place to add tests for that?
I tested locally and it works fine but we need to add test.
Thanks!

I'll also add a changeset before merging.


  • 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:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: I'll update the docs once merged

@vicb vicb requested a review from a team as a code owner January 28, 2025 08:25
Copy link

changeset-bot bot commented Jan 28, 2025

⚠️ No Changeset found

Latest commit: 539ab96

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

@vicb vicb added e2e Run e2e tests on a PR no-changeset-required labels Jan 28, 2025
Copy link
Contributor

github-actions bot commented Jan 28, 2025

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/13011893122/npm-package-wrangler-7927

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-wrangler-7927 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-workers-bindings-extension-7927 -O ./cloudflare-workers-bindings-extension.0.0.0-v5f70f83bb.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v5f70f83bb.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-create-cloudflare-7927 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-kv-asset-handler-7927

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-miniflare-7927

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-pages-shared-7927

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-unenv-preset-7927

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-vite-plugin-7927

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-vitest-pool-workers-7927

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-workers-editor-shared-7927

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-workers-shared-7927

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13011893122/npm-package-cloudflare-workflows-shared-7927

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.20250124.0
workerd 1.20250124.0 1.20250124.0
workerd --version 1.20250124.0 2025-01-24

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

@vicb vicb requested a review from a team as a code owner January 28, 2025 13:49
@vicb
Copy link
Contributor Author

vicb commented Jan 28, 2025

I added a test.

Could anybody please confirm that generating the file in the outdir will not get it uploaded?

@petebacondarwin
Copy link
Contributor

I added a test.

Could anybody please confirm that generating the file in the outdir will not get it uploaded?

That will depend upon whether it matches a "additional module rule" and whether find_additional_modules and/or no_bundle are true.

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.

I think this should be explicitly opt-in rather than inferred from the outdir.
E.g. --metafile or similar

The opt-in would default to false. A value equivalent to true could default to putting the metafile in the outdir if no other value is provided.

E.g. --metafile=path/to/metafile.json.

@vicb
Copy link
Contributor Author

vicb commented Jan 28, 2025

Thanks for the review @petebacondarwin, I have a few follow up questions:

Could anybody please confirm that generating the file in the outdir will not get it uploaded?

That will depend upon whether it matches a "additional module rule" and whether find_additional_modules and/or no_bundle are true.

Could you please point me to the code?
(That was my fear but the additional modules should be looking for files in the source folder, not the outdir?)

I think this should be explicitly opt-in rather than inferred from the outdir.
E.g. --metafile=path/to/metafile.json

--metafile=path/to/metafile.json was my first thought.

Then I thought that we already have an outdir and we can re-use that, so it should probably just be --metafile (i.e. only to enable but do not offer to override the path).

I also see that we always generate the metadata so the only override here is to dump to disk. So I'm wondering if we really need that --metafile at all - which is what I implemented in this PR. I think simpler is better but happy to change that if needed.

@petebacondarwin
Copy link
Contributor

Could you please point me to the code?
(That was my fear but the additional modules should be looking for files in the source folder, not the outdir?)

It is not uncommon to run wrangler build to generate a compiled Worker and then wrangler deploy with no_bundle on to deploy from that output directory.

@petebacondarwin
Copy link
Contributor

I also see that we always generate the metadata so the only override here is to dump to disk. So I'm wondering if we really need that --metafile at all - which is what I implemented in this PR. I think simpler is better but happy to change that if needed.

Yes I was proposing that we have a --metafile option that by itself would dump the metadata to disk in the outdir directory. I think this should still be opt-in, i.e. not to dump the file unless this flag is on.

@vicb
Copy link
Contributor Author

vicb commented Jan 29, 2025

It is not uncommon to run wrangler build to generate a compiled Worker and then wrangler deploy with no_bundle on to deploy from that output directory.

Oh I see, good point - and in this case the .map is not an issue because it doesn't match any of the implicit rules.

I'll update the PR to add --metafile later this week.

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 no-changeset-required
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Option to output esbuild metafile
2 participants