Skip to content

Commit 374e4f7

Browse files
authored
fix(serverless): Re-add missing modules in Node AWS Lambda Layer (#4982)
This PR fixes the AWS Lambda layer in @sentry/serverless. The problem was caused by changes introduced in #4882. Some unintended consequences of these changes were: - By centralising most .npmignore files, npm-packlist did not find all the necessary (but also unnecessary) files when creating the list of files that should end up in the lambda layer Zip file. Due to the missing .npmignore files, it resorted to .gitignore which ignores generated JS files. This PR re-adds local .npmignore files in the dependencies of @sentry/serverless to fix this. - @sentry/tracing is a special case where we need to execute prepack.ts also after building. The call to prepack was missing the --bundles flag, resulting in a weird directory structure. This PR adds the flag and adjusts the sideEffects entry we need for our integration tests. As a hotfix, this PR ensures further that the directory structure in the Lambda layer conforms to the NODE_OPTIONS environment variable set by Sentry
1 parent 6824a7a commit 374e4f7

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

packages/minimal/.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
*
5+
6+
# TODO remove bundles (which in the tarball are inside `build`) in v7
7+
!/build/**/*
8+
9+
!/dist/**/*
10+
!/esm/**/*
11+
!/types/**/*

packages/node/.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
*
5+
6+
# TODO remove bundles (which in the tarball are inside `build`) in v7
7+
!/build/**/*
8+
9+
!/dist/**/*
10+
!/esm/**/*
11+
!/types/**/*

packages/serverless/scripts/build-awslambda-layer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ async function main() {
144144
const version = serverlessPackage.version;
145145
const zipFilename = `sentry-node-serverless-${version}.zip`;
146146

147+
try {
148+
fs.symlinkSync(path.resolve(destRoot, 'build', 'dist'), path.resolve(destRoot, 'dist'));
149+
fs.symlinkSync(path.resolve(destRoot, 'build', 'esm'), path.resolve(destRoot, 'esm'));
150+
} catch (error) {
151+
console.error(error);
152+
}
153+
147154
try {
148155
fs.unlinkSync(path.resolve(dist, zipFilename));
149156
} catch (error) {

packages/tracing/.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
*
5+
6+
# TODO remove bundles (which in the tarball are inside `build`) in v7
7+
!/build/**/*
8+
9+
!/dist/**/*
10+
!/esm/**/*
11+
!/types/**/*

packages/tracing/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"jsdom": "^16.2.2"
3030
},
3131
"scripts": {
32-
"build": "run-p build:cjs build:esm build:types build:bundle && ts-node ../../scripts/prepack.ts #necessary for integration tests",
32+
"build": "run-p build:cjs build:esm build:types build:bundle && ts-node ../../scripts/prepack.ts --bundles #necessary for integration tests",
3333
"build:bundle": "rollup --config",
3434
"build:cjs": "tsc -p tsconfig.cjs.json",
3535
"build:dev": "run-p build:cjs build:esm build:types",
@@ -82,8 +82,8 @@
8282
"sideEffects": [
8383
"./dist/index.js",
8484
"./esm/index.js",
85-
"./npm/dist/index.js",
86-
"./npm/esm/index.js",
85+
"./build/npm/dist/index.js",
86+
"./build/npm/esm/index.js",
8787
"./src/index.ts"
8888
]
8989
}

packages/types/.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
*
5+
6+
# TODO remove bundles (which in the tarball are inside `build`) in v7
7+
!/build/**/*
8+
9+
!/dist/**/*
10+
!/esm/**/*
11+
!/types/**/*

packages/utils/.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
2+
# into it by the prepack script `scripts/prepack.ts`.
3+
4+
*
5+
6+
# TODO remove bundles (which in the tarball are inside `build`) in v7
7+
!/build/**/*
8+
9+
!/dist/**/*
10+
!/esm/**/*
11+
!/types/**/*

0 commit comments

Comments
 (0)