IE在webpack期间冻结$$ _ lazy_route_resource

时间:2019-03-07 09:48:55

标签: angular internet-explorer webpack

我有一个使用ng build编译的Angular 7 Web应用程序,在DEV模式下大约为4.7meg,分为6个块,最大的是卖方,为3.1,主要的是1.1。在生产中大约是3meg。 2.3供应商,主要为0.3

我需要它在IE 11中运行。在初始页面加载时,它冻结约15秒。冻结是指我得到了蓝色圆圈指示器,如果单击寡妇,它会变苍白,并且(无响应)出现在标题栏中

使用IE性能分析器,我可以看到绝大多数时间(13-14s)是HTML解析和对带有url的脚本的脚本评估

webpack:///frontend/$_lazy_route_resource lazy namespace object

其内容为

function webpackEmptyAsyncContext(req) {
    // Here Promise.resolve().then() is used instead of new Promise() to prevent
    // uncaught exception popping up in devtools
    return Promise.resolve().then(function() {
        var e = new Error("Cannot find module '" + req + "'");
        e.code = 'MODULE_NOT_FOUND';
        throw e;
    });
}
webpackEmptyAsyncContext.keys = function() { return []; };
webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
module.exports = webpackEmptyAsyncContext;
webpackEmptyAsyncContext.id = "./frontend/$$_lazy_route_resource lazy recursive";

请注意,“ frontend”是我的应用程序所在的文件夹,我什至没有使用延迟加载。

Chrome浏览器不会冻结,它加载速度更快,而且似乎根本没有提到此网址,而是像我期望的那样,将其大部分时间都花在了main.js中。

我的angular.json

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "defaultProject": "portal",
    "projects": {
        "portal": {
            "root": "",
            "sourceRoot": "frontend/app-ng",
            "projectType": "application",
            "prefix": "",
            "schematics": {},
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "frontend/public",
                        "index": "frontend/app-ng/app.html",
                        "main": "frontend/main.ts",
                        "polyfills": "frontend/polyfills.ts",
                        "tsConfig": "frontend/tsconfig.app.json",
                        "assets": [
                            "frontend/app-ng/index.php",
                            "frontend/app-ng/favicon.ico",
                            "frontend/app-ng/env.js"
                        ],
                        "styles": [
                            "frontend/styles.scss"
                        ],
                        "scripts": []
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "frontend/environments/environment.ts",
                                    "with": "frontend/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": true,
                            "aot": true,
                            "extractLicenses": true,
                            "vendorChunk": true,
                            "buildOptimizer": true
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "options": {
                        "browserTarget": "portal:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "portal:build:production"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "portal:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "main": "frontend/test.ts",
                        "polyfills": "frontend/polyfills.ts",
                        "tsConfig": "frontend/tsconfig.spec.json",
                        "karmaConfig": "frontend/karma.conf.js",
                        "styles": [
                            "frontend/styles.scss"
                        ],
                        "scripts": [],
                        "assets": []
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "frontend/tsconfig.app.json",
                            "frontend/tsconfig.spec.json"
                        ],
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        },
        "portal-e2e": {
            "root": "e2e/",
            "projectType": "application",
            "architect": {
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "portal:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "portal:serve:production"
                        }
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": "e2e/tsconfig.e2e.json",
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        }
    },
    "schematics": {
        "@schematics/angular:component": {
            "styleext": "scss"
        }
    }
}

我知道IE可能会比更现代的浏览器慢,但冻结是糟糕的用户体验和糟糕的第一印象。

更新

在处理一个最小的完整示例时,我发现没有对enableProdMode()的调用,所以我解决了这个问题,然后问题就消失了。因此,在devmode代码中似乎有IE不喜欢的东西吗?

0 个答案:

没有答案