amcharts5 icon indicating copy to clipboard operation
amcharts5 copied to clipboard

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

Open lucabonvinigug opened this issue 1 year ago • 6 comments

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):

  • for PDF export the error is: ERROR Error: Uncaught (in promise): ChunkLoadError: Loading chunk 643 failed. (missing: http://localhost:4201/pdfmake.js)

  • for XLSX export the error is: GET http://localhost:4201/462.js net::ERR_ABORTED 404 (Not Found)

    ERROR Error: Uncaught (in promise): ChunkLoadError: Loading chunk 462 failed. (error: http://localhost:4201/462.js)

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",

lucabonvinigug avatar Jul 13 '22 12:07 lucabonvinigug

Can you try with the latest version (5.2.10)?

martynasma avatar Jul 13 '22 14:07 martynasma

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

lucabonvinigug avatar Jul 13 '22 15:07 lucabonvinigug

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

Pauan avatar Jul 15 '22 03:07 Pauan

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

lucabonvinigug avatar Jul 15 '22 08:07 lucabonvinigug

@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.

Pauan avatar Jul 17 '22 04:07 Pauan

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/"

lucabonvinigug avatar Jul 18 '22 10:07 lucabonvinigug

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.

github-actions[bot] avatar Aug 18 '22 00:08 github-actions[bot]