Skip to content

[wrangler] Include default module rules in generated types - #15573

Open
xgame92 wants to merge 10 commits into
cloudflare:mainfrom
xgame92:xgame92/fix-wrangler-types-default-rules
Open

xgame92 wants to merge 10 commits into
cloudflare:mainfrom
xgame92:xgame92/fix-wrangler-types-default-rules

Conversation

@xgame92

@xgame92 xgame92 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #8893

Summary

wrangler types now includes the built-in Text, Data, and CompiledWasm module declarations in generated declaration files, using the same effective rule resolution and fallthrough semantics as deployment.

Configured rules remain the only module declarations shown in console output. Effective rules are deduplicated after glob normalization, generated-file hashes include the effective declarations, and silent API/check paths do not emit rule warnings.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This fixes generated output to match existing deployment behavior.

Note

This is a contribution from an AI agent: OpenAI Codex.


Devin Review

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ee341c

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin 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-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 8, 2026
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team September 8, 2026 23:03
@workers-devprod

workers-devprod commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/gentle-files-type.md: [@cloudflare/wrangler]
  • packages/wrangler/e2e/types.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/type-generation.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/deployment-bundle/rules.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15573

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15573

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15573

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15573

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15573

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15573

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15573

miniflare

npm i https://pkg.pr.new/miniflare@15573

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15573

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15573

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15573

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15573

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15573

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15573

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15573

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15573

wrangler

npm i https://pkg.pr.new/wrangler@15573

commit: 6ee341c

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@xgame92

xgame92 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@petebacondarwin The latest CI run is green except for Vite Plugin Playground (windows-latest, vite-8). That job completed 93 test files successfully and then two unrelated suites timed out in the shared beforeAll hook after 50 seconds (assets/no-client-entry and worker-♫/log-level-error). The Wrangler-specific and cross-platform checks passed. I do not have repository permission to rerun the failed job; could a maintainer please rerun it when convenient? The PR is otherwise ready for codeowner review.

@dario-piotrowicz
dario-piotrowicz requested review from dario-piotrowicz and removed request for petebacondarwin September 10, 2026 09:19

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the f ix @xgame92 🙂

This PR generally looks ok to me, but I left a couple of small questions


const hash = createHash("sha256")
.update(consoleOutput)
.update(fileContent)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mh... this change seems unrelated to this PR 🤔

why are you changing the variable used here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change is related to the service-worker part of the PR. generatePerEnvTypeStrings() now deliberately returns different console and file representations: the console keeps the existing export {}; declare global preview, while the written declaration must remain a script so wildcard ambient modules are valid. The header hash is what wrangler types --check compares for staleness, so it needs to hash the actual fileContent returned as envTypes; hashing consoleOutput would miss changes in effective/default declarations. The same change is applied in the single-environment path, and includes effective module rules in the generated types hash covers it.

}),
];
const uniqueRuleSets = [
...new Map(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be a Set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Map is intentional here. A Set<ModuleTypeRuleSet> would compare object identity, so separately created top-level/named-environment objects with identical contents would not be deduplicated. JSON.stringify(ruleSet) provides the structural key, while the map value preserves the original typed object and first-seen order; using a Set<string> would require parsing or casting the values back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

wrangler types should include module declarations for default rules

3 participants