Skip to content

Commit 4df0621

Browse files
authored
ref(aws-serverless): Add resolution for import-in-the-middle when building the Lambda layer (#17780)
this is actually a fix but not a user-facing one, therefore, `ref`. Starting with `1.14.3`, `import-in-the-middle` uses both, `import` and `require` statements in its `hook.mjs` file. This caused `@vercel/nft` in its default config to _not_ trace the required `hook.js` file (+ all of its dependencies). This PR enables `mixedModules: true` to trace both, requires and imports. In contrast to #17777, we therefore don't have to override the IITM version and we also don't have to revert this PR.
1 parent ae747ad commit 4df0621

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/aws-serverless/scripts/buildLambdaLayer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ async function pruneNodeModules(): Promise<void> {
7979
'./build/aws/dist-serverless/nodejs/node_modules/@sentry/aws-serverless/build/npm/esm/awslambda-auto.js',
8080
];
8181

82-
const { fileList } = await nodeFileTrace(entrypoints);
82+
const { fileList } = await nodeFileTrace(entrypoints, {
83+
// import-in-the-middle uses mixed require and import syntax in their `hook.mjs` file.
84+
// So we need to set `mixedModules` to `true` to ensure that all modules are tracked.
85+
mixedModules: true,
86+
});
8387

8488
const allFiles = getAllFiles('./build/aws/dist-serverless/nodejs/node_modules');
8589

0 commit comments

Comments
 (0)