Skip to content

Invalid computed root folder for ui5-tooling-transpile #879

@ArnaudBuchholz

Description

@ArnaudBuchholz

Describe the bug
I created some sample apps to test ui5-test-runner in different configurations.
In particular, I want to validate that it works with TS transpiling.

I have no problem running a normal JS app inside the project, but the TS one is quite challenging.
I found a workaround but I believe the problem is inside the transpiler in the way the configuration is built.

To Reproduce

  1. Clone ui5-test-runner repository
  2. npm i
  3. npm run serve:sample:js works fine even if executed from the root but pointing to a ui5.yaml inside a subfolder
  4. Modify ./test/sample.ts/ui5.yaml to add :
resources:
  configuration:
    paths:
      webapp: ./test/sample.ts/webapp
  1. npx ui5 serve --config ./test/sample.ts/ui5.yaml
  2. open http://localhost:8080/index.html
  3. The application does not start because Component.js is missing (not transpiled)

Expected behavior
I would expect the TS sample to work as fine as the JS one

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows (reproduced on Ubuntu)
  • Browser : all (server 404 issue)
  • Version :
   "@openui5/types": "^1.119.0",
   "@ui5/cli": "^3.6.1",
   "@ui5/middleware-code-coverage": "^1.1.0",
   "typescript": "^5.2.2",
   "ui5-tooling-transpile": "^3.2.6"

Additional context
Enabling debug & --verbose shows :

verb server:custom-middleware:ui5-tooling-transpile-middleware Normalized configuration:
{
  "debug": true,
  "includes": [],
  "excludes": [
    ".png",
    ".jpeg",
    ".jpg"
  ],
  "filePattern": ".js",
  "transformTypeScript": false,
  "transformModulesToUI5": false
}
info server:custom-middleware:ui5-tooling-transpile-middleware Create Babel configuration based on ui5.yaml configuration options...
info server:custom-middleware:ui5-tooling-transpile-middleware Using browserslist configuration from ui5.yaml...
verb server:custom-middleware:ui5-tooling-transpile-middleware {
  "assumptions": {},
  "configFile": false,
  "babelrc": false,
  "filename": "<WHATEVER>\\ui5-test-runner\\src\\dummy.js",
  "sourceMaps": "inline",
  "targets": {},
  "cloneInputAst": true,
  "browserslistConfigFile": false,
  "passPerPreset": false,
  "envName": "development",
  "cwd": "<WHATEVER>\\ui5-test-runner",
  "root": "<WHATEVER>\\ui5-test-runner",
  "rootMode": "root",
  "plugins": [],
  "presets": [
    {
      "options": {
        "targets": {
          "browsers": "defaults"
        }
      },
      "dirname": "<WHATEVER>\\ui5-test-runner",
      "file": {
        "request": "@babel/preset-env",
        "resolved": "<WHATEVER>\\ui5-test-runner\\node_modules\\@babel\\preset-env\\lib\\index.js"
      }
    }
  ]
}

After long debugging sessions, I finally understood that the problem comes from a combination of process.cwd() and the location
of package.json. The transpiler configures itself as it in the project root instead of the folder where ui5.yaml stands.

I found a way to 'hack' this but I would expect the whole thing to run fine without hack...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions