我正在尝试配置应用程序,以便chrome开发工具控制台引用打字稿源而不是编译的javascript源。
我已在仪表板组件的ngOnInit
中添加了以下行
throw new TypeError('Badaboomm!!');
很遗憾,chrome将我指向 js 文件:
DashboardComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Badaboomm!!
at DashboardComponent.ngOnInit (app-app-module.js:64409)
at checkAndUpdateDirectiveInline (provider.ts:212)
at checkAndUpdateNodeInline (view.ts:429)
at checkAndUpdateNode (view.ts:389)
这是我们的angular.json
配置:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"oneval": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "ovl",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/_styles.scss",
"node_modules/ag-grid/dist/styles/ag-grid.css",
"node_modules/ag-grid/dist/styles/theme-fresh.css",
"node_modules/ag-grid/src/styles/ag-theme-material.scss",
"node_modules/ag-grid/src/styles/ag-theme-balham.scss",
"node_modules/flag-icon-css/css/flag-icon.css"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles",
"src/styles/global",
"src/styles/overrides",
"src/styles/utils"
]
},
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"int": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.int.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"qua": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.qua.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"sta": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.sta.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "oneval:build",
"aot": false,
"sourceMap": {
"scripts": true,
"styles": true,
"vendor": true
}
},
"configurations": {
"production": {
"browserTarget": "oneval:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "oneval:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "oneval"
}
并进行tsconfig.json
配置:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"types": ["jest"],
"paths": {
"@admin/*": ["src/app/admin/*"],
"@core/*": ["src/app/core/*"],
"@cache/*": ["src/app/cache/*"],
"@dashboard/*": ["src/app/dashboard/*"],
"@i18n/*": ["src/app/i18n/*"],
"@material/*": ["src/app/material/*"],
"@project-definition/*": ["src/app/project-definition/*"],
"@prototype/*": ["src/app/prototype/*"],
"@shared/*": ["src/app/shared/*"],
"@validation/*": ["src/app/validation/*"],
"@renault-shared/*": ["src/app/validation/renault/shared/*"],
"@renault-applied/*": ["src/app/validation/renault/applied/*"],
"@renault-standard/*": ["src/app/validation/renault/standard/*"],
"@nissan/*": ["src/app/validation/nissan/*"]
}
}
}
我强烈怀疑此问题是在ng update
之后开始发生的...否则,我尝试使用ng new someApp
创建另一个角度应用程序,并且此问题没有发生。我们使用角度8。
有人可以帮忙吗?
编辑1 :该问题(js
源而不是ts
源)尤其在强制重新加载页面时出现...
编辑2 :如我在聊天中的评论之一所述,该问题似乎与使用async / await和promise有关。在使用async / await / promises之前不会发生此问题。
编辑3 :我尝试通过在新的角度应用程序上使用async / await / promises重现该问题,但无济于事...
答案 0 :(得分:1)
您需要在您当前使用的配置(不建议用于生产环境)中的angular.json文件中启用源地图。
您也可以使用cli声明它:
ng serve --source-map=true
更新:
我认为问题在于您的serve
配置覆盖了production
选项:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "oneval:build",
"aot": false,
"sourceMap": {
"scripts": true,
"styles": true,
"vendor": true
}
},
"configurations": {
"production": {
"browserTarget": "oneval:build:production"
^^^^^^^^^^
}
}
},
因此,请尝试更改您的production
配置:
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
^^^^^
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
...
答案 1 :(得分:0)
您需要在配置文件中将$lsc_adminid_query = xtDBquery("SELECT lsc.option_id,
lsc.option_value
FROM lsc_config lsc
WHERE lsc.option_id = 27");
while ($adminid_query = xtc_db_fetch_array($lsc_adminid_query)) {
if (xtc_not_null($adminid_query['option_value'])) {
$adminids = $adminid_query['option_value'];
}
}
$lsc_cid = array($adminids);
if (in_array($_SESSION['customer_id'], $lsc_cid)) {
$lsc_admin = "lsc_admin";
if (!isset($_COOKIE[$lsc_admin])) {
setcookie($lsc_admin, '1', time() + (7200), "/");
}
}
更改为true。 (开发与生产)
--source-map