Skip to content

refactor(wrangler): generate bundle meta file#7927

Closed
vicb wants to merge 2 commits into
mainfrom
meta-file
Closed

refactor(wrangler): generate bundle meta file#7927
vicb wants to merge 2 commits into
mainfrom
meta-file

Conversation

@vicb

@vicb vicb commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

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
@changeset-bot

changeset-bot Bot commented Jan 28, 2025

Copy link
Copy Markdown

⚠️ 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 ci:e2e Run wrangler + vite-plugin E2E tests on a pull request ci:no-changeset-required Skip pull request checks for a valid changeset labels Jan 28, 2025
@github-actions

github-actions Bot commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

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.


wrangler@3.106.0 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

vicb commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

I added a test.

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

@petebacondarwin

Copy link
Copy Markdown
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.

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

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

vicb commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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

vicb commented Jan 29, 2025

Copy link
Copy Markdown
Contributor Author

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.

@DaniFoldi

Copy link
Copy Markdown
Contributor

Hey @vicb,

Is there anything I can help with to land this? The feature request issue has been open for a long time, and I'd love to be able to see which dependency is increasing the bundle size (which is an important metric for startup time) without having to patch wrangler.

@vicb

vicb commented Mar 24, 2025

Copy link
Copy Markdown
Contributor Author

Hey @vicb,

Is there anything I can help with to land this? The feature request issue has been open for a long time, and I'd love to be able to see which dependency is increasing the bundle size (which is an important metric for startup time) without having to patch wrangler.

We need to add a --metafile flag to enable the generation of the file - do you want to get a stab at this?

@ItsWendell

ItsWendell commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

Hey @vicb,
Is there anything I can help with to land this? The feature request issue has been open for a long time, and I'd love to be able to see which dependency is increasing the bundle size (which is an important metric for startup time) without having to patch wrangler.

We need to add a --metafile flag to enable the generation of the file - do you want to get a stab at this?

@vicb I did a attempt here, #8716

I added a simple --metafile flag and adjusted / added some more tests. I was doubting whether to allow the --metafile flag to be string to change the location but didn't see any value in that in this case since the build process is highly managed by the worker itself anyway.

Curious on how I could best document this further for docs, and whether I missed a build path if you have any insights into this.

Also not sure what the best workflow is for me to contribute to this particular PR itself, I now opened a PR to be merged into this branch.

@vicb

vicb commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

Superseded by #8716

@vicb vicb closed this Apr 16, 2025
@github-project-automation github-project-automation Bot moved this from In Review to Done in workers-sdk Apr 16, 2025
@vicb vicb deleted the meta-file branch July 24, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run wrangler + vite-plugin E2E tests on a pull request ci:no-changeset-required Skip pull request checks for a valid changeset

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Option to output esbuild metafile

4 participants