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

feat(lambda-nodejs): external and install modules #8681

Merged
merged 10 commits into from Jun 29, 2020

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Jun 22, 2020

Add support for:

  • external modules: modules that should not be bundled. Defaults to
    aws-sdk.
  • install modules: modules that should not be bundled but included in
    the node_modules folder of the Lambda package. Those modules are
    installed in a Lambda compatible Docker image with the right installer
    (npm or yarn) based on lock file detection.

Closes #6323
Closes #7912


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add support for:
* external modules: modules that should not be bundled. Defaults to
`aws-sdk`.
* install modules: modules that should not be bundled but included in
the `node_modules` folder of the Lambda package. Those modules are
installed in a Lambda compatible Docker image with the right installer
(`npm` or `yarn`) based on lock file detection.

Closes aws#6323
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Minor

```

#### Install modules
Use the `installModules` prop to specify a list of modules that should not be bundled
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a preface saying: "By default, Parcel will automatically detect all modules referenced in your lambda code and will include them in the lambda bundle. ..."

packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda-nodejs/README.md Outdated Show resolved Hide resolved
RUN npm install --global yarn

# Install parcel 2 (fix the version since it's still in beta)
RUN yarn global add parcel@2.0.0-beta.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we allow people to select parcel version?

@jogold
Copy link
Contributor Author

jogold commented Jun 25, 2020

I wonder if we should change the API to something like this:

const myFn = NodejsFunction.parcel(this, 'fn', { ... }); // static method

and have the NodejsFunction only take:

export interface NodejsFunctionProps extends lambda.FunctionOptions {
  entry?: string;
  handler?: string;
  runtime?: lambda.Runtime;
  code?: lambda.Code;
}

code would default to:

lambda.Code.fromAsset(path.dirname(entry), {
  exclude: ['**', '!entry']
});

Also stumbled upon this https://github.com/vercel/ncc, which looks very interesting for this module.

eladb
eladb previously approved these changes Jun 28, 2020
@mergify mergify bot dismissed eladb’s stale review June 28, 2020 08:10

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jun 29, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c9bdfed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jun 29, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 401594e into aws:master Jun 29, 2020
@jogold jogold deleted the lambda-nodejs-parcel2 branch June 29, 2020 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants