cds-typer icon indicating copy to clipboard operation
cds-typer copied to clipboard

[FEATURE] Use `Proxy` to wrap the cds.entities access in the generated index.js files

Open stockbal opened this issue 6 months ago • 0 comments

Description

Currently the recommendation from CAP https://cap.cloud.sap/docs/tools/cds-typer#subpath-imports is to use dynamic imports to be safe during runtime. Generally speaking, dynamic imports should only be used if really necessary (e.g. dynamic paths, reduction of loading time because of module size).

Suggested Solution

To avoid these dynamic imports I propose an adjustment of the modules.exports expressions in the index.js files to wrap the cds.entities access to Proxy objects.

Example of an index.js file after the rework. image

The used function createEntityProxy will be created in the reuse module @cds-models/_/index.js and will perform the actual Proxy creation for the cds entities.

See #281

Alternatives

No response

Additional Context

No response

stockbal avatar Jul 29 '24 08:07 stockbal