You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My build process successfully outputs webpack .js artifacts. However, when I deploy to AWS, only the original TypeScript files get uploaded, not the transpiled .js and .map.js files shown below. I cannot for the life of me figure out why this is happening.
But when I deploy the stack, the deployed lambda packages only include the orginal TypeScript files, not the webpack bundles.
Example:
Ignore the fact that the file is named app instead of index -- this is because I've been trying different things and happened to grab a screenshot before I switched to using index. The important part is that the .ts source code is getting deployed instead of the .js files that are generated in the .aws-sam/build directory.
Here is my webpack config. Note that I added an --env flag to webpack to more easily switch between template.prod.yaml and template.dev.yaml.
Any help in understanding why SAM is deploying TypeScript files despite webpack correctly outputting ECMAScript files to .aws-sam/build/ would be appreciated!
The text was updated successfully, but these errors were encountered:
sam deploy --template-file .aws-sam/build/template.yaml --config-file ~/dev/shopify-monitor/samconfig.toml --config-env dev --guided
For some reason, specifying the relative path to the template and the absolute path to samconfig.toml resolved the issue. SAM is deploying the transpiled .js code from .aws-sam/build/ now.
I tried passing a relative path to samconfig.toml but that did not work:
> sam deploy --template-file .aws-sam/build/template.yaml --config-file ./samconfig.toml --config-env dev --guided
Error: Config file ./samconfig.toml does not exist or could not be read!
This leaves some outstanding questions:
Why is samconfig.toml not in the relative path of the SAM CLI when I execute sam deploy ... from the
same directory? I've never had to set the absolute path to the samconfig.toml file before.
Same question. Why do I need to explicitly specify the path to .aws-sam/build/template.yaml? I've never had to set the path to .aws-sam/build/template.yaml before.
To clarify, here is the process I am following to deploy my code:
Build the stack webpack-cli --env prod
Deploy the stack: sam deploy --config-env dev
Step 1 definitively builds the intended stack. We can verify this by looking at the contents of .aws-sam/builld/ after Step 1 and checking that only bundled JS files are present. This is the case.
Step 2 seems to lack harmony with Step 1. While Step 2 technically works in that AWS SAM successfully deploys the defined resources to AWS, it somehow deploys the original TypeScript files instead of the JS bundles that were generated in Step 1.
Originally SAM CLI had separate steps for build, package and deploy. The plugin replaces the build step in that original 3 step process. My best guess is that it's incompatible with the newer guided deployment that sam deploy offers. That would make sense because SAM is going to use it's own build step instead of this plugin.
My build process successfully outputs webpack
.js
artifacts. However, when I deploy to AWS, only the original TypeScript files get uploaded, not the transpiled.js
and.map.js
files shown below. I cannot for the life of me figure out why this is happening.Running
webpack-cli
produces:But when I deploy the stack, the deployed lambda packages only include the orginal TypeScript files, not the webpack bundles.
Example:
Ignore the fact that the file is named
app
instead ofindex
-- this is because I've been trying different things and happened to grab a screenshot before I switched to usingindex
. The important part is that the.ts
source code is getting deployed instead of the.js
files that are generated in the.aws-sam/build
directory.Here is my webpack config. Note that I added an
--env
flag to webpack to more easily switch betweentemplate.prod.yaml
andtemplate.dev.yaml
.webpack.config.cjs:
To deploy, I run
sam deploy --config-env dev
orsam deploy --config-env default
.samconfig.toml:
Here is how my lambda files are organized:
Here are the
CodeUri
andHandler
properties declared in my SAM templates:Any help in understanding why SAM is deploying TypeScript files despite webpack correctly outputting ECMAScript files to
.aws-sam/build/
would be appreciated!The text was updated successfully, but these errors were encountered: