|
| 1 | +import { makeBaseBundleConfig, makeBundleConfigVariants, makeBaseNPMConfig } from '../../rollup/index.js'; |
| 2 | + |
| 3 | +export default [ |
| 4 | + // The SDK |
| 5 | + ...makeBundleConfigVariants( |
| 6 | + makeBaseBundleConfig({ |
| 7 | + // this automatically sets it to be CJS |
| 8 | + bundleType: 'node', |
| 9 | + entrypoints: ['src/index.awslambda.ts'], |
| 10 | + jsVersion: 'es6', |
| 11 | + licenseTitle: '@sentry/serverless', |
| 12 | + outputFileBase: () => 'index', |
| 13 | + packageSpecificConfig: { |
| 14 | + output: { |
| 15 | + dir: 'build/aws/dist-serverless/nodejs/node_modules/@sentry/serverless/build/npm/cjs', |
| 16 | + sourcemap: false, |
| 17 | + }, |
| 18 | + }, |
| 19 | + }), |
| 20 | + // 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 |
| 21 | + // plus its dependencies can be, and we might as well take up as little of that space as is necessary. We'll rename |
| 22 | + // it to be `index.js` in the build script, since it's standing in for the index file of the npm package. |
| 23 | + { variants: ['.min.js'] }, |
| 24 | + ), |
| 25 | + |
| 26 | + // This builds a wrapper file, which our lambda layer integration automatically sets up to run as soon as node |
| 27 | + // launches (via the `NODE_OPTIONS="-r @sentry/serverless/dist/awslambda-auto"` variable). Note the inclusion in this |
| 28 | + // path of the legacy `dist` folder; for backwards compatibility, in the build script we'll copy the file there. |
| 29 | + makeBaseNPMConfig({ |
| 30 | + entrypoints: ['src/awslambda-auto.ts'], |
| 31 | + packageSpecificConfig: { |
| 32 | + // Normally `makeNPMConfigVariants` sets both of these values for us, but we don't actually want the ESM variant, |
| 33 | + // and the directory structure is different than normal, so we have to do it ourselves. |
| 34 | + output: { |
| 35 | + format: 'cjs', |
| 36 | + dir: 'build/aws/dist-serverless/nodejs/node_modules/@sentry/serverless/build/npm/cjs', |
| 37 | + sourcemap: false, |
| 38 | + }, |
| 39 | + // We only want `awslambda-auto.js`, not the modules that it imports, because they're all included in the bundle |
| 40 | + // we generate above |
| 41 | + external: ['./index'], |
| 42 | + }, |
| 43 | + }), |
| 44 | +]; |
0 commit comments