Open ArnaudBuchholz opened 11 months ago
Yes, the following line is not pointing to the project root path:
const cwd = middlewareUtil.getProject().getRootPath() || process.cwd();
also the root path is considered as being in the path where ui5 serve
is executed. Hmm, need to think about this...
BUT - I'm still not sure what the right behavior is - from where should we derive the project root and the config? Right now, all indicators tend to the root path I geht from the project. The alternative would be to be able to define a root path.
Cc: @RandomByte @matz3
UI5 Tooling determines the project root path to be the directory containing the closest package.json to the CWD of the process (searching in the current and all parent directories). The location of the ui5.yaml is irrelevant. See the implementation for reference.
By executing npx ui5 serve --config ./test/sample.ts/ui5.yaml
in the root of https://github.com/ArnaudBuchholz/ui5-test-runner, UI5 Tooling will use the root package.json rather than the project package.json. This is certainly not what you want. So you should rather execute the UI5 CLI in the project directory (i.e. the directory containing the package.json): (cd ./test/sample.ts && npx ui5 serve)
Hmm, well - the initial issue is that the configuration is not derived properly from the project as the ui5-tooling-transpile
derives the project type from the files in the project root - fun fact: yesterday I was thinking about a different way to derive the project configuration but I'm not yet sure - let's iterate a bit on this...
Yes, it is mainly related to the detection of the project type (whether to transform TypeScript or not) - by configuring it manually it works:
server:
customMiddleware:
- name: ui5-tooling-transpile-middleware
afterMiddleware: compression
configuration:
transformTypeScript: true
The automatic detection is causing the trouble here as by starting from the project root pointing to another ui5.yaml
does not mean the project root is relative to the ui5.yaml
. The project root is always there where the ui5 serve
or ui5 build
command are executed in. What I could think of is to allow to define an altRootPath
or something like that to tell the ui5-tooling-transpile
plugin to lookup the configuration at another place - but it also requires configuration.
Food for thoughts :
ui5.yaml
it is possible to set where to find the webapp folder, why not doing the same for the project root (optional)
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
npm i
npm run serve:sample:js
works fine even if executed from the root but pointing to aui5.yaml
inside a subfolder./test/sample.ts/ui5.yaml
to add :npx ui5 serve --config ./test/sample.ts/ui5.yaml
http://localhost:8080/index.html
Component.js
is missing (not transpiled)Expected behavior I would expect the TS sample to work as fine as the JS one
Screenshots![image](https://github.com/ui5-community/ui5-ecosystem-showcase/assets/4194952/9a24f604-2839-451d-a8ea-7878275dc329)
Desktop (please complete the following information):
404
issue)Additional context Enabling
debug
&--verbose
shows :After long debugging sessions, I finally understood that the problem comes from a combination of
process.cwd()
and the locationof
package.json
. The transpiler configures itself as it in the project root instead of the folder whereui5.yaml
stands.I found a way to 'hack' this but I would expect the whole thing to run fine without hack...