ionic-team / ionic-team/ionic-cli

Cannot build in android in --prod mode

Abierto
#2,628 10 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
2k
Forks
682
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

_From @lostdev on August 9, 2017 18:1_

**Ionic version:** (check one with "x")
[ ] **1.x** (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] **2.x**
[x] **3.x**

**I'm submitting a ...** (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

**Current behavior:**
When building my project using `ionic cordova build android --prod` I get the following error:

```
Running app-scripts build: --build --prod --iscordovaserve --nobrowser

[11:04:29] build prod started ...
[11:04:29] clean started ...
[11:04:29] clean finished in 2 ms
[11:04:29] copy started ...
[11:04:29] ngc started ...
[11:04:38] ngc finished in 8.64 s
[11:04:38] preprocess started ...
[11:04:38] deeplinks started ...
[11:04:38] deeplinks finished in 30 ms
[11:04:38] optimization started ...
[11:04:38] copy finished in 8.86 s
[11:04:50] optimization finished in 11.55 s
[11:04:50] preprocess finished in 11.58 s
[11:04:50] webpack started ...
[WARN] Error occurred during command execution from a CLI plugin
(@ionic/cli-plugin-cordova).
Error: ./node_modules/ionic-native/dist/esm/plugins/plugin.js
Module build failed: TypeError: Cannot read property 'type' of undefined
at Object.getEffectiveTypeAnnotationNode (C:\git\mobile\node_modules\typescr
ipt\lib\typescript.js:9341:17)
at assignContextualParameterTypes (C:\git\mobile\node_modules\typescript\lib
\typescript.js:41652:25)
at checkFunctionExpressionOrObjectLiteralMethod (C:\git\mobile\node_modules\
typescript\lib\typescript.js:41948:29)
at checkExpressionWorker (C:\git\mobile\node_modules\typescript\lib\typescri
pt.js:42959:28)
at checkExpression (C:\git\mobile\node_modules\typescript\lib\typescript.js:
42898:42)
at checkExpressionCached (C:\git\mobile\node_modules\typescript\lib\typescri
pt.js:42779:38)
at checkReturnStatement (C:\git\mobile\node_modules\typescript\lib\typescrip
t.js:45418:54)
at checkSourceElement (C:\git\mobile\node_modules\typescript\lib\typescript.
js:46763:28)
at Object.forEach (C:\git\mobile\node_modules\typescript\lib\typescript.js:1
506:30)
at checkBlock (C:\git\mobile\node_modules\typescript\lib\typescript.js:44563
:16)
@ ./node_modules/ionic-native/dist/esm/index.js 146:0-33
@ ./src/providers/network-status.ts
@ ./src/app/app.module.ngfactory.ts
@ ./src/app/main.ts
```

**Expected behavior:**
I expect the build to work, just like it does without the --prod flag.

**Steps to reproduce:**
I cannot provide specific steps, but it started occurring after a recent update of the ionic CLI. After looking more in detail, the error is caused by a JSDoc comment in `node_modules\ionic-native\dist\esm\plugins\plugin.js`. The following are two versions of the JSDoc. The original (non-working), and my updated, which fixes the issue:

*Original code:*
```
/**
* @private
* @param pluginObj
* @param methodName
* @param opts
* @returns {function(...[any]): (undefined|*|Observable|*|*)}
*/
export var wrap = function (pluginObj, methodName, opts) {
-- line 245
```

*Fixed code (notice the ... missing)*
```
/**
* @private
* @param pluginObj
* @param methodName
* @param opts
* @returns {function([any]): (undefined|*|Observable|*|*)}
*/
export var wrap = function (pluginObj, methodName, opts) {
-- line 245
```

**Other information:**
*My question on the Ionic forum:*
https://forum.ionicframework.com/t/error-ionic-native-dist-esm-plugins-plugin-js-module-build-failed-typeerror-cannot-read-property-type-of-undefined/101191/8
*Another person with the same issue*
https://forum.ionicframework.com/t/error-during-executing-ionic-cordova-run-android-prod/100252/6
*Seems to be an issue with the angular CLI?*
https://github.com/angular/angular-cli/issues/7110

**Ionic info:** (run `ionic info` from a terminal/cmd prompt and paste output below):

```
C:\git\mobile>ionic info

cli packages: (C:\git\mobile\node_modules)

@ionic/cli-plugin-cordova : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils : 1.7.0
ionic (Ionic CLI) : 3.7.0

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.3 ios 4.3.1
Ionic Framework : ionic-angular 3.6.0

System:

Android SDK Tools : 25.2.5
Node : v6.10.3
OS : Windows 8.1
npm : 3.10.8
```

**tsconfig.json:**
```
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"src/**/*spec.ts"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
```

**package.json:**
```
{
"name": "App",
"version": "0.0.1",
"description": "App",
"license": "Apache-2.0",
"scripts": {
"build": "ionic-app-scripts build",
"clean": "ionic-app-scripts clean",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"test": "karma start ./.tests/karma.conf.js",
"test-ci": "karma start ./.tests/karma.conf.js --single-run"
},
"dependencies": {
"@angular/animations": "^4.3.1",
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/compiler-cli": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/platform-server": "^4.3.1",
"@angular/router": "^4.3.1",
"@ionic-native/app-version": "^4.1.0",
"@ionic-native/core": "3.10.2",
"@ionic-native/in-app-browser": "3.10.2",
"@ionic-native/splash-screen": "3.10.2",
"@ionic-native/status-bar": "3.10.2",
"@ionic/storage": "2.0.1",
"@types/pouchdb": "^5.4.28",
"@types/pouchdb-browser": "^5.4.4",
"@types/pouchdb-core": "^5.4.5",
"@types/semver": "^5.3.32",
"chart.js": "^2.6.0",
"cordova-android": "^6.2.3",
"cordova-ios": "^4.3.1",
"cordova-plugin-app-version": "^0.1.9",
"cordova-plugin-console": "1.0.5",
"cordova-plugin-crosswalk-webview": "~2.2.0",
"cordova-plugin-device": "1.1.4",
"cordova-plugin-inappbrowser": "~1.4.0",
"cordova-plugin-splashscreen": "~4.0.1",
"cordova-plugin-statusbar": "2.2.1",
"cordova-plugin-whitelist": "1.3.1",
"cordova-plugin-wkwebview-engine": "git+https://github.com/ionic-team/cordova-plugin-wkwebview-engine.git",
"enquire.js": "^2.1.6",
"events": "^1.1.1",
"ionic-angular": "^3.5.3",
"ionic-plugin-keyboard": "~2.2.1",
"ionicons": "3.0.0",
"pouchdb": "^5.4.5",
"pouchdb-browser": "^6.0.6",
"pouchdb-upsert": "^2.0.2",
"rxjs": "^5.4.2",
"semver": "^5.4.1",
"sw-toolbox": "3.4.0",
"typescript": "^2.4.2",
"zone.js": "0.8.11"
},
"devDependencies": {
"@ionic/app-scripts": "^2.1.3",
"@ionic/cli-plugin-cordova": "1.6.2",
"@ionic/cli-plugin-ionic-angular": "1.4.1",
"@types/jasmine": "^2.5.53",
"angular2-template-loader": "^0.6.2",
"html-loader": "^0.4.5",
"ionic": "3.7.0",
"jasmine-core": "^2.7.0",
"jasmine-spec-reporter": "^4.1.0",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"null-loader": "^0.1.1",
"protractor": "^5.1.1",
"ts-loader": "^2.0.3",
"ts-node": "^3.0.2",
"typescript": "2.3.3"
},
"config": {},
"cordova": {
"platforms": [
"android",
"ios"
],
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-crosswalk-webview": {
"XWALK_VERSION": "22+",
"XWALK_LITEVERSION": "xwalk_core_library_canary:17+",
"XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
"XWALK_MODE": "embedded",
"XWALK_MULTIPLEAPK": "true"
},
"cordova-plugin-device": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-wkwebview-engine": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-app-version": {}
}
}
}
```

**npm outdated:**
```
C:\git\mobile>npm outdated
Package Current Wanted Latest
@ionic-native/core 3.10.2 3.10.2 4.1.0
@ionic-native/in-app-browser 3.10.2 3.10.2 4.1.0
@ionic-native/splash-screen 3.10.2 3.10.2 4.1.0
@ionic-native/status-bar 3.10.2 3.10.2 4.1.0
@types/pouchdb 5.4.28 5.4.28 6.3.0
@types/pouchdb-browser 5.4.4 5.4.4 6.1.1
@types/pouchdb-core 5.4.5 5.4.5 6.1.5
cordova-plugin-console 1.0.5 1.0.5 1.0.7
cordova-plugin-crosswalk-webview 2.2.0 2.2.0 2.3.0
cordova-plugin-device 1.1.4 1.1.4 1.1.6
cordova-plugin-inappbrowser 1.4.0 1.4.0 1.7.1
cordova-plugin-statusbar 2.2.1 2.2.1 2.2.3
cordova-plugin-whitelist 1.3.1 1.3.1 1.3.2
cordova-plugin-wkwebview-engine 1.1.4-dev git git
html-loader 0.4.5 0.4.5 0.5.1
pouchdb 5.4.5 5.4.5 6.3.4
sw-toolbox 3.4.0 3.4.0 3.6.0
zone.js 0.8.11 0.8.11 0.8.16
```

_Copied from original issue: ionic-team/ionic#12628_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.