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

lambda-nodejs: parcel is too big to bundle #6340

Closed
eladb opened this issue Feb 18, 2020 · 5 comments · Fixed by #6345
Closed

lambda-nodejs: parcel is too big to bundle #6340

eladb opened this issue Feb 18, 2020 · 5 comments · Fixed by #6345
Assignees
Labels
bug This issue is a bug. in-progress This issue is being actively worked on. p1

Comments

@eladb
Copy link
Contributor

eladb commented Feb 18, 2020

We are looking into releasing the entire AWS CDK as a single library (see aws/aws-cdk-rfcs#6). This basically means that all modules (and their transitive dependencies) will be bundled into a single package.

Recently, we have introduced @aws-cdk/aws-lambda-nodejs as a high level API for writing node.js lambda functions. This construct uses [parcel] in order to bundle all function's dependencies into a single artifact.

The problem is that [parcel] is too big:

  • It has 652 transitive dependencies
  • 15,558 files
  • 100MiB (uncompressed)

This is unrealistic and also introduces an intrinsic security risk posed by including so many dependencies in our project.

Proposal

Let's use parcel as an [undeclared] peer-dependency. Simply require that users declare parcel in their own package.json file. It will also give them more control over which version to use.

@eladb eladb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 18, 2020
@eladb eladb self-assigned this Feb 18, 2020
@eladb
Copy link
Contributor Author

eladb commented Feb 18, 2020

@jogold what do you think?

@jogold
Copy link
Contributor

jogold commented Feb 18, 2020

Yes, peer dependency is fine. What do you mean with [undeclared]?

@eladb
Copy link
Contributor Author

eladb commented Feb 18, 2020

I mean that we won't be able to officially declare it as a "peerDependency" in our package.json because jsii doesn't really know what to do with it, so basically I think at runtime we can do something like require.resolve('parcel/package.json').version and check that we are compatible with the version the user installed.

@jogold
Copy link
Contributor

jogold commented Feb 18, 2020

OK, let me open a PR for this.

@eladb
Copy link
Contributor Author

eladb commented Feb 18, 2020

Awesome, thanks!

jogold added a commit to jogold/aws-cdk that referenced this issue Feb 18, 2020
Stop bundling `parcel-bundler` and make it an undeclared peer dependency.

Transform `build` function into a class.

Fixes aws#6340

BREAKING CHANGE: `parcel-bundler` v1.x is now a peer dependency of `@aws-cdk/aws-lambda-nodejs`.
Please add it to your `package.json`.
@SomayaB SomayaB added in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 18, 2020
@eladb eladb added the p1 label Feb 19, 2020
eladb pushed a commit that referenced this issue Feb 19, 2020
Stop bundling parcel-bundler and make it an undeclared peer dependency.

Transform build function into a class.

Fixes #6340

BREAKING CHANGE: parcel-bundler v1.x is now a peer dependency of @aws-cdk/aws-lambda-nodejs. Please add it to your package.json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants