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

Allow alternatives to reflect-metadata for shimming reflect metadata API #761

Open
jacobjove opened this issue Sep 16, 2022 · 5 comments
Open
Labels
feature Adds a new Feature or Request

Comments

@jacobjove
Copy link

Describe what you need | want

Typegoose requires a shim for the reflect metadata API but does not need to require reflect-metadata (which is old and heavy) specifically. There are alternatives such as https://github.com/abraham/reflection

Do you have already an idea for the implementation?

Yes. Interchangability of reflect metatdata shims is already implemented by TypeGraphQL; see MichalLytek/type-graphql#1331 (comment)


@jacobjove jacobjove added the feature Adds a new Feature or Request label Sep 16, 2022
@hasezoey
Copy link
Member

i will consider it when we switch to ESM, because from what i can tell the mentioned library is ESM-only, which is a problem because typegoose will not switch to that any time soon, see #214 (from what i know CJS can be used in ESM, but ESM not in CJS without having a async function somewhere and typegoose currently is sync)

@hasezoey hasezoey added the wont fix (currently) This will not be worked on in the near-future label Sep 16, 2022
@hasezoey
Copy link
Member

hasezoey commented Feb 17, 2023

just had a user in discord having a problem where reflect-metadata would not set the custom options, but `` worked

so i will consider adding a way to change the reflection package used sooner

just as a note though, if the current reflect-metadata does not work (not adding the proper functions), then a simple install of another reflection package (like @abraham/reflection) and registering it with import '@abraham/reflection'; will work (before any imports of typegoose classes)
(though note that @abraham/reflection is a ES module, and not a CJS module and so cannot be easily run in CJS)

@hasezoey hasezoey removed the wont fix (currently) This will not be worked on in the near-future label Feb 17, 2023
@KeithGillette
Copy link

We are using Typegoose with import 'core-js/features/reflect'; from core-js@3.30.2 without issue.

@hasezoey
Copy link
Member

hasezoey commented Jun 2, 2023

@KeithGillette did you confirm that only that reflect library is running? because reflect-metadata is a direct dependency of typegoose currently and theoretically always imported in typegoose

@KeithGillette
Copy link

No, @hasezoey, I did not realize that reflect-metadata was loaded directly by Typegoose. Other dependencies I've used calling the Reflect API have required that a Reflect shim be loaded in the project manually.

@hasezoey hasezoey added this to the 12.0 milestone Jun 10, 2023
@hasezoey hasezoey mentioned this issue Jul 3, 2023
7 tasks
@hasezoey hasezoey removed this from the 12.0 milestone Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adds a new Feature or Request
Projects
None yet
Development

No branches or pull requests

3 participants