Closed victorgarciaesgi closed 4 years ago
Same quetion here!
@Atinux Any news? :(
Sorry for delay. I am packaging a new version with fixes for today .
On Thu, 17 Oct 2019, 09:23 Victor Garcia, notifications@github.com wrote:
@Atinux https://github.com/Atinux Any news? :(
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/nuxt-property-decorator/issues/55?email_source=notifications&email_token=AAI5PLBOF2AF3PJO7R6OKH3QPAOILA5CNFSM4IYVCRRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBPIBDY#issuecomment-543064207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI5PLFZYTW7NQKDHY24TBLQPAOILANCNFSM4IYVCRRA .
@husayt Thanks! 👍
New version is out. Do you still have a problem?
@husayt Yeah still having the problem. I'm importing reflect-metadata in my global plugin, where should I import it?
I don't understand why are you importing reflect-metadata and what is the problem. What do you mean by "reflect-metadata is not working"?
I use this library both in JS and TS without any issues
Reflect metadata in my case is needed for tsyringe, a dependency injection container which uses reflection data to resolve items.
It works when running the plugin without SSR. When adding
‘’’ import “reflect-metadata” ‘’’
In a plug-in with SSR, the application fails with an error suggesting to import reflect metadata as the metadata attributes were not found.
Once again, everything works fine without SSR.
On Thu, 17 Oct 2019 at 19:22, HG notifications@github.com wrote:
I don't understand why are you importing reflect-metadata and what is the problem. What do you mean by "reflect-metadata is not working"?
I use this library both in JS and TS without any issues
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/nuxt-property-decorator/issues/55?email_source=notifications&email_token=ADBFXZLCWTRVG4FT3WPX42DQPCNMLA5CNFSM4IYVCRRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBQ4AWY#issuecomment-543277147, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBFXZIW6VUBFXTKF4PBBEDQPCNMLANCNFSM4IYVCRRA .
It seems like this is an issue in nuxt itself. In any case this is not an issue with nuxt-property-decorator
, so hence closing,
@victorgarciaesgi same problem, do you resolve it? :(
Nope, we had to disable SSR :-( @altinux
On Mon, 4 Nov 2019 at 09:09, Younccat notifications@github.com wrote:
@victorgarciaesgi https://github.com/victorgarciaesgi same problem, do you resolve it? :(
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/nuxt-property-decorator/issues/55?email_source=notifications&email_token=ADBFXZNCYNP6ERPLM7DHDKLQR7KCTA5CNFSM4IYVCRRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC6PGTY#issuecomment-549253967, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBFXZI747CHUN46ALTKX5DQR7KCTANCNFSM4IYVCRRA .
@lifenautjoe Hi~
I think I solved it :)
if (process.client) {
middlewareProcessor($axios)
}
middlewareProcessor
include logger.js
that import reflect-metadata
, but the file throw a error defineMetadata is not a function
when I restart.
this is my logger.js
import { RequestInterceptor, All } from '../decorators'
@RequestInterceptor
export class Logger {
@All('/')
logReqDetail(config) {
console.log(config)
return config
}
}
I think It throws an error because decorator is created when logger.js
is imported which means it is added to the dependency graph that JS engine can exec.
So, It's must be imported lazy, I added the following code fragment to middlewareProcessor
const logger = await import("./logger.js")
It will be working because logger.js is always running on browser~
Hope this helps.
Add middleware middleware/_reflect.ts
"_" in filename is required, that this middleware require first.
import 'reflect-metadata';
export default () => {
throw new Error('This is hack for correct working reflect metadata on server');
};
Because import middleware from './middleware.js'
it's first user code that include in .nuxt/server.js
Add middleware middleware/_reflect.ts
"_" in filename is required, that this middleware require first.
import 'reflect-metadata'; export default () => { throw new Error('This is hack for correct working reflect metadata on server'); };
Because
import middleware from './middleware.js'
it's first user code that include in .nuxt/server.js
Nuxi 3.6.1 5:42:25 AM Nuxt 3.6.1 with Nitro 2.5.2 5:42:25 AM 5:42:26 AM
Local: http://localhost:3000/ Network: http://172.16.5.4:3000/ 5:42:24 AM ✔ Nuxt Devtools is enabled v0.6.6 (experimental) 5:42:26 AM ℹ Vite client warmed up in 2349ms 5:42:29 AM ✔ Nitro built in 1061 ms nitro 5:42:30 AM [nitro] [uncaughtException] TypeError: Reflect.getMetadata is not a function 5:42:31 AM at /workspaces/magicland-game/node_modules/class-transformer/cjs/decorators/type.decorator.js:13:39 at __decorateClass (file:///workspaces/magicland-game/.nuxt/dev/index.mjs:871:24) at file:///workspaces/magicland-game/.nuxt/dev/index.mjs:905:1 at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
I have this issue because I import in Nuxt config util that reexported with decorated class. For me this error was actual because app specific code was imported to nuxt.config.ts file
I'm importing reflect-metadata on a plugin because i don't know where to put it, but it doesn't work. Where do you import it?