-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(build): Use rollup to build AWS lambda layer #5146
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
da10e94
reactivate lambda layer job
lobsterkatie 1a6a911
rename lambda GHA job
lobsterkatie f720781
simplify getting SDK version in CI
lobsterkatie 786851e
switch to getting files to zip from the build cache
lobsterkatie 9b9979a
cache serverless package rather than `dist-serverless`
lobsterkatie 7bcd663
add index file for lambda bundle
lobsterkatie 8199b59
adjust config to become a package with bundles
lobsterkatie 845d017
add rollup config for lambda bundle
lobsterkatie 6793dee
switch to using rollup config for lambda layer build
lobsterkatie 47d44f1
add build script for lambda layer
lobsterkatie 876a3e2
use `build:bundle` to build layer rather than `build:awslambda-layer`
lobsterkatie a487cbf
add TODO re: auto file in npm rollup config
lobsterkatie ffead19
add script mimicking lambda layer GHA locally
lobsterkatie cae6b01
add results of running lambda zipping GHA locally to .gitignore
lobsterkatie fe2c4b6
remove obsolete .gitignore
lobsterkatie cce54c0
remove obsolete .npmignores
lobsterkatie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { makeBaseBundleConfig, makeBundleConfigVariants, makeBaseNPMConfig } from '../../rollup/index.js'; | ||
|
||
export default [ | ||
// The SDK | ||
...makeBundleConfigVariants( | ||
makeBaseBundleConfig({ | ||
// this automatically sets it to be CJS | ||
bundleType: 'node', | ||
entrypoints: ['src/index.awslambda.ts'], | ||
jsVersion: 'es6', | ||
licenseTitle: '@sentry/serverless', | ||
outputFileBase: () => 'index', | ||
packageSpecificConfig: { | ||
output: { | ||
dir: 'build/aws/dist-serverless/nodejs/node_modules/@sentry/serverless/build/npm/cjs', | ||
sourcemap: false, | ||
}, | ||
}, | ||
}), | ||
// We only need one copy of the SDK, and we pick the minified one because there's a cap on how big a lambda function | ||
// plus its dependencies can be, and we might as well take up as little of that space as is necessary. We'll rename | ||
// it to be `index.js` in the build script, since it's standing in for the index file of the npm package. | ||
{ variants: ['.min.js'] }, | ||
), | ||
|
||
// This builds a wrapper file, which our lambda layer integration automatically sets up to run as soon as node | ||
// launches (via the `NODE_OPTIONS="-r @sentry/serverless/dist/awslambda-auto"` variable). Note the inclusion in this | ||
// path of the legacy `dist` folder; for backwards compatibility, in the build script we'll copy the file there. | ||
makeBaseNPMConfig({ | ||
entrypoints: ['src/awslambda-auto.ts'], | ||
packageSpecificConfig: { | ||
// Normally `makeNPMConfigVariants` sets both of these values for us, but we don't actually want the ESM variant, | ||
// and the directory structure is different than normal, so we have to do it ourselves. | ||
output: { | ||
format: 'cjs', | ||
dir: 'build/aws/dist-serverless/nodejs/node_modules/@sentry/serverless/build/npm/cjs', | ||
sourcemap: false, | ||
}, | ||
// We only want `awslambda-auto.js`, not the modules that it imports, because they're all included in the bundle | ||
// we generate above | ||
external: ['./index'], | ||
}, | ||
}), | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be refactored in an upcoming PR, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on your definition of "upcoming." 😛
But yes, eventually, once I've applied the "wait only as long as you need to" to all of the "extras" steps, then the "extras" build can happen in parallel with the others, and this can move back under that umbrella.