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

Print Enums Explicitly During cds-typer Run #107

Merged
merged 5 commits into from
Nov 27, 2023
Merged

Conversation

daogrady
Copy link
Contributor

@daogrady daogrady commented Nov 13, 2023

Fixes #94

Runtime-enums were formerly derived from the runtime model in their respective index.js file.
This had two drawbacks:

  1. importing these files caused a performance hit, as all enums contained in that file were dynamically built -- even if they were not being used.
  2. the cds minimizer would remove all enums from the runtime model that were not referenced anywhere in the model. If the user wanted to have those enums even if they went unused in the model, they would run into a runtime error (see [BUG] App crashes with unused enum types #94)

So the former

module.exports.MyEnum = Object.fromEntries(Object.entries(cds.model .......))

now becomes

module.exports.MyEnum = { A: 'a', B: 'b', ... }

@daogrady daogrady changed the title Print enums explicitly during cds-typer run Print Enums Explicitly During cds-typer Run Nov 14, 2023
@daogrady daogrady enabled auto-merge (squash) November 27, 2023 05:20
@daogrady daogrady merged commit 384d0b5 into main Nov 27, 2023
7 checks passed
@daogrady daogrady deleted the fix/print-unused-enums branch November 27, 2023 05:22
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

Successfully merging this pull request may close these issues.

[BUG] App crashes with unused enum types
1 participant