tradingview / charting-library-examples

Examples of Charting Library integrations with other libraries, frameworks and data transports
MIT License
1.33k stars 744 forks source link

Vue, Uncaught SyntaxError: Unexpected token 'export' #293

Open melchiebooy opened 2 years ago

melchiebooy commented 2 years ago

Describe the bug

I have been fighting this for weeks... When deploying to production, a syntax error occours and breaks the loading of the charting library. This syntax error triggers a redirect which loads index.html again hence the double navigation bar, see screenshot. error This error can be somewhat temporarily mitigated by turning of the -s flag or the redirect rule on AWS. But this caused alot of other problems instead...

To Reproduce

Steps to reproduce the behavior:

  1. npm install
  2. npm run build
  3. serve dist -s

Expected behavior charting module loads, see below (works when running command serve dist) noerror

Screenshots this is the error message i see in the console, I suspect this triggers the redirect uncaught-ex-serve-dist

romfrancois commented 2 years ago

Hi @melchiebooy !

serve dist -s

Did you mean npm run serve dist -s

I tried to run npm run serve without any errors.

melchiebooy commented 2 years ago

Hi @melchiebooy !

serve dist -s

Did you mean npm run serve dist -s

I tried to run npm run serve without any errors.

Hi @romfrancois,

Thank you for having a look!

No i did not mean that.

Nom run serve works, but then its not built for production. So the problem arises when building first and then trying to serve it in production.

romfrancois commented 2 years ago

Well if Im not mistaken and according to the doc serve -s does

-s, --single Rewrite all not-found requests to index.html

so given the favicon is not found I would expect another request on index.html that would reload and add stuff that was already there?

Any reason for using that flag?

Having said that I don't think that has anything to do with the library itself. The compilation works and the basics of serving and making it work as well.

melchiebooy commented 2 years ago

Well if Im not mistaken and according to the doc serve -s does

-s, --single Rewrite all not-found requests to index.html

so given the favicon is not found I would expect another request on index.html that would reload and add stuff that was already there?

Any reason for using that flag?

Having said that I don't think that has anything to do with the library itself. The compilation works and the basics of serving and making it work as well.

Well something in the charting widget is making a request, which fails. I can't find what it is, do you have any suggestion of how to find out?

The -s flag is necessary to make Single page applications work properly. It is the default setting in production. Below is a problem that immediately arises if this -s rule is not used.

https://stackoverflow.com/questions/50299204/receive-accessdenied-when-trying-to-access-a-reload-or-refresh-or-one-in-new-tab