-
Notifications
You must be signed in to change notification settings - Fork 48
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
Help importing and building #288
Comments
I tried this without using the document client from typedorm, not sure if this should work or not:
but regardless, I still get the same errors from document-client-types.d.ts 1.15.1:
|
I had
'aws-sdk' shouldn't be imported at all, as I'm using v3 ... and it exports a bunch of stuff and doesn't have a default export. And @aws-sdk/client-dynamodb doesn't export DynamoDBClientV3 - in fact, I can't find that symbol anywhere. Where does DynamoDBClientV3 come from? I'm building this project as part of a CDK stack. What has me concerned is that some other (perhaps transitive) dependency is being noticed and telling it to try to import aws-sdk. Let me take a closer look at the sample you referenced.
|
I have a few differencse in tsconfig.json could that be a problem?
is the one that has me a little concerned because I'm not sure how the magic works to support both v2 and v3 |
Just for fun, I cloned
I didn't think it would make a difference that I'm using yarn rather than npm, but just to be sure, I wiped the project and started again with npm, and it did the same. That makes sense since the errors are just coming from tsc. I also tried building at the root ... so three commands:
|
Sorry for the monolog here. Working through this, I'm trying first to track down where thie symbol DynamoDBClientV3 comes from, as one of the two errors is trying to import that. In all of Github there are only a handful, less if you eliminate things not in the exact case:
which didn't reveal much, so then I did this:
which pointed me to this: that I think is my problem: https://www.typescriptlang.org/tsconfig#allowSyntheticDefaultImports I don't understand these comments: #265 (comment) and #265 (comment) but a few conclusions here:
The reason I am using esbuild is because I'm working within the CDK environment. If you don't use esbuild but you're using CDK, then it needs docker to work, which makes things slower and makes it virtually impossible to build on windows (I flip back and forth between windows and linux depending on what I'm doing). |
I probably should have said when I started all this, my goal here is to build a lambda using typedorm within a CDK stack build. That said, there may be other issues beyond the above. Example:
but I definitely did set emitDecoratorMetadata to true. Does this look right?
The generated output of tsc includes:
so I think emitDecoratorMetadata did its job. Not sure what the problem is. |
@wz2b I can second the MissingReflectMetadata error
I just migrated a project from AWS SAM to CDK and am trying to deploy lambda functions that have Typedorm code. Here is my package.json
@whimzyLive I have seen your comments in aws-cdk issues regarding emitDecoratorMetadata and esbuild bundling lambdas so perhaps you have a better idea if we are configuring something wrong with regards to esbuild. Looking forward to your insights |
Yeah it doesn't seem to work right in the CDK environment. I asked this question on Repost to try to see if there's a way to have a lambda that's part of the project but has its own tsconfig, package.json, etc. I think that might be the better approach, I'm just not sure how to make it work. |
Hey @wz2b amd @michael-pont Yes, it is correct that the
So when the |
The obvious workaround for getting the TypeDORM to work with CDK is to always rely on If one of you can set up an example of using |
@whimzyLive thanks. I submitted a PR here typedorm/typedorm-examples#1 |
Hi @whimzyLive , have you been able to take a look at the PR? |
@michael-pont Am I missing something or does your PR not use esbuild? I see it as a I'm running into similar issues with trying to get TypeDORM to play nice with esbuild (using SST, "The Serverless Stack"). EDIT: I finally got this working. If anyone else is trying to use TypeDORM with SST do the following (paths are relative to root of project, NOT root of
const {esbuildDecorators} = require("@anatine/esbuild-decorators");
module.exports = [
esbuildDecorators({
tsconfig: './services/tsconfig.json', // <- This was the missing piece for me, without this nothing worked
}),
];
Before: const api = new Api(stack, 'api', {
routes: {
'GET /': 'functions/lambda.handler'
}
}); After: const api = new Api(stack, 'api', {
defaults: {
function: {
bundle: {
esbuildConfig: {
plugins: 'config/esbuild.js'
}
}
}
},
routes: {
'GET /': 'functions/lambda.handler'
}
}); For SEO purposes
|
I'm having trouble building using this:
It insisted I install smithy-client, which I didn't note in the docs. To make a connection, I'm doing this:
I get two errors I don't know how to resolve:
For the first error, I'm not sure why it needs to bring that dependency in in the first place if I'm doing V3. For the second error, that's correct, the client isn't called DynamoDBClientV3, it's just called DynamoDBClient.
I'm not sure what's going on here, is it a versioning problem? I don't really want to bring aws-sdk at all. If I don't, I get some warnings:
even if I do bring aws-sdk in at 2.799 or the most recent version I still get the error that it doesn't export "AWS"
I'm not sure how to clear this up.
The text was updated successfully, but these errors were encountered: