Skip to content

Commit 30cc609

Browse files
committed
refactor: add index.ts
1 parent 9dfe240 commit 30cc609

File tree

3 files changed

+67
-62
lines changed

3 files changed

+67
-62
lines changed

src/function.ts

+1-62
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,9 @@ import * as path from 'path';
55
import { mergeRight, union, without } from 'ramda';
66

77
import { packExternalModules } from './pack-externals';
8+
import { NodejsFunctionProps } from './props';
89
import { extractFileName, findProjectRoot, nodeMajorVersion } from './utils';
910

10-
/**
11-
* Properties for a NodejsFunction
12-
*/
13-
export interface NodejsFunctionProps extends lambda.FunctionOptions {
14-
/**
15-
* The root of the lambda project. If you specify this prop, ensure that
16-
* this path includes `entry` and any module/dependencies used by your
17-
* function otherwise bundling will not be possible.
18-
*
19-
* @default = the closest path containing a .git folder
20-
*/
21-
readonly rootDir?: string;
22-
23-
/**
24-
* The name of the method within your code that Lambda calls to execute your function.
25-
*
26-
* The format includes the file name and handler function.
27-
* For more information, see https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html.
28-
*
29-
* @default = 'index.handler'
30-
*/
31-
readonly handler?: string;
32-
33-
/**
34-
* The runtime environment. Only runtimes of the Node.js family are
35-
* supported.
36-
*
37-
* @default = `NODEJS_12_X` if `process.versions.node` >= '12.0.0',
38-
* `NODEJS_10_X` otherwise.
39-
*/
40-
readonly runtime?: lambda.Runtime;
41-
42-
/**
43-
* The list of modules that must be excluded from bundle and from externals.
44-
*
45-
* @default = ['aws-sdk']
46-
*/
47-
readonly exclude?: string[];
48-
49-
/**
50-
* Whether to use package manager to pack external modules or explicit name of a well known packager.
51-
*
52-
* @default = true // Determined based on what preference is set, and whether it's currently running in a yarn/npm script
53-
*/
54-
readonly packager?: Packager | boolean;
55-
56-
/**
57-
* The esbuild bundler specific options.
58-
*
59-
* @default = { bundle: true, target: 'es2017' }
60-
*/
61-
readonly esbuildOptions?: es.BuildOptions;
62-
}
63-
64-
/**
65-
* Package manager to pack external modules.
66-
*/
67-
export enum Packager {
68-
NPM = 'npm',
69-
YARN = 'yarn',
70-
}
71-
7211
const BUILD_FOLDER = '.build';
7312
const DEFAULT_BUILD_OPTIONS: es.BuildOptions = {
7413
bundle: true,

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './function';
2+
export * from './props';

src/props.ts

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import * as lambda from '@aws-cdk/aws-lambda';
2+
import { BuildOptions } from 'esbuild';
3+
4+
/**
5+
* Properties for a NodejsFunction
6+
*/
7+
export interface NodejsFunctionProps extends lambda.FunctionOptions {
8+
/**
9+
* The root of the lambda project. If you specify this prop, ensure that
10+
* this path includes `entry` and any module/dependencies used by your
11+
* function otherwise bundling will not be possible.
12+
*
13+
* @default = the closest path containing a .git folder
14+
*/
15+
readonly rootDir?: string;
16+
17+
/**
18+
* The name of the method within your code that Lambda calls to execute your function.
19+
*
20+
* The format includes the file name and handler function.
21+
* For more information, see https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html.
22+
*
23+
* @default = 'index.handler'
24+
*/
25+
readonly handler?: string;
26+
27+
/**
28+
* The runtime environment. Only runtimes of the Node.js family are
29+
* supported.
30+
*
31+
* @default = `NODEJS_12_X` if `process.versions.node` >= '12.0.0',
32+
* `NODEJS_10_X` otherwise.
33+
*/
34+
readonly runtime?: lambda.Runtime;
35+
36+
/**
37+
* The list of modules that must be excluded from bundle and from externals.
38+
*
39+
* @default = ['aws-sdk']
40+
*/
41+
readonly exclude?: string[];
42+
43+
/**
44+
* Whether to use package manager to pack external modules or explicit name of a well known packager.
45+
*
46+
* @default = true // Determined based on what preference is set, and whether it's currently running in a yarn/npm script
47+
*/
48+
readonly packager?: Packager | boolean;
49+
50+
/**
51+
* The esbuild bundler specific options.
52+
*
53+
* @default = { bundle: true, target: 'es2017' }
54+
*/
55+
readonly esbuildOptions?: BuildOptions;
56+
}
57+
58+
/**
59+
* Package manager to pack external modules.
60+
*/
61+
export enum Packager {
62+
NPM = 'npm',
63+
YARN = 'yarn',
64+
}

0 commit comments

Comments
 (0)