Skip to content

Commit 13619c1

Browse files
committed
fix(lambda-nodejs): incorrect working directory for local bundling
Execute local bundling from the directory containing the entry file. Without this change, in a monorepo with multiple `package.json` files Parcel doesn't look for the right one. Also fix a regression introduced in aws#9632 for the working directory in the container.
1 parent b1d0ac0 commit 13619c1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class LocalBundler implements cdk.ILocalBundling {
6464
process.stderr, // redirect stdout to stderr
6565
'inherit', // inherit stderr
6666
],
67+
cwd: path.dirname(path.join(this.props.projectRoot, this.props.relativeEntryPath)),
6768
});
6869
return true;
6970
}
@@ -107,7 +108,7 @@ export class DockerBundler {
107108
image,
108109
command: ['bash', '-c', command],
109110
environment: props.environment,
110-
workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)),
111+
workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)).replace(/\\/g, '/'), // Always use POSIX paths in the container,
111112
};
112113
}
113114
}

packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ test('Local bundling', () => {
241241
],
242242
expect.objectContaining({
243243
env: expect.objectContaining({ KEY: 'value' }),
244+
cwd: '/project/folder',
244245
}),
245246
);
246247

0 commit comments

Comments
 (0)