ui5-community / ui5-ecosystem-showcase

A repository showcasing the UI5 tooling extensibility to combine OSS tools for UI5 application development.
https://ui5-community.github.io/ui5-ecosystem-showcase/
Other
192 stars 93 forks source link

[ui5-tooling-transpile] Automatically generate interfaces from the task #919

Closed HappyHepo closed 11 months ago

HappyHepo commented 11 months ago

Is your feature request related to a problem? Please describe. The middleware includes an automatic call to the @ui5/ts-interface-generator, but the task does not.

Describe the solution you'd like Please also call the interface generator automatically from the task, when the conditions are met for the middleware.

Describe alternatives you've considered Currently a manual invocation of the interface generator is needed, when using the task.

petermuessig commented 11 months ago

I had the discussion with @akudev about this and the reason why I didn't add it is because @akudev assumes that these files are generated during the middleware usage and submitted with the code. But what I can do is to add an option to run the interface generator also during build time. WDYT?

HappyHepo commented 11 months ago

That option would be great, as the interface files are in our gitignores and when developing our library, I often only use the builder, not the middleware.

petermuessig commented 11 months ago

I'll release a bit later today.

To make the generation happening, you need to set the option generateTsInterfaces to true: https://github.com/ui5-community/ui5-ecosystem-showcase/blob/b761392a91b52f010302c59f7babf2ab431b1b50/showcases/ui5-tsapp/ui5.yaml#L30-L35

petermuessig commented 11 months ago

BTW: it's released - let me know if it works for you.

HappyHepo commented 11 months ago

Works, when run twice. Babel does not pickup on the generated interface files from that run. Therefor the .d.ts files for the custom controls are not created, as typescript is missing the generated methods and parameters from the generated interface files.

Relevant config: buildscript: `ui5 build --clean-dest` ui5.yaml: ```yaml specVersion: "3.0" metadata: name: com.my.lib type: library framework: name: OpenUI5 version: "1.108.0" libraries: - name: sap.ui.core - name: sap.ui.unified - name: sap.m builder: customTasks: - name: ui5-tooling-transpile-task afterTask: replaceVersion configuration: transformAsyncToPromise: true generateTsInterfaces: true ``` tsconfig.json: ```json { "compilerOptions": { "target": "es2015", "module": "es2015", "lib": [ "es2017", "dom" ], "moduleResolution": "node", "skipLibCheck": true, "preserveConstEnums": true, "declaration": true, "noEmit": true, "sourceMap": false, "allowJs": true, "strict": true, "strictNullChecks": true, "strictPropertyInitialization": true, "rootDir": "./src", "baseUrl": "./src", "paths": { "com/my/lib/*": [ "./com/my/lib/*" ] } }, "include": [ "./src/**/*", "./test/**/*" ] } ``` No explicit babel config
petermuessig commented 11 months ago

Ah, good catch - the workspace isn't aware of the newly created resources - all these new resources need to be added to the workspace after the run...

petermuessig commented 11 months ago

That's strange - after testing the flow a bit more in depth, for me it always includes the gen.d.ts files and also the d.ts files for the custom controls are generated... Weird...

petermuessig commented 11 months ago

Closing for now...

HappyHepo commented 10 months ago

I checked again with v3.3.2, the output includes the files, but the log includes some errors. Weird, but works