gpt4 book ai didi

asp.net - 加载模板失败: (HTTP status: undefined undefined) after bundle minification in ASP.网络

转载 作者:行者123 更新时间:2023-12-02 15:26:12 26 4
gpt4 key购买 nike

我发现 AngularJs 应用程序的 javascript bundle 在 Release模式下没有缩小。它给出了这些类型的错误:

Minification failed. Returning unminified contents. (12834,21-27): run-time error JS1010: Expected identifier: delete

解决这些错误后, bundle 确实进行了缩小,但是现在应用程序将不再在浏览器中启动:它会抛出一个

"Failed to load template error" on the first component.

那么在缩小的 JavaScript 中可以进行哪些更改来破坏 Angular 模板的加载?

这是捆绑配置:

      bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/scripts/jquery-{version}.js",
"~/scripts/jquery.initialize.js",
"~/scripts/jquery.scrollTo.min.js"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/scripts/bootstrap.js"));

bundles.Add(new ScriptBundle("~/bundles/angular").Include(
"~/scripts/underscore.js",
"~/scripts/angular.js",
"~/scripts/angular-animate.js",
"~/scripts/i18n/angular-locale_nl-nl.js",
"~/scripts/angular-ui/ui-bootstrap.js",
"~/scripts/angular-ui/ui-bootstrap-tpls.js",
"~/scripts/dir-pagination.js",
"~/scripts/ng-ckeditor.js"));

bundles.Add(new ScriptBundle("~/bundles/chart").Include(
"~/scripts/moment.js",
"~/scripts/chart.js",
"~/scripts/angular-chart.js"));

bundles.Add(new StyleBundle("~/Content/css/style").Include(
"~/Content/css/style.css"));

bundles.Add(new ScriptBundle("~/bundles/app").Include( //this bundle didn't minify but the app loaded properly, now that it does minify the templates won't load
"~/scripts/AdminTemplate.js",
"~/scripts/goalSeek.js",
"~/scripts/app/app.js")
.IncludeDirectory("~/Scripts/app/", "*.js", true));

bundles.Add(new TemplateBundle("~/bundle/templates", _options)
.IncludeDirectory("~/scripts/app/", "*.html", true));

这是模块声明:

module Iop.Insight {  (() => {
"use strict";

var app = (<any>window).app = angular.module("InsightModule", ["ngAnimate", "ui.bootstrap", "chart.js", "ngLocale", "angularUtils.directives.dirPagination", "ngCkeditor"]);
app.config(config);
config.$inject = ["$compileProvider", "$uibTooltipProvider", "$httpProvider"];

function config($compileProvider, $uibTooltipProvider, $httpProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?:|ms-excel:ofe\|u\||ms-word:ofe\|u\|)/);
$compileProvider.debugInfoEnabled(true);
$uibTooltipProvider.options({
appendToBody: true
});
$httpProvider.defaults.transformResponse.push(responseData => {
if (typeof responseData === "object") {
//If the responseData is an object. We want to convert all Iso8601 DateTime strings within it to JavaScript Date object.
new Iso8601ConversionService().convert(responseData);
}

return responseData;
});
}

app.factory("_", ["$window", $window => $window._]);
app.filter("sanitize", ["$sce", $sce => htmlCode => $sce.trustAsHtml(htmlCode)]); })(); }

其余组件和指令如:

module Iop.Insight {  class NavigatieController {  
static $inject = ["navigatieService"]; constructor(private navigatieService: NavigatieService){}

最佳答案

事实证明,模板加载正确,但相应的 Angular 组件执行了一个“失败”的http请求,因为如果缩小版本包含如下箭头函数,则缩小版本会错误地处理 promise 的解析:

 IwillReturnUndefined(): Promise<string> {
return this.test().then(
(message) => {
console.log('log something');
return message;
});
}

它将被缩小为这样:

  IwillReturnUndefined() {
return this.test().then(n=>console.log("log something"), n)
}

从而返回console.log方法的结果。所以我猜这里的 Angular 错误处理是错误的,让我走上了错误的轨道。

关于asp.net - 加载模板失败: (HTTP status: undefined undefined) after bundle minification in ASP.网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59339969/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com