Skip to content

Conversation

dom96
Copy link
Contributor

@dom96 dom96 commented Oct 8, 2025

Implements a new python_modules_excludes wrangler config field. The user can specify a list of globs in that field to exclude them from being vendored. By default every file in python_modules is included but for certain packages they contain so much stuff that sometimes it's good to be able to filter it out, especially since our bundle sizes are limited.



Test Plan

pnpm run test --filter wrangler -- -t "should print vendor modules correctly in table" src/__tests__/deploy.test.ts

cd packages/wrangler/
pnpm run build
pnpm test:e2e --run --testNamePattern="can exclude vendored module during"

Copy link

changeset-bot bot commented Oct 8, 2025

🦋 Changeset detected

Latest commit: fbade0e

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

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

Copy link

pkg-pr-new bot commented Oct 8, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10927

@cloudflare/workers-editor-shared

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

wrangler

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

commit: fbade0e

@dom96 dom96 force-pushed the dominik/customise-python-modules branch 2 times, most recently from 63ae386 to 466f746 Compare October 9, 2025 10:33
@dom96 dom96 marked this pull request as ready for review October 9, 2025 10:44
@dom96 dom96 requested a review from a team as a code owner October 9, 2025 10:44
from js import Response, console
def on_fetch(request):
console.log(f"hello {mul(2,3)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you mix console.log() and print()? Is there a reason not to choose one and stick with it?

try:
import excluded_module
print("excluded_module found")
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
except:
except ImportError:

writeWranglerConfig({
main: "src/index.py",
compatibility_flags: ["python_workers"],
python_modules_excludes: ["**/*.pyc"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably we will eventually want to exclude these by default. But that can be left to followup work.

Copy link
Contributor

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Looks very reasonable to me. Thanks @dom96!

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.

2 participants