Main.js和polyfills.js编译不正确-Angular / .Net核心应用

时间:2019-06-07 13:49:12

标签: javascript asp.net-mvc angular

我有一个与.Net Core框架集成的Angular 7项目。这种情况很少发生,但是有时当我使用“ ng build --watch”构建应用程序文件时,main.js和polyfills.js文件无法正确编译。我不了解的部分是为什么它只发生在main.js和polyfills.js文件中,而不是项目中每个生成的文件中都发生。

在浏览器开发工具中发现控制台错误:

polyfills.js:SELECT a.name, a.id, SUM(CASE WHEN a.sourceId = 'INTERNAL' THEN a.amount ELSE -a.amount END) AS total, a.description, DATEDIFF(day, a.startDate, a.endDate) AS days, a.location, a.linkId, a.isMatch FROM DataHistory a GROUP BY a.name, a.id, a.description, DATEDIFF(day, a.startDate, a.endDate), a.location, a.linkId, a.isMatch

main.js:Uncaught SyntaxError: Unexpected string

我将工作中的“ dist”文件夹与损坏的“ dist”文件夹进行了比较,构建文件存放在该文件夹中,这两个文件看上去完全不同。如果我运行另一个“ ng build”,通常可以解决该问题,我很好。

这实际上不是本地问题,因为我可以使用替代方法,但是由于此错误,我的构建和部署通常会失败。任何帮助表示赞赏。

这是文件失败时的样子:

polyfills.js

Uncaught SyntaxError: Unexpected token {

main.js

/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
 * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
 * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
 *
 * Learn more in https://angular.io/guide/browser-support
 */
/***************************************************************************************************
 * BROWSER POLYFILLS
 */
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js';  // Run `npm install --save classlist.js`.
/**
 * Web Animations `@angular/platform-browser/animations`
 * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
 * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
 */
// import 'web-animations-js';  // Run `npm install --save web-animations-js`.
/**
 * By default, zone.js will patch all possible macroTask and DomEvents
 * user can disable parts of macroTask/DomEvents patch by setting following flags
 * because those flags need to be set before `zone.js` being loaded, and webpack
 * will put import in the top of bundle, so user need to create a separate file
 * in this directory (for example: zone-flags.ts), and put the following flags
 * into that file, and then add the following code before importing zone.js.
 * import './zone-flags.ts';
 *
 * The flags allowed in zone-flags.ts are listed here.
 *
 * The following flags will work for all browsers.
 *
 * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
 * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
 * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
 *
 *  in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
 *  with the following flag, it will bypass `zone.js` patch for IE/Edge
 *
 *  (window as any).__Zone_enable_cross_context_check = true;
 *
 */
/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
 * APPLICATION IMPORTS
 */
//# sourceMappingURL=polyfills.js.map

tsconfig:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
    enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
    .catch(function (err) { return console.error(err); });
//# sourceMappingURL=main.js.map

0 个答案:

没有答案