[wrangler] fix: respect find_additional_modules when no_bundle is set#14315
Conversation
🦋 Changeset detectedLatest commit: 2d89372 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 |
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Incomplete fix: runBuild in use-esbuild.ts ignores findAdditionalModules when noBundle is true (packages/wrangler/src/dev/use-esbuild.ts:115-127)
The PR fixes noBundleWorker and its call sites in deploy.ts, versions/upload.ts, preview.ts, and BundlerController.ts#runCustomBuild, but misses the parallel code path in use-esbuild.ts. The getAdditionalModules() function at packages/wrangler/src/dev/use-esbuild.ts:115-126 always calls doFindAdditionalModules when noBundle is true, ignoring the findAdditionalModules parameter that was already passed into runBuild (line 55/83). This path is reached during wrangler dev without a custom build command, via BundlerController.ts:248 which passes findAdditionalModules: config.build?.findAdditionalModules (line 266). As a result, setting find_additional_modules = false with no_bundle = true will still scan for and attach additional modules during wrangler dev.
When no_bundle was true, wrangler always collected additional modules even if find_additional_modules was explicitly set to false. Pass the flag through to noBundleWorker so the config setting is honoured, and add tests covering both the default (collect) and opt-out (skip) cases.
137b2ad to
afcd119
Compare
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: |
The non-custom-build dev path in use-esbuild.ts was calling doFindAdditionalModules unconditionally when noBundle was true, ignoring the findAdditionalModules flag. Gate it behind findAdditionalModules !== false to match the other call sites.
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Fixes #10063.
When
no_bundle = trueis configured, wrangler was always collecting and attaching additional modules even iffind_additional_moduleswas explicitly set tofalse. The setting was being ignored in the no-bundle path.The fix adds a
findAdditionalModulesEnabledparameter tonoBundleWorker(defaults tofalse) and updates all four call sites —deploy.ts,versions/upload.ts,BundlerController.ts, andpreview.ts— to pass the config value through. Whenfind_additional_modulesis not set, the default isfalse, which is consistent with how the bundled code path already behaves (see the comment "moduleCollector doesn't get used when noBundle is set, so findAdditionalModules always defaults to false").I noticed the comment in
deploy.tsandupload.tsalready says "findAdditionalModules always defaults to false" for the module collector, but the actualnoBundleWorkercall was not respecting that — it was scanning regardless.findAdditionalModuleswhen the config says to. The existing unit tests fornoBundleWorkercover the happy path. The behaviour when the flag isfalseis identical to returning[], which is whatbundleWorkeralso does whenfindAdditionalModulesisfalse.find_additional_modulesalready documents that setting it tofalseshould skip additional module discovery.