Update netlify adapter to integrate includeFiles and excludeFiles options#13194
Update netlify adapter to integrate includeFiles and excludeFiles options#13194ematipico merged 9 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 194a27b 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 |
7d6936e to
a1bcac7
Compare
ematipico
left a comment
There was a problem hiding this comment.
Thank you! I left some questions, and also we should make the docs a bit more explicit because there's some important information that we should expose to users.
| if (_config.vite.assetsInclude) { | ||
| const mergeGlobbedIncludes = (globPattern: unknown) => { | ||
| if (typeof globPattern === 'string') { | ||
| const entries = glob.sync(globPattern).map((p) => pathToFileURL(p)); |
There was a problem hiding this comment.
Two questions:
- Why aren't these assets resolved from the same
cwdof line 263? - Why don't we ignore
exclude?
There was a problem hiding this comment.
- Why aren't these assets resolved from the same
cwdof line 263?
That is a good question; this code were taken from the vercel integration not sure why that difference does currently exists...
Maybe it does have sense to update this and use the getFilesByGlob function to have the same behavior on either includeFiles and vite.assetsInclude.
- Why don't we ignore
exclude?
Similar to previous response; this code were taken from the vercel integration but I think there isn't any specific reason to don't exclude the files therefore we can add it.
I just wanted to keep the most consistency between integration, for those reasons I decided to keep this code as is. Let me know if any modifications are needed, and I'll gladly update it 👌
There was a problem hiding this comment.
It looks like the code is been there for a long time, let's keep it as is. Thank you for taking time for investigating and providing me with a proper response!
There was a problem hiding this comment.
While the Vercel code has been there for a long time, this is new code for Netlify, so I think it would make sense to make it consistent with the cwd at least
| includeFiles?: string[]; | ||
|
|
||
| /** Exclude any files from the bundling process that would otherwise be included. */ | ||
| excludeFiles?: string[]; |
There was a problem hiding this comment.
There's an important piece of information that is missing from the inline JS docs. The code resolves the files from the rootDir. This information must be shared with the docs. This information is also missing from the docs PR (I checked).
What does that mean? If a user adds an absolute path, this might fail. We should provide this information.
There was a problem hiding this comment.
I've added a note on the JS Docs 93c2acf#diff-c395613459736f27ff2bafd942481c8713261bd79538e1234994f9d3d4d0be5bR148
Also I will make sure to update the docs to add this important information 👍
There was a problem hiding this comment.
Can you add it to the excludeFiles block too
| if (_config.vite.assetsInclude) { | ||
| const mergeGlobbedIncludes = (globPattern: unknown) => { | ||
| if (typeof globPattern === 'string') { | ||
| const entries = glob.sync(globPattern).map((p) => pathToFileURL(p)); |
There was a problem hiding this comment.
It looks like the code is been there for a long time, let's keep it as is. Thank you for taking time for investigating and providing me with a proper response!
sarah11918
left a comment
There was a problem hiding this comment.
Just left an idea of a sample changeset, for your consideration!
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
This PR implements the changes previously proposed in withastro/adapters#515, migrated to work within this repository's structure. The core functionality remains the same, with adjustments made to align with this repository.
Changes
When trying Netlify SSR with Astro, I wasn't able to get the
included_filesoption to work. After investigating, I realized that theincludeFilesandexcludeFilesfunctionalities, similar to what Vercel provides, were necessary to include additional files during the build process.In this PR, I have implemented the integration to add these options:
includeFilesandexcludeFilesoptions to the integration, mirroring Vercel's functionality.includeFiles: Allows users to explicitly specify files or directories to be bundled with their function. Useful for avoiding missing files in production.excludeFiles: Enables users to specify files or directories to be excluded from the deployment. Helps minimize bundle size.Testing
includeFilesandexcludeFileswith various configurations to ensure:includeFilesare bundled correctly.excludeFilesare omitted as expected.Docs
includeFilesandexcludeFileson netlify adapter.