Open hcz1 opened 1 month ago
Hi, normally sam build
is capable of building your Typescript project using esbuild
as a build method (docs). Using tsc
to perform a "preprocessing" build, then using sam build
will have unintended side effects depending on the project structure.
Namely, that sam build
will have it's own build process that may or may not include the dist
folder. sam build
will call npm pack
under the hood to create a "production" ready copy of the project. npm pack
will ignore any files that is listed in either .gitignore
, or .npmignore
, preferring to use .npmignore
if both files exist. This may be the root cause of the issue you are facing.
Can you provide a sample project that utilizes your build process to help us further diagnose?
Thank you for getting back to me. I’m currently on holiday and will get back to this the week of 9th September.
On Wed, 28 Aug 2024 at 20:07, Lucas @.***> wrote:
Hi, normally sam build is capable of building your Typescript project using esbuild as a build methods (docs https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-build-typescript.html). Using tsc to perform a "preprocessing" build, then using sam build will have unintended side effects depending on the project structure.
Namely, that sam build will have it's own build process that may or may not include the dist folder. sam build will call npm pack under the hood to create a "production" ready copy of the project. npm pack will ignore any files that is listed in either .gitignore, or .npmignore, preferring to use .npmignore if both files exist. This may be the root cause of the issue you are facing.
Can you provide a sample project that utilizes your build process to help us further diagnose?
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-sam-cli/issues/7402#issuecomment-2316066361, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSIDVMPBHPQZH7EHK3K4YLZTYNW3AVCNFSM6AAAAABNBSVQ4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJWGA3DMMZWGE . You are receiving this because you authored the thread.Message ID: @.***>
Title:
sam build
Ignores Files indist/
Directory When Specified in.gitignore
Description
Issue Summary
When specifying the
dist/
directory in the.gitignore
file, thesam build
process also ignores the files in this directory. This behaviour causes issues when the build output is expected to be in thedist/
directory, as the necessary files are not included in the build.Steps to Reproduce
.gitignore
file with the following content:dist/
directory.sam build
command.Expected Behaviour
The sam build process should include the files in the
dist/
directory, even if it is specified in the.gitignore
file, as the.gitignore
file should only affect Git operations.Actual Behaviour
The sam build process ignores the files in the
dist/
directory, causing the dist folder not to be copied to.aws-sam/build/function_name/
.Workaround
Removing the
dist/
entry from the.gitignore
file allows the sam build process to include the necessary files, but this is not an ideal solution as it causes thedist/
directory to be tracked by Git.Environment
SAM CLI Version: 1.123.0 Node.js Version: v20.9.0 OS: 14.3 (23D56)
Additional Context
My build process is to run
tsc && sam build && sam deploy
, the lambda handler is set todist/path_to_handler
.