ui5-community / babel-plugin-transform-modules-ui5

A Babel transformer plugin for OpenUI5/SAPUI5. It allows you to develop UI5 applications by using the latest ECMAScript or TypeScript, including new syntax and objective oriented programming technology.
MIT License
34 stars 16 forks source link

Introduce JSDoc annotation denoting named exports as design-time only #67

Closed akudev closed 2 years ago

akudev commented 2 years ago

Using a JSDoc comment with the newly introduced custom tag @ui5designtimeonlyexport the subsequent named export can be marked as "design-time only". This means it is only needed during development time for certain TypeScript mechanisms, but should not be present at runtime.

This implements a proposal discussed in https://github.com/r-murphy/babel-plugin-transform-modules-ui5/pull/66 to make the overall solution discussed in https://github.com/SAP/ui5-typescript/issues/294 prettier: For module merging needed in UI5 control development, the control class name needs to be a named export (in addition to being the default export). This is only needed at development time to make the TypeScript compiler recognize the additionally generated interface as enriching the control class.

akudev commented 2 years ago

This is a draft for discussion, whether the overall approach is ok.

What I will do if the approach is accepted, before actually having it merged:

What I can do if requested:

What I would prefer not to do (as of now):

akudev commented 2 years ago

What it does: named exports annotated like this (first export in the code sample) are removed during transformation. Reasoning as described in https://github.com/r-murphy/babel-plugin-transform-modules-ui5/pull/66 and overall explained in https://github.com/SAP/ui5-typescript/issues/294.

/**
 * @ui5designtimeonlyexport
 */
export { Example };
export { ThisStaysIn };
export default Example;
codeworrior commented 2 years ago

I think your proposal is a good compromise for the discussion in https://github.com/SAP/ui5-typescript/issues/294 and has a low impact on this plugin.

akudev commented 2 years ago

Not needed anymore as a way was found to make it work without named export.

akudev commented 2 years ago

See https://github.com/SAP/ui5-typescript/issues/294#issuecomment-974272000 for details.