[LRUG] tricky rails asset pipeline javascript issue

Samuel Joseph tansaku at gmail.com
Wed May 15 02:42:35 PDT 2019


Hi LRUGers,

So here's a tricky issue that might be of interest and I could use help 
with :-)

I've got the lovely topojson library working for me in a Rails app locally:

https://github.com/topojson/topojson

and it's allowing us to show some nice geoJSON in a google map like so:

I show it with the map.js file exposed, since that seems to be where the 
trouble is when we deploy to heroku.  On heroku the map.js file gives an 
error on chrome:

 > maps-....js:27 Uncaught SyntaxError: Unexpected token export

and a similar error (although on a different line) on firefox:

 > SyntaxError: export declarations may only appear at top level of a 
module maps-...js:1

<https://kcsc.herokuapp.com/assets/maps-f5cd362bb136069cb709fa43918fa4d9f595d642d3533664e8046dc5778e3bf8.js>

I've been in touch with heroku support who suggested locking down our 
npm version, as it seems like the minified js file is ending up with 
slightly different content locally than on heroku.  I note that I've 
done everything I can to replicate production mode locally, clobbering 
and recompiling the static assets etc. and running like so:

```
RAILS_SERVE_STATIC_FILES=true DEVISE_SECRET_KEY=1234 
AIRBRAKE_PROJECT_ID=1234 RAILS_ENV=production be rails s
```

but I cannot replicate the issue on my dev machine.

You can see all the gory details in this PR 
https://github.com/AgileVentures/LocalSupport/pull/1069 and I was 
wondering if anyone had any ideas about anything else that could be a 
difference between my dev machine and heroku that could be leading to 
the javascript files compiling differently? On heroku we have the following:

```
export*from"topojson-client";export*from"topojson-server";export*from"topojson-simplify
```

but there is no mention of the offending `export` keywords in the static 
assets compiled locally, but there they are in the files on the heroku 
server.   I've been trying all sort of methods to ensure that I'm 
deleting cached files and that that the changes I am making are being 
reflected both locally and on heroku.

I've also been investigating ways to try and handle the export keyword 
(new in es6) but that seems like an even deeper rabbit hole, i.e. 
sprockets 4 or webpack or similar.

Anyhow, if anyone has any thoughts on other things that could cause 
heroku to be operating differently here I'd love to hear them, so I can 
either lock them down or work out how to replicate the bug locally.

Many thanks in advance

Best, Sam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20190515/5368b846/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cjjbeheklgadbbip.png
Type: image/png
Size: 173372 bytes
Desc: not available
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20190515/5368b846/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bipfmciegjncdgnh.png
Type: image/png
Size: 115763 bytes
Desc: not available
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20190515/5368b846/attachment-0001.png>


More information about the Chat mailing list