-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui5-tooling-modules] failed to load JavaScript resource for jspdf #1128
Comments
Hi @mmotkim, as you suggest, maybe you could provide me your source code (if you are SAP internal, just write to me internally to share the source code). This would make the analysis easier. I'm wondering a bit why you exclude jsPDF from transformation. The debug flag should be THX and BR, |
Hi @petermuessig, thanks for the reply! I'm happy you could help, I've just added you to the repo.
The issue is still present and I've been making some changes to the app since the day I posted the issue:
Edit: Interestingly, the adaptation editor didn't produce any errors and it could run just fine, it's just the Application Preview function in VSCode that didn't work |
@mmotkim : AFAICS, it is an application variant project - so changes will be applied to the original application and the modules will be loaded relative to the application. I didn't think about this scenario so far. If you open the following URL: http://localhost:8080/resources/pdf-lib.js - does it show up and has a sap.ui.define preamble? |
@petermuessig Yes it does, http://localhost:8080/resources/pdf-lib.js returns the code starting with
|
Ok, then the problem is related to running the URL: You could maybe add for testing the following in the beginning of the sap.ui.loader.config({
paths: {
"pdf-lib": "/resources/pdf-lib"
}
});
sap.ui.define(... This ensures to re-route the pdf-lib request to the server root. This is only a workaround to see whether it works or not. I want to redirect the request to |
For the |
But when I used ExcelJS for the application variant at first it worked flawlessly, Only when adding pdf-js/removing ExcelJS and adding pdf-js that it cried about not being able to load the .js |
What you can do is the following - add a - name: fiori-tools-proxy
afterMiddleware: fiori-tools-appreload
configuration:
debug: true
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
backend:
- client: "302"
url: https://s35.gb.ucc.cit.tum.de
path: /sap
- path: /customer/atpreportvariant/resources
pathReplace: /resources
url: http://localhost:8080
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
version: 1.108.33
|
The |
Alright, I removed Headers
|
Please try the following configuration in the proxy: - path: /sap/bc/ui5_ui5/sap/zatpr/~3652DD8F6F55485147ACA7924D0C9999~5/resources
pathReplace: /resources
url: http://localhost:8080 What I don't like is the static definition of the cachebuster token in the URL - but it should be at least for the whole application - so it may work then for all the requests. @tobiasqueck @Klaus-Keller - is it possible to use a regex in the Fiori tools proxy? I tried it but I run into an endless loop. Maybe this would be an interesting feature to proxy such kind of requests and to be able to ignore the cachebuster token segment. THX |
There were still 2 of those same failed requests URLs. I add the config to fiori-tools-proxy like this:
I used Text compare to make sure the static definitions in the urls were identical, is there something preventing proxy configuration from catching the path? Edit:
Thanks a lot! Would there be any problems when I deploy? |
@petermuessig @mmotkim I don't think your setup is a good idea. I am also not sure how this is supposed to work after deployment.
If my assumptions are correct then removing the |
Let me further elaborate on the reproduction steps:
- name: fiori-tools-appreload
afterMiddleware: ui5-tooling-modules-middleware The middleware should run in order of Hope it can help, @tobiasqueck |
@mmotkim a few more question to ensure I got the full picture:
That one confuses me. The only reason that I could guess would be that your original app already knows one of the two. Is that the case? |
@tobiasqueck - the application variant comes with a custom code Now, for the deployment, there should be no issue anymore - as the build is prefixing the imports of the thirdparty with the namespace of the application variant - see here the build output of the With that the thirdparty is addressed relative to the application variant and I don't see a problem here. The main issue was about pointing the thirdparty requests during development to the |
That is what confuses me because the preview middleware generates an html (you can check the source in the browser when testing) that tells UI5 to find all the original app files and the adaptation files at |
But the thirdparty is not rewritten so far during local development. The rewrite (prefix with the application namespace) only takes place during the build. I already thought about this feature but it would again require a bigger rework. Maybe there's some time during the next x-mas vacation for that... ;-) |
@petermuessig would |
This is exactly the missing feature which would solve it in general. Right now, all thirdparty requests will go through /resources/* and not through the application namespace... |
Sorry, I wrote my response before I read your last message. Now I am getting the problem! |
Related issue: #1049 |
It's a misuse of a feature but could you try the following in your preview-middleware config:
That's a wild guess that may work ... |
I just tried, it worked as well! Also to answer your questions:
|
I am happy to hear that. I'd suggest to use it as a workaround until #1049 is available. Afterwards, you shouldn't need it anymore. |
@tobiasqueck @petermuessig I was changing some code but didn't see anything different when reloading, even with new I just redeployed once more and ran the Preview Application when the change finally displayed, which means I have to literally redeploy each time I want to see my changes :) Fortunately the Adaptation Editor still works live |
But how could that be? In my suggested approach, the mapping is only redirecting the application variant local Maybe a solution is to redirect the full application? With Tobias suggestion slightly changed: - name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
flp:
apps:
- target: /
componentId: customer.atpreportvariant => Redirecting the variant to the server root |
The preview middleware merges the original manifest with the appdescr changes and then starts the app. When a file is locally available it will use it, otherwise, it will proxy the request to the original app. I doubt that my proposal above caused the loading of the files from the backend instead of locally. |
@tobiasqueck The preview seems to still be using the changes present on the server, maybe the problem lies in Preview Application's command But there's another problem today, I just configured the fiori launchpad and started the ADP when it threw the same error for my first working library ExcelJS: The URL were: # yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json
specVersion: "3.0"
metadata:
name: atpreportvariant
type: application
resources:
configuration:
propertiesFileSourceEncoding: UTF-8
builder:
customTasks:
- name: ui5-tooling-modules-task
afterTask: replaceVersion
configuration:
addToNamespace: true
customConfiguration:
adp:
support:
id: "@sap/generator-adaptation-project"
version: 1.1.63
toolsId: 09edfc9e-5876-4488-a154-8d943eb1994e
server:
customMiddleware:
- name: ui5-tooling-modules-middleware
afterMiddleware: compression
- name: fiori-tools-appreload
afterMiddleware: ui5-tooling-modules-middleware
configuration:
port: 35729
path: webapp
delay: 300
- name: fiori-tools-preview
afterMiddleware: fiori-tools-appreload
configuration:
flp:
apps:
- target: /resources
componentId: customer.atpreportvariant.resources
adp:
target:
client: "302"
url: https://s35.gb.ucc.cit.tum.de
ignoreCertErrors: false
- name: fiori-tools-proxy
afterMiddleware: fiori-tools-preview
configuration:
ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted
backend:
# - path: /sap/bc/ui5_ui5/sap/zatpr/~6B559E7121C9D296876EAB4772A343FD~5/resources
# pathReplace: /resources
# url: http://localhost:8080
- client: "302"
url: https://s35.gb.ucc.cit.tum.de
path: /sap
# - path: /customer/atpreportvariant/resources
# pathReplace: /resources
# url: http://localhost:8080
ui5:
path:
- /resources
- /test-resources
url: https://ui5.sap.com
version: 1.108.33
Really appreciate if you could help!! |
Additional Info: I just undeployed and redeployed then checked the deployment log and didn't see any resource files being pushed. Here's the log:
The |
This is more a general ADP with custom modules issue then a tools issue, I think. It might make more sense for you to open an incident that support can have a closer look at you projects and backend. |
Describe the bug
I'm working on an adaptation project, I've been following the documentation on www.npmjs.com/package/ui5-tooling-modules and got the library excelJS to work. I cleared the excel-related code and proceeded to use jspdf when I could not get it to work.
I've tried tweaking witth
skipTransform
skipCache: true
inject:
and still to no avail,interestingly I also can't get
debug: true
to work. It creates the same log whether I'm usingnpm run start
ornpm run build
.I've been scratching my head at this thing for 3 days now.
To Reproduce
Steps to reproduce the behavior:
npm i jspdf
Screenshots
Code
Here's my ui5.yaml:
Here's my package.json:
Desktop (please complete the following information):
P/S: I'm happy to share my entire source code for your further inspection.
The text was updated successfully, but these errors were encountered: