Skip to content
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

TypeORM - Circular dependency and one minor bug #1327

Closed
gamelaster opened this issue May 4, 2021 · 2 comments
Closed

TypeORM - Circular dependency and one minor bug #1327

gamelaster opened this issue May 4, 2021 · 2 comments

Comments

@gamelaster
Copy link

Describe the bug
Minor bug: After building a project, there is require is not defined error in compiled server app.js, for some reason, browser template gets compiled into the final app.js (This is not happening in Sapper). It should be just removed, it shouldn't affect functionality.

image

After removing this, the primary problem occurs.

ColumnTypeUndefinedError2: Column type for ProductImage#url is not defined and cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true option in tsconfig.json. Also make sure you have imported "reflect-metadata" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.

Well firstly, it looks like reflect-metadata doesn't work much good. Also I encountered various circular dependencies issues (Product.ts is referencing ProductImage.ts and vice-versa) (mainly in Sapper).

To Reproduce
Reproduction repository

pnpm install
pnpm run build

Expected behavior
TypeORM should work just fine.

Information about your SvelteKit Installation:

Diagnostics

System:
OS: Windows 10 10.0.19042
Binaries:
Node: 15.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.7.6 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@sveltejs/kit: next => 1.0.0-next.96
svelte: ^3.29.0 => 3.37.0
vite: ^2.1.0 => 2.1.5

Severity
Because of this problem, I can't use TypeORM, and since it's not working also in Sapper, I can't use it at all with combination of Svelte SSR.

Thanks.

@dummdidumm
Copy link
Member

dummdidumm commented May 4, 2021

I guess that the underlying problem is that you use Vite there, which uses ESBuild, which does not support the emitDecoratorMetadata setting. You need to find a Vite plugin that transpiles TS/JS files with the tsc compiler.

Maybe we should document this in troubleshooting/FAQ

@benmccann
Copy link
Member

Please don't report two problems in a single ticket. It makes it very hard to manage

Since this ticket seems to be primarily about TypeORM, I'm closing as a duplicate of #798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants