[wrangler] Don't error when find_additional_modules discovers a file matching a shadowed rule#14388
Conversation
🦋 Changeset detectedLatest commit: 0f1669e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
The tests look good and cover both scenarios. The logic change is sound and well-tested. Let me do a final sanity check on whether there's any scenario where this behavioral change could be a backward-compatibility/silent-data-loss concern, and verify the second test rules get parsed with proper default rules included. The second test passes only one user rule with The change is well-scoped, correctly guarded by This is a clean, correct fix. LGTM |
|
All changesets look good |
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…matching a shadowed rule Module rules assign module types to imported files — they are not include/exclude filters. Previously, when find_additional_modules walked the filesystem and discovered a file whose only matching rule had been shadowed by an earlier rule of the same type (via fallthrough: false, or by being a default rule overridden by a user rule), wrangler would throw and fail the build. Discovered files that only match a shadowed rule are now silently skipped, with a debug-level log explaining what happened and how to include the file if desired. The direct-import path is unchanged: importing a file in code that only matches a shadowed rule is still a hard error. Fixes #14257
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
bfecfa4 to
0f1669e
Compare
…matching a shadowed rule (#14388)
Fixes #14257.
Module rules assign module types to imported files — they are not include/exclude filters. Previously, when
find_additional_moduleswalked the filesystem and discovered a file whose only matching rule had been shadowed by an earlier rule of the same type (viafallthrough: false, or by being a default rule overridden by a user-defined rule), wrangler would throw and fail the build.For example, with this config and
no_bundle: true, any.txt/.html/.sqlfile under the module root that did not match the user's glob would break the build, even when that file was never imported:With this change, discovered files that only match a shadowed rule are silently skipped, and a
debug-level log records each skip with a hint on how to include the file if desired (e.g. addfallthrough: trueto the earlier rule or broaden the user rule's globs). The direct-import path inmodule-collection.tsis unchanged: importing a file in code that only matches a shadowed rule is still a hard error, since the imported file genuinely needs a defined module type.Verified locally against the reporter's reproduction:
fallthrough: falseas a way to filter out files, and the only user-visible difference is that a misleading error is no longer raised for unimported files.