Change your script from:
<script type="text/html" src="main.js"></script>
to:
<script type="module" src="main.js"></script>
const varName = require('module name');
// CDN address is supposed to be a file, or raw text
ng build --prod --base-href yoursubfolder
var ga = ga