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
189 stars 91 forks source link

ui5-tooling-transpile does not transpile sap.ui.core for the self-contained app #987

Closed C3ntraX closed 1 month ago

C3ntraX commented 2 months ago

Describe the bug We have issues with the sap.ui.core to transpile down in production build with self-contained as target. Its not working because the file is somehow not considered. In the UI5 version "1.120.9" they added a bunch of unsupported syntax for Chrome > 64.

We actually need Chrome > 64 for some devices even for SAP Business One Webview.

Babel actually transpiled the syntax in my source code but the exact same syntax is not transpiled for the sap.ui.core inside the sap-ui-custom.js.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Transpiling only work when every javascript file is transpiled and not "some"

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

C3ntraX commented 2 months ago

This is the ui5.yaml. I even tried afterTask: generateStandaloneAppBundle and including the sap-ui-custom but this doesn't work either, because there is some wreid issue if you transpile this whole app.

specVersion: "3.0"
metadata:
   name: xxx
type: application
framework:
   name: OpenUI5
   version: "1.120.9"
   libraries:
      - name: sap.f
      - name: sap.m
      - name: sap.tnt
      - name: sap.ui.core
      - name: sap.ui.layout
      - name: themelib_sap_belize
builder:
   customTasks:
      - name: encode-xml-to-utf8
        afterTask: replaceVersion
      - name: ui5-tooling-modules-task
        afterTask: replaceVersion
      - name: ui5-tooling-transpile-task
        afterTask: replaceVersion
        #afterTask: generateStandaloneAppBundle
        configuration:
           excludePatterns:
              - "scripts/"
           #includePatterns:
           #   - "/dist/resources/sap-ui-custom.js"
      - name: ui5-tooling-stringreplace-task
        afterTask: replaceVersion
        configuration:
           debug: true
           files:
              - "**/*.js"
           replace:
              - placeholder: "BASE_URL_PLACEHOLDER"
                value: ""
              - placeholder: "MODE_PLACEHOLDER"
                value: "PRODUCTION"
      - name: ui5-task-i18ncheck
        afterTask: replaceVersion
server:
   settings:
      httpPort: 3000
   customMiddleware:
      - name: ui5-middleware-livereload
        afterMiddleware: compression
        configuration:
           debug: true
           extraExts: "xml,json,properties"
           port: 35730
           watchPath: "webapp"
      - name: ui5-middleware-simpleproxy
        afterMiddleware: compression
        mountPath: /backend
        configuration:
           debug: true
           baseUri: "http://localhost:9123"
           limit: "100mb"
           httpHeaders:
              Any-Header: AnyHeader
      - name: ui5-tooling-modules-middleware
        afterMiddleware: compression
      - name: ui5-tooling-transpile-middleware
        afterMiddleware: compression
        configuration:
           debug: true
      - name: ui5-tooling-stringreplace-middleware
        afterMiddleware: compression
        configuration:
           debug: true
           files:
              - "/controller/BaseController.js"
           replace:
              - placeholder: "BASE_URL_PLACEHOLDER"
                value: "/backend/"
C3ntraX commented 2 months ago

This issue happens, if you try to transpile the whole app with afterTask: generateStandaloneAppBundle:

image

petermuessig commented 2 months ago

Hi @C3ntraX , the ui5-tooling-transpile hasn't been designed to transpile the whole bundle. It only transpiles the resources of the UI5 application or the custom UI5 library. I need to think about this requirement - this is also a bit more complicated as it would require to be injected into the build of the standard UI5 libraries such as the sap.ui.core library. But these libraries are built with their own task configuration.

An option maybe would be to use standalone Babel after the build and to transform the sap-ui-custom.js but this maybe also not sufficient as all modulesloaded afterwards from the standard libraries of OpenUI5 or SAPUI5 will also not be transpiled.

I'm wondering if we can get that running properly at all for your scenario...

@codeworrior, @RandomByte, @matz3 - what's your opinion on that?

C3ntraX commented 2 months ago

Any news?

matz3 commented 2 months ago

I'm sorry, but this does not sound like a scenario that we consider or foresee to support from our end (UI5 Tooling / UI5 CLI). I also can't think of a good approach or workaround apart from post-processing all the files after the build. We currently do not plan to add custom tasks to the build process of framework libraries (or dependencies in general).

petermuessig commented 1 month ago

@C3ntraX - I think this can't be supported with the ui5-tooling-transpile middleware and task as it is related to the official UI5 libraries. A solution may be to do a post-processing of the sap-ui-custom.js with babel after the build took place. Sorry for not having better news... 😢