Angular instances are doubled when bootstrapping them by inserting build scripts in the script tag

59 views Asked by At

When I insert angular build scripts with document.createElement('script') angular instances double. It works when there are more than one build. You can see it in the sandbox console: there are four console.log().

Sandbox Link

Here is my build script:

const fs = require('fs-extra');
const concat = require('concat');

const uniqueName = app-c;
const uniqueComponentPath = ./dist/app/${uniqueName}.js;

(async function build() {
   const files = [
    './dist/app/runtime.js',
    './dist/app/polyfills.js',
    './dist/app/main.js'
   ].filter((x) => fs.pathExistsSync(x));
   await fs.ensureFile(uniqueComponentPath);
   await concat(files, uniqueComponentPath);
})();

"build": "ng build --output-hashing none && node build.js"
0

There are 0 answers