Issue
I confront an error cause by assign a property to value from ngrx state, but this error only show in dev environment.
Could anyone help explain why this error not show in production mode ?
Here's my tsconfig.json and angular.json :
angular.json:
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"buildOptimizer": false,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/assets"],
"styles": ...,
"scripts": ...,
"allowedCommonJsDependencies": ...
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": true,
"buildOptimizer": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "10mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "src",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2022",
"resolveJsonModule": true,
"module": "es2020",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom", "es2019.array"],
"paths": ...,
"useDefineForClassFields": false,
"strict": false
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
I tried to change the builder of angular and also try to add strict mode in development mode, but this error still exist in development only.
Solution
Based on the answer from @MarianTheisen:
NgRx will automatically disable run time checks in production builds.
Answered By - Ethan Kuo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.