Skip to content

Use absolute path for esbuild entry #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class NodejsFunction extends lambda.Function {
es.buildSync({
...buildOptions,
external: union(exclude, buildOptions.external || []),
entryPoints: [entry],
entryPoints: [path.join(projectRoot, entry)],
outdir: path.join(projectRoot, BUILD_FOLDER, path.dirname(entry)),
platform: 'node',
});
Expand Down
4 changes: 2 additions & 2 deletions tests/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Runtime, RuntimeFamily } from '@aws-cdk/aws-lambda';
import { Stack } from '@aws-cdk/core';
import { buildSync } from 'esbuild';
import mockfs from 'mock-fs';
import path from 'path';
import path, { join } from 'path';

import { NodejsFunction } from '../src';

Expand Down Expand Up @@ -56,7 +56,7 @@ describe('NodejsFunction tests', () => {
${'a/b/c.h'} | ${'a/b/c.ts'}
`('Should be valid entry with default rootDir', ({ handler, entry }) => {
new NodejsFunction(new Stack(), 'lambda-function', { handler });
expect(buildSync).toHaveBeenCalledWith(expect.objectContaining({ entryPoints: [entry] }));
expect(buildSync).toHaveBeenCalledWith(expect.objectContaining({ entryPoints: [join(process.cwd(), entry)] }));
});

it('Should be valid outdir with custom rootDir', () => {
Expand Down