Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] ignore nested node_modules, .next, .nuxt, .git & .vercel #12807

Merged
merged 3 commits into from
Jan 2, 2025

Conversation

QuiiBz
Copy link
Member

@QuiiBz QuiiBz commented Dec 29, 2024

By default, the Python builder only ignores the root node_modules from the zip output. Many customers have Next.js or Nuxt.js apps along with their Python Vercel Functions, where nested node_modules folders and potentially .next / .nuxt build output folders could also be included in the zip, increasing its size for nothing.

An example of that is our recent AI SDK Python Streaming template, where we had to ignore the .next manually because it was blowing up the size of the Python function: https://github.com/vercel-labs/ai-sdk-preview-python-streaming/blob/07a632d6fb60c2c09e725fc3d5be1c2a353855bd/vercel.json#L4

This PR updates the default ignore list to ignore:

  • nested node_modules
  • nested .next & .nuxt folders
  • .git & .vercel

Copy link

changeset-bot bot commented Dec 29, 2024

🦋 Changeset detected

Latest commit: 8faf079

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

This PR includes changesets to release 2 packages
Name Type
@vercel/python Minor
vercel 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

Comment on lines +202 to +208
: [
'.git/**',
'.vercel/**',
'**/node_modules/**',
'**/.next/**',
'**/.nuxt/**',
],
Copy link
Contributor

@developerjhp developerjhp Jan 2, 2025

Choose a reason for hiding this comment

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

Hi Tom, I was reviewing this PR, and I noticed the ignore rules are directly defined in the code. I was wondering if it might be worth considering an alternative approach by separating the default ignore rules into a constant, as shown below:

const DEFAULT_IGNORE_FOLDERS = [
    '.git/**',
    '.vercel/**',
    '**/node_modules/**',
    '**/.next/**',
    '**/.nuxt/**',
];


........
ignore: config?.excludeFiles ?? DEFAULT_IGNORE_FOLDERS

This change could potentially improve the readability and maintainability of the code by clearly isolating the default rules, making them easier to manage and update if needed.

Of course, this is just a suggestion, and I'd love to hear your thoughts on whether this aligns with the team's preferences or goals for this functionality. Let me know if you think this would be helpful!

@QuiiBz QuiiBz added this pull request to the merge queue Jan 2, 2025
Merged via the queue into main with commit c11c355 Jan 2, 2025
171 checks passed
@QuiiBz QuiiBz deleted the python/ignore-nested-node-modules-next-nuxt-git branch January 2, 2025 15:49
TooTallNate pushed a commit that referenced this pull request Jan 2, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@9.0.0

### Major Changes

- Change getPathOverrideForPackageManager() to use detectedLockfile
argument ([#12749](#12749))

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

- add support for `images.qualities`
([#12792](#12792))

## @vercel/edge@1.2.0

### Minor Changes

- moved methods to @vercel/functions
([#12758](#12758))

## @vercel/python@4.6.0

### Minor Changes

- Update default ignored folders from the zip output:
([#12807](#12807))

    -   nested `node_modules`
    -   nested `.next` & `.nuxt`
    -   `.git` & `.vercel`

### Patch Changes

- Support VERCEL_IPC_PATH along with VERCEL_IPC_FD
([#12800](#12800))

## vercel@39.2.4

### Patch Changes

- Added root params support for pages powered by partial prerendering
([#12764](#12764))

- Update `@vercel/fun` to v1.1.2
([#12791](#12791))

- Update "follow-redirects" to v1.15.9 to avoid security vulnerability
report ([#12771](#12771))

- [deploy] make deploy --target case sensitive
([#12747](#12747))

- add support for `images.qualities`
([#12792](#12792))

- Updated dependencies
\[[`79a7374cdd8e734f01ee1b9ad6662182b9090bc0`](79a7374),
[`6150fbe18ef7fb4a6591a87a40c4452b2c9923ce`](6150fbe),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`c11c3553f30bf00501f7136cfb5fda9f9c4b4fb1`](c11c355),
[`99a2899b9f3e1868752690f75bd1ca587f53ffdd`](99a2899),
[`c31d0813fc9668859c81ec0002e502aa200eec95`](c31d081)]:
    -   @vercel/next@4.4.1
    -   @vercel/static-build@2.5.40
    -   @vercel/build-utils@9.0.0
    -   @vercel/hydrogen@1.0.10
    -   @vercel/redwood@2.1.11
    -   @vercel/remix-builder@5.0.1
    -   @vercel/python@4.6.0
    -   @vercel/node@5.0.1

## @vercel/client@13.5.3

### Patch Changes

- Updated dependencies
\[[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`c31d0813fc9668859c81ec0002e502aa200eec95`](c31d081)]:
    -   @vercel/build-utils@9.0.0

## @vercel/firewall@0.1.5

### Patch Changes

- remove "next" in firewall to resolve vulnerability report
([#12688](#12688))

## @vercel/fs-detectors@5.3.2

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

## @vercel/gatsby-plugin-vercel-builder@2.0.62

### Patch Changes

- Updated dependencies
\[[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`c31d0813fc9668859c81ec0002e502aa200eec95`](c31d081)]:
    -   @vercel/build-utils@9.0.0

## @vercel/hydrogen@1.0.10

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

## @vercel/next@4.4.1

### Patch Changes

- Added root params support for pages powered by partial prerendering
([#12764](#12764))

- Fix next data route replacing
([#12782](#12782))

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

- add support for `images.qualities`
([#12792](#12792))

## @vercel/node@5.0.1

### Patch Changes

- Updated dependencies
\[[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`c31d0813fc9668859c81ec0002e502aa200eec95`](c31d081)]:
    -   @vercel/build-utils@9.0.0

## @vercel/redwood@2.1.11

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

## @vercel/remix-builder@5.0.1

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

## @vercel/static-build@2.5.40

### Patch Changes

- Refactor build-util usage to reuse detected lockfile
([#12749](#12749))

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.62

## @vercel-internals/types@3.0.3

### Patch Changes

- Updated dependencies
\[[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`7adf5367054bdd86e7ecb9791290fffeb756fcfb`](7adf536),
[`c31d0813fc9668859c81ec0002e502aa200eec95`](c31d081)]:
    -   @vercel/build-utils@9.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants