1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular 18 with SSR: Setting optimization to true ignores library loaded inside scripts

Discussão em 'Angular' iniciado por Kim, Setembro 12, 2024.

  1. Kim

    Kim Guest

    My Angular 18 application runs smoothly with SSR in development mode. However, when I switch to production mode with optimization set to true, the application fails to locate the 'igv.js' file, even though it is already included in the scripts section of the angular.json file.

    Configurations section:

    "configurations": {
    "production": {
    "budgets": [
    {
    "type": "anyComponentStyle",
    "maximumWarning": "6kb"
    }
    ],
    "optimization": true,
    "sourceMap": true,
    "namedChunks": true,
    "extractLicenses": true,
    "outputHashing": "all"
    },
    "development": {
    "optimization": false,
    "extractLicenses": false,
    "sourceMap": true
    }
    },


    Scripts section:

    "scripts": [
    "node_modules/swagger-ui-dist/swagger-ui-bundle.js",
    "node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js",
    "igv.js"
    ],


    This is how I am calling the IGV module. Since I am using SSR, I have to call the file on the client-side.

    ngAfterViewInit() {
    if (this.isBrowser) {
    import('igv').then(igvModule => {
    const igv = igvModule.default;
    if (igv && typeof igv.createBrowser === 'function') {
    this.igvModule = igv;
    } else {
    console.error('igv.createBrowser is not a function');
    }
    }).catch(error => {
    console.error('Error loading igv module:', error);
    });
    }
    }


    Any suggestion on what could be missing?

    Continue reading...

Compartilhe esta Página