amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
359 stars 96 forks source link

Error in PDF and XLSX export in micro-frontends based Angular app #484

Closed lucabonvinigug closed 2 years ago

lucabonvinigug commented 2 years ago

Bug description

I'm using @amcharts/amcharts5 at version ^5.1.3 in an a micro-frontends based Angular app, when i click on Export to PDF or Export to XLSX, i got error only when it's published (locally it works):

Seems it tries to get pdfmake.js and 462.js in localhost and not, for example in root.

Environment

Angular CLI: 12.2.16 "@amcharts/amcharts5": "^5.1.3", "@amcharts/amcharts5-fonts": "^5.0.1", "@amcharts/amcharts5-geodata": "^5.0.2", "typescript": "~4.3.5" "single-spa": ">=4.0.0", "single-spa-angular": "^5.0.2",

martynasma commented 2 years ago

Can you try with the latest version (5.2.10)?

lucabonvinigug commented 2 years ago

I updated amcharts to the version 5.2.10, but the error is still present

Pauan commented 2 years ago

@lucabonvinigug Since you're using Angular, have you tried using the the <base> tag to control the loaded URL?

lucabonvinigug commented 2 years ago

@Pauan yes I use <base href="/"> in index.html of "container" and "micro frontend" Angular apps.

Pauan commented 2 years ago

@lucabonvinigug I tried following our Angular tutorial. I used npm run build to create a production build and then tested it, everything worked fine. It sounds like you have some sort of misconfiguration on your server, or a misconfiguration of Angular.

amCharts doesn't handle file loading, we use the standard import() syntax to load files. So that means the file loading is entirely handled by Angular. Unfortunately we can't provide support for issues that are the fault of Angular, so you'll have to ask for help someplace else, like on StackOverflow.

lucabonvinigug commented 2 years ago

I found the solution. In order to prevent building warnings, I added in the angular.json, in allowedCommonJsDependencies array: "pdfmake/build/pdfmake.js", "xlsx/dist/xlsx.core.min.js"

But I needed to change the deployUrl value (in the angular.json) with the prod relative path, eg.: "deployUrl": "/my-app-path/my-analytics-path/"

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.