OS: Win 10 64bit v1803
node: v8.9.3
npm: v5.6.0
cordova: v7.1.0
ionic: v3.20.0
Firebase: v5.3.1
1. 概要
ionic3プロジェクト内でFirebaseをv4.12.1
からv5.3.1
にバージョンアップしてビルドしたらFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
エラーが発生した。
PS D:\src\002-memo\prod> node --max-old-space-size=6144 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build
--prod --aot
[13:32:57] ionic-app-scripts 3.1.11
[13:32:57] build prod started ...
[13:32:57] clean started ...
[13:32:57] clean finished in 3 ms
[13:32:57] copy started ...
[13:32:57] deeplinks started ...
[13:32:57] deeplinks finished in 99 ms
[13:32:57] ngc started ...
[13:33:06] ngc finished in 9.04 s
[13:33:06] preprocess started ...
[13:33:06] preprocess finished in 1 ms
[13:33:06] webpack started ...
[13:33:07] copy finished in 9.74 s
<--- Last few GCs --->
[12516:0000028A1E113C10] 759259 ms: Mark-sweep 6147.3 (6299.4) -> 6147.3 (6299.4) MB, 5559.8 / 0.0 ms allocation failure GC in old space requested
[12516:0000028A1E113C10] 765408 ms: Mark-sweep 6147.3 (6299.4) -> 6147.2 (6274.4) MB, 6145.5 / 0.0 ms last resort GC in old space requested
[12516:0000028A1E113C10] 770207 ms: Mark-sweep 6147.2 (6274.4) -> 6147.2 (6274.4) MB, 4796.8 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000019BC05A5EE1 <JSObject>
1: setEmitFlags [D:\src\002-memo\prod\node_modules\typescript\lib\typescript.js:~49349] [pc=0000014EA238DB6B](this=000002E5D8228039 <Object map = 000003D4CD9834E9>,node=000000C7E6E703A9 <IdentifierObject map = 000000B3198FE1C9>,emitFlags=16777216)
3: createEntityNameFromSymbolChain(aka createEntityNameFromSymbolChain) [D:\src\002-memo\prod\node_modules\typescript\lib\typescript.js:2635...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
2. 原因
一見Firebaseのバージョンアップで発生したためFirebaseに問題ありそうだが、Firebaseの中の人の話を見るに他に原因がありそう。
詳細な原因は不明だが暫定的な対処方法は見つかった。
3. 暫定対処方法
以下のパッケージを追加することで、エラーは発生せずに正常に動作した。
対処方法
npm install --save @angular-devkit/build-optimizer@0.6.8