aws-lambda-router not being included in package.json

26 Views Asked by At

I have a NX repo with an application called firmware-config. The build trigger is as follows:

"build": {
      "executor": "@nx/esbuild:esbuild",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "platform": "node",
        "outputPath": "{workspaceRoot}/dist/src/functions/firmware-config",
        "format": ["cjs"],
        "bundle": false,
        "main": "{workspaceRoot}/src/functions/firmware-config/src/main.ts",
        "tsConfig": "{workspaceRoot}/src/functions/firmware-config/tsconfig.app.json",
        "generatePackageJson": true,
        "esbuildOptions": {
          "external": ["headers"],
          "sourcemap": true,
          "outExtension": {
            ".js": ".js"
          }
        }
      },

the main.ts has the following imports:

// eslint-disable max-len
import { Handler, APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda'
import { Meta, parseHeaders } from 'headers'
import helpers from './helpers'
import firebase from 'firebase'
import * as router from 'aws-lambda-router'
import { ProxyIntegrationEvent } from 'aws-lambda-router/lib/proxyIntegration'

tsconfig.json (for reference)

{
  "compilerOptions": {
    "target": "ES2018",
    "module": "commonjs",
    "lib": ["es2018"],
    "declaration": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "typeRoots": ["./node_modules/@types"],
    "baseUrl": ".",
    "paths": {
      "/opt/nodejs/*": ["./src/functions/layers/*"],
      "headers": ["src/layers/headers/src/headers.ts"],
      "helpers": ["src/layers/helpers/src/helpers.ts"],
      "firebase": ["src/layers/firebase/src/firebase.ts"]
    }
  },
  "exclude": ["node_modules", "cdk.out"]
}

aws-lambda-router is installed in my main package.json as a dependency, and nothing else I can find is excluding anything.

Here is the generated package.json:

{
  "name": "firmware-config",
  "version": "0.0.1",
  "dependencies": {
    "@firebase/database-types": "0.10.4",
    "firebase-admin": "10.3.0"
  },
  "main": "./main.js",
  "type": "commonjs"
}

What am I doing wrong? What is causing this package to not be included in the generated package.json?

My expectation is the generated package.json will look as follows:

{
  "name": "firmware-config",
  "version": "0.0.1",
  "dependencies": {
    "@firebase/database-types": "0.10.4",
    "firebase-admin": "10.3.0",
    "aws-lambda-router": "^0.11.0",
  },
  "main": "./main.js",
  "type": "commonjs"
}

0

There are 0 best solutions below