Replies: 7 comments 18 replies
-
Wanted to refresh this issue because it seems important to support the most-starred JS ORM on Github with SvelteKit. I'll be opening an issue if no one has any ideas. |
Beta Was this translation helpful? Give feedback.
-
The provided reproduction repository should first be updated to fix the following issues. There is a top-level await in
|
Beta Was this translation helpful? Give feedback.
-
Please check the following PR - Glench/sveltekit-typeorm-test#1. Regarding the following error, reference Why can't reflect-metadata be used in vite.
|
Beta Was this translation helpful? Give feedback.
-
That comes from this line: You can see that it checks if it's CJS with:
You could manually add it to Vite's |
Beta Was this translation helpful? Give feedback.
-
Specify column type as mention above and using default import seem work well for me in |
Beta Was this translation helpful? Give feedback.
-
Will there be full support for TypeORM for version 1.0.0? |
Beta Was this translation helpful? Give feedback.
-
still problem with esbuild vite.config.ts import typescript from "@rollup/plugin-typescript";
import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';
const config: UserConfig = {
plugins: [sveltekit(), typescript()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
ssr: {
external: ["reflect-metadata"]
},
esbuild: false
};
export default config; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I know that SvelteKit is still in beta and changing a lot, but I'd still like to ask about getting TypeORM to work with the SvelteKit dev server and production node server.
I made a minimal repository with a basic SvelteKit project (using npm init svelte@next) and TypeORM (using all the installation instructions here).
According to the TypeORM docs, my very basic repository shouldn't throw any errors, but it does. So this seems like a bug somewhere in the SvelteKit/Vite stack. Both development and production (with
adapter-node
) throw errors.When I try to do
npm run dev --
I get a warning that import-metadata isn't importing correctly:Then I get an exception from TypeORM:
I'm not sure why the reflect-metadata library doesn't seem to be importing correctly. I've tried both import "reflect-metadata" and import * as Reflect from 'reflect-metadata'; but got the same error. Heck, I even tried copying and pasting the JS library into hooks.ts and commenting out the imports, but the same reflect-metadata and TypeORM errors seem to happen.
Right now my assumption is that if the reflect-metadata library can be imported correctly then that would fix the TypeORM error, but I'm not sure. Here's a relevant issue in the SvelteKit Github. I'm hoping that my issue can be solved without opening a new SvelteKit issue but I want to make sure that it's possible to use TypeORM with SvelteKit since it's the most starred JS ORM on Github.
Update 3: After putting
reflect-metadata
into the SSR external config for vite, the warning goes away but TypeORM still doesn't work. Same errors as listed in dev.Also, when running
npm run build
withadapter-node
, this error happens:BaseEntity is obviously part of the TypeORM library so it's not clear to me what's going on.
If you have any ideas or solutions I'd love to hear them!
Update: @hyunbinseo below found that adding the database type to the Column constructor (e.g.
@Column('text')
) removes the ColumnTypeUndefinedError. That's a good workaround for now, but doesn't solve the issue that it should work without it, and that it doesn't work when runningnpm run build
withadapter-node
.Update 2: @benmccann suggested using Vite's SSR/external option and that fixed the dev server warnings and errors completely! However, the issue with
npm run build
still exists.Update 3: @benmccann's suggestion didn't work after all. I had just tested it wrong. Both
npm run dev
andnpm run build
are still broken with the errors shown above.Beta Was this translation helpful? Give feedback.
All reactions