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

Introduce bundling with esbuild, --hotswap and --watch #1321

Merged
merged 24 commits into from
Nov 30, 2023

Conversation

samchungy
Copy link
Contributor

@samchungy samchungy commented Nov 17, 2023

Related: #1311

Copy link

changeset-bot bot commented Nov 17, 2023

🦋 Changeset detected

Latest commit: d0c53bc

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

This PR includes changesets to release 1 package
Name Type
skuba 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

@@ -163,7 +163,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
},
},
"FunctionName": "serviceName",
"Handler": "app.handler",
"Handler": "index.handler",
Copy link
Contributor Author

@samchungy samchungy Nov 17, 2023

Choose a reason for hiding this comment

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

The handler value will be automatically prefixed with the bundled output file name, index., unless the handler value contains a . character, in which case the handler value is used as-is to allow for values needed by some Lambda extensions.

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html#configuring-esbuild

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should rename the source file to index.ts to align 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's very necessary, just a bundling thing tbh

runtime: aws_lambda.Runtime.NODEJS_20_X,
handler: 'app.handler',
Copy link
Contributor Author

@samchungy samchungy Nov 17, 2023

Choose a reason for hiding this comment

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

Alternatively, an entry file and handler can be specified:

new nodejs.NodejsFunction(this, 'MyFunction', {
 entry: '/path/to/my/file.ts', // accepts .js, .jsx, .cjs, .mjs, .ts, .tsx, .cts and .mts files
 handler: 'myExportedFunc', // defaults to 'handler'
});

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html#configuring-esbuild

@samchungy samchungy changed the title It's Bundling Time Introduce bundling with esbuild, --hotswap and --watch Nov 26, 2023
@samchungy samchungy marked this pull request as ready for review November 29, 2023 23:08
@samchungy samchungy requested review from a team as code owners November 29, 2023 23:08
@@ -4,6 +4,8 @@
"scripts": {
"build": "skuba build",
Copy link
Member

Choose a reason for hiding this comment

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

Does this render skuba build redundant for this template?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ruh roh looks like removing this causes issues with test-template

Copy link
Member

Choose a reason for hiding this comment

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

Heh, I think we can catch and ignore "Command not found" errors there 🙏

Copy link
Member

@72636c 72636c left a comment

Choose a reason for hiding this comment

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

👏

@@ -4,6 +4,8 @@
"scripts": {
"build": "skuba build",
"deploy": "cdk deploy appStack --require-approval never --context stage=${ENVIRONMENT}",
"deploy:hotswap": "yarn deploy --hotswap",
"deploy:watch": "yarn deploy:hotswap --watch",
"format": "skuba format",
"lint": "skuba lint",
"package": "yarn install --ignore-optional --ignore-scripts --modules-folder ./lib/node_modules --non-interactive --offline --production",
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this packaging malarkey?

@samchungy samchungy merged commit 3345668 into master Nov 30, 2023
19 checks passed
@samchungy samchungy deleted the its-bundling-time branch November 30, 2023 03:57
@seek-oss-ci seek-oss-ci mentioned this pull request Nov 30, 2023
72636c added a commit that referenced this pull request Dec 14, 2023
72636c added a commit that referenced this pull request Dec 14, 2023
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.

None yet

3 participants