Skip to content

tables + typescript do not build/compile #21

@Xiphe

Description

@Xiphe

Describe the issue

When I setup a fresh arc project
And I add a table
And I install the typescript plugin
And I run arc sandbox

Then I expect the dev-sandbox to start
But instead I get a bunch of errors

✘ [ERROR] Could not resolve "@aws-sdk/client-dynamodb"
    node_modules/@architect/functions/src/tables/legacy.js:16:25:
      16 │     let dynamo = require('@aws-sdk/client-dynamodb')

Steps to reproduce

With reproduce repo

https://github.com/Xiphe/architect-tables-typescript-issue

git clone git@github.com:Xiphe/architect-tables-typescript-issue.git
cd architect-tables-typescript-issue
npm i 
npm start

OR from scratch

  1. run npm init @architect your-app and cd into your-app
  2. run npm install @architect/functions @architect/plugin-typescript @types/node
  3. change your app.arc to this
    @app
    test-arc
    
    @http
    get /
    
    @aws
    # profile default
    region us-west-2
    architecture arm64
    runtime typescript
    
    @plugins
    architect/plugin-typescript
    
    @tables
    people
      pplID *String
    
  4. rename src/http/get-index/index.mjs to ./index.ts
  5. change the contents of that file to
    import { Context, APIGatewayProxyResult, APIGatewayEvent } from "aws-lambda";
    import arc from "@architect/functions";
    console.log(arc);
    
    // learn more about HTTP functions here: https://arc.codes/http
    export async function handler(
      event: APIGatewayEvent,
      context: Context,
    ): Promise<APIGatewayProxyResult> {
    // REST AS IS...
  6. run npm start, arc sandbox or arc deploy
  7. See errors in console
    Compiling TypeScript
    ✘ [ERROR] Could not resolve "@aws-sdk/client-dynamodb"
    
        node_modules/@architect/functions/src/tables/legacy.js:16:25:
          16 │     let dynamo = require('@aws-sdk/client-dynamodb')
             ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      You can mark the path "@aws-sdk/client-dynamodb" as external to exclude it from
      the bundle, which will remove this error and leave the unresolved path in the
      bundle. You can also surround this "require" call with a try/catch block to handle
      this failure at run-time instead of bundle-time.
    

Expected behavior

I would expect the dev environment to start

Also since 11.x I would expect that I don't need to install the old aws client

Screenshots

image

Desktop

  • OS: MacOS 13.4
  • Node: 20.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions