CMS Development

TNorton7
Member

Problem and possible solution to parsing error when uploading pre-compiled JS

I'm working on a client project and I like to use vite/vue.

I kept hitting problems wherein hubspot's own validators were throwing a bunch of parsing errors, and thus, not allowing me to publish what I KNOW is valid JS. (IMO this is a really bad feature and developers should be allowed to bypass it in favor of their own builds while still leveraging hubspots cache busting).

I devised a solution that seems to work perfectly, but I just want to be sure this doesn't introduce other downstream issues.

What I did was upload the javascript file with the `.txt` extension rather than `.js`. I included it in my base template like so:

{{ require_js(get_asset_url('/{theme-folder}/web/dist/main.txt'), { defer: true }) }}

It works perfectly and it successfully bypasses all of hubspot's own Javascript processing. Is there any other potential issues I should be concerned about here?

1 Reply 1
JSiddall
Participant

Problem and possible solution to parsing error when uploading pre-compiled JS

Hey @TNorton7 ,

 

Your solution just saved me hours of webpack fun. I'll be copying your solution using .txt!

 

thank you!!

0 Upvotes