Skip to content

Commit 09d9bba

Browse files
committed
Add private option to use npm 7
1 parent 4549a5b commit 09d9bba

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lambda.js",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"main": "dist/lambda.js",
55
"repository": {
66
"type": "git",

src/build.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ const makeBuildDirectory = () => {
3838
return dir;
3939
};
4040

41-
const makeDockerFile = (runtime: lambda.Runtime) => (`
41+
const makeDockerFile = (runtime: lambda.Runtime, useNpm7: boolean = false) => (`
4242
FROM ${runtime.bundlingImage.image}:latest
4343
4444
COPY writeDependencies.js /lambda.js/writeDependencies.js
4545
46+
${useNpm7 ? "RUN npm i -g npm@^7" : ""}
4647
RUN npm i -g typescript
4748
`);
4849

@@ -70,6 +71,7 @@ export interface BuildPreparationOptions {
7071
entry: string;
7172
directory: string;
7273
inplace: boolean;
74+
_bundleUsingNpm7?: boolean;
7375
}
7476

7577
export interface BuildPreparationResult {
@@ -91,7 +93,7 @@ export interface BuildPreparationResult {
9193
export function prepareBuild(options: BuildPreparationOptions): BuildPreparationResult {
9294

9395
const temporaryDirectory = makeBuildDirectory();
94-
const dockerfile = makeDockerFile(options.runtime);
96+
const dockerfile = makeDockerFile(options.runtime, options._bundleUsingNpm7);
9597

9698
let cache;
9799
if (runtimeCache[options.directory] != null) {

src/lambda.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export interface FunctionProps extends lambda.FunctionOptions {
7171
*
7272
*/
7373
runtime?: lambda.Runtime;
74+
75+
_bundleUsingNpm7?: boolean;
7476
}
7577

7678
export class Function extends lambda.Function {
@@ -90,7 +92,7 @@ export class Function extends lambda.Function {
9092
...functionProps
9193
} = props;
9294

93-
const preparation = prepareBuild({ runtime, entry, directory, inplace });
95+
const preparation = prepareBuild({ runtime, entry, directory, inplace, _bundleUsingNpm7: props._bundleUsingNpm7 });
9496

9597
let codeOptions: s3_assets.AssetOptions = {
9698
exclude: makeLambdaExcludes(directory, preparation.info.sources, preparation.cache.paths)

0 commit comments

Comments
 (0)