Skip to content

[ui5-tooling-transpile] & [ui5-tooling-stringreplace] string replace before transpile don't work #1008

@MrChuzzle

Description

@MrChuzzle

Hi all,

I used the string replacer to define my app namespace. This works fine with the ui5 module syntax sap.ui.define and Object.extend("namespace.ClassName" {...}). Thanks to ui-tooling-transpile, we can use modern module syntax, now. But when I'm using the transpiler, the string replacer don't work correctly.

I'm using ui5-tooling-transpile version 3.4.1 and ui5-tooling-stringreplace version 3.2.2. and ui5/cli version 3.10.3

My ui5.yaml:

specVersion: "3.2"
metadata:
  name: oct.templates.validator
type: application
server:
  customMiddleware:
    - name: ui5-middleware-livereload
      afterMiddleware: compression
    - name: ui5-middleware-simpleproxy
      afterMiddleware: compression
      mountPath: /resources
      configuration:
        baseUri: "https://sapui5.hana.ondemand.com/1.123.1/resources"
    - name: ui5-tooling-stringreplace-middleware
      afterMiddleware: compression
      configuration:
        debug: true
        prefix: UI5_ENV # default
        path: ./ # default
        separator: "." # default
        files:
          - "**/*.js"
          - "**/*.xml"
        replace:
          - placeholder: ${project.NAMESPACE}
            value: oct.templates.validator
          - placeholder: ${project.VERSION}
            value: 1.0.0-SNAPSHOT
    - name: ui5-tooling-transpile-middleware
      afterMiddleware: compression
      configuration:
        transformModulesToUI5: true

When ui5-tooling-transpiler is used, all *.js files are ignored by the string replacer.
When the string replacer runs after the transpiler, all *.js files getting string replaced correctly, but then the transpiler could not transpile correctly because he transpiled with the placeholders string.

Expected behavior
The string replacer don't ignore the *.js files and replace all placesholders before the files getting transpiled. The result should look like the last screenshot, here.

Screenshots
When the string replacer runs before the transpiler (*.js files are ignored by the string replacer):
image

When the string replacer runs after the transpiler:
image

When I remove the string replacer and replace all placesholders with the correct namespace, the transpiler works fine (expected behavior):
image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Chrome
  • Version: 124.0.6367.208

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions