question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reflect Metadata wasnt imported into production build

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v18.6.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: modern, alias, css, runtimeConfig, httpApi, modules, buildModules, vite, build, intlify
  • Runtime Modules: @pinia/nuxt@0.3.1, ./modules/uikit, ./api/module, @vueuse/nuxt@8.9.4
  • Build Modules: floating-vue/nuxt

Reproduction

I was using reflect-metdata in global middleware in nuxt-rc6 and it was working perfectly. After upgrade to rc8 i face issue after production build (using nuxt build) and nuxi preview i see next error:

[nuxt] [request error] [unhandled] [500] Reflect.getMetadata is not a function

Describe the bug

I was using reflect-metdata in global middleware in nuxt-rc6 and it was working perfectly. After upgrade to rc8 i face issue after production build (using nuxt build) and nuxi preview i see next error:

[nuxt] [request error] [unhandled] [500] Reflect.getMetadata is not a function

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oleghalincommented, Aug 31, 2022

@dmitryT93 yeah, you need to make dummy check for import

import * as Reflect from "reflect-metadata";

export default () => {
  if (!Reflect) {
    throw new Error("Reflect wasnt imported");
  }
};

After this change builder works properly and dont treeshake it

0reactions
danielroecommented, Sep 1, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Reflect.defineMetadata is not a ...
I had this issue for the Elastic APM RUM agent in Angular 7.1.4. The fix was the same: In Polyfills.ts i added import...
Read more >
polyfills possible breaks reflect-metadata · Issue #62
The problem is, that the reflect polyfill in this library is not compatible with the original one. I could fix this by importing...
Read more >
reflect-metadata
Start using reflect-metadata in your project by running `npm i ... Defining new metadata-producing decorators should not be arduous or ...
Read more >
babel-plugin-transform-typescript-metadata
Babel plugin to emit decorator metadata like typescript compiler ... allows advanced reflection patterns when combined with Reflect.metadata output.
Read more >
Decorators
With the introduction of Classes in TypeScript and ES6, there now exist certain ... import "reflect-metadata"; const formatMetadataKey = Symbol("format"); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found