Skip to content

Commit

Permalink
fix(serverless): Re-add missing modules in Node AWS Lambda Layer (#4982)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lms24 committed Apr 26, 2022
1 parent 6824a7a commit 374e4f7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/minimal/.npmignore
@@ -0,0 +1,11 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

*

# TODO remove bundles (which in the tarball are inside `build`) in v7
!/build/**/*

!/dist/**/*
!/esm/**/*
!/types/**/*
11 changes: 11 additions & 0 deletions packages/node/.npmignore
@@ -0,0 +1,11 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

*

# TODO remove bundles (which in the tarball are inside `build`) in v7
!/build/**/*

!/dist/**/*
!/esm/**/*
!/types/**/*
7 changes: 7 additions & 0 deletions packages/serverless/scripts/build-awslambda-layer.js
Expand Up @@ -144,6 +144,13 @@ async function main() {
const version = serverlessPackage.version;
const zipFilename = `sentry-node-serverless-${version}.zip`;

try {
fs.symlinkSync(path.resolve(destRoot, 'build', 'dist'), path.resolve(destRoot, 'dist'));
fs.symlinkSync(path.resolve(destRoot, 'build', 'esm'), path.resolve(destRoot, 'esm'));
} catch (error) {
console.error(error);
}

try {
fs.unlinkSync(path.resolve(dist, zipFilename));
} catch (error) {
Expand Down
11 changes: 11 additions & 0 deletions packages/tracing/.npmignore
@@ -0,0 +1,11 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

*

# TODO remove bundles (which in the tarball are inside `build`) in v7
!/build/**/*

!/dist/**/*
!/esm/**/*
!/types/**/*
6 changes: 3 additions & 3 deletions packages/tracing/package.json
Expand Up @@ -29,7 +29,7 @@
"jsdom": "^16.2.2"
},
"scripts": {
"build": "run-p build:cjs build:esm build:types build:bundle && ts-node ../../scripts/prepack.ts #necessary for integration tests",
"build": "run-p build:cjs build:esm build:types build:bundle && ts-node ../../scripts/prepack.ts --bundles #necessary for integration tests",
"build:bundle": "rollup --config",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:dev": "run-p build:cjs build:esm build:types",
Expand Down Expand Up @@ -82,8 +82,8 @@
"sideEffects": [
"./dist/index.js",
"./esm/index.js",
"./npm/dist/index.js",
"./npm/esm/index.js",
"./build/npm/dist/index.js",
"./build/npm/esm/index.js",
"./src/index.ts"
]
}
11 changes: 11 additions & 0 deletions packages/types/.npmignore
@@ -0,0 +1,11 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

*

# TODO remove bundles (which in the tarball are inside `build`) in v7
!/build/**/*

!/dist/**/*
!/esm/**/*
!/types/**/*
11 changes: 11 additions & 0 deletions packages/utils/.npmignore
@@ -0,0 +1,11 @@
# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied
# into it by the prepack script `scripts/prepack.ts`.

*

# TODO remove bundles (which in the tarball are inside `build`) in v7
!/build/**/*

!/dist/**/*
!/esm/**/*
!/types/**/*

0 comments on commit 374e4f7

Please sign in to comment.