Skip to content

Commit 33949ab

Browse files
authored
Adds docs for python_module_excludes. (#25725)
1 parent 730c5cf commit 33949ab

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/content/docs/workers/wrangler/configuration.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,28 @@ Any files that match `rules` will also be included as unbundled, external module
11281128

11291129
See https://developers.cloudflare.com/workers/wrangler/bundling/ for more details and examples.
11301130

1131+
### Python Workers
1132+
1133+
By default, Python Workers bundle the files and folders in `python_modules` at the root of your Worker (alongside your wrangler config file).
1134+
The files in this directory represent your vendored packages and is where the pywrangler tool copies packages into. In some cases, you
1135+
may find that the files in this folder are too large and if your worker doesn't require them then they just grow your bundle size for
1136+
no reason.
1137+
1138+
To fix this, you can exclude certain files from being included. To do this use the `python_modules.excludes` option, for example:
1139+
1140+
<WranglerConfig>
1141+
1142+
```toml title="wrangler.toml"
1143+
[python_modules]
1144+
excludes = ["**/*.pyc", "**/__pycache__"]
1145+
```
1146+
1147+
</WranglerConfig>
1148+
1149+
This will exclude any .pyc files and `__pycache__` directories inside any subdirectory in `python_modules`.
1150+
1151+
By default, `python_modules.excludes` is set to `["**/*.pyc"]`, so be sure to include this when setting it to a different value.
1152+
11311153
## Local development settings
11321154

11331155
:::note

0 commit comments

Comments
 (0)