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): refine the type of buildOptions #7876

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Jan 23, 2025

Minor change I figured out while exploring metafiles - my idea is to have an options to expose them so that users can get info about their bundle content.

The change:

Before this PR, we had:

const buildOptions: esbuild.BuildOptions & { metafile: true } = {
  // ...
  metafile: true,
  // ...
};

let result: esbuild.BuildResult<typeof buildOptions>;

Because the type of result depends on typeof buildOptions, we had to add & { metafile: true } so that the metafile specific props are exposed on the result.

This PR switches to:

const buildOptions = {
  // ...
  metafile: true,
  // ...
} satisfies esbuild.BuildOptions;

So that typeof buildOptions is not esbuild.BuildOptions but it's actual type and then metafile: true is inferred from the actual value.

There are multiple other properties on resultdepending on the actual type of the options, so this minor change is a nice thing to have.


  • 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: type only change
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: no user facing change

@vicb vicb requested a review from a team as a code owner January 23, 2025 06:49
Copy link

changeset-bot bot commented Jan 23, 2025

⚠️ No Changeset found

Latest commit: ebc6e25

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 23, 2025
Copy link
Contributor

github-actions bot commented Jan 23, 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/12957249221/npm-package-wrangler-7876

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

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

Or you can use npx with this latest build directly:

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

cloudflare-workers-bindings-extension:

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

create-cloudflare:

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

@cloudflare/kv-asset-handler:

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

miniflare:

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

@cloudflare/pages-shared:

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

@cloudflare/unenv-preset:

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

@cloudflare/vite-plugin:

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

@cloudflare/vitest-pool-workers:

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

@cloudflare/workers-editor-shared:

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

@cloudflare/workers-shared:

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

@cloudflare/workflows-shared:

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

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 removed the e2e Run e2e tests on a PR label Jan 23, 2025
@vicb vicb requested a review from petebacondarwin January 23, 2025 07:11
@vicb vicb force-pushed the esbuild-options branch 3 times, most recently from 941ed67 to e6b6245 Compare January 24, 2025 05:29
@vicb vicb merged commit 3213efe into main Jan 27, 2025
32 checks passed
@vicb vicb deleted the esbuild-options branch January 27, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants