Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Build Scripts error - Getting Module build failed: RangeError: Maximum call stack size exceeded when using --prod with the build #996

Closed
jgw96 opened this issue May 17, 2017 · 33 comments

Comments

@jgw96
Copy link
Contributor

jgw96 commented May 17, 2017

From @pjc2007 on May 16, 2017 13:5

Ionic version: (check one with "x")
[ ] 1.x
[ ] 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:
I have a build where I get a clean copy of the npm modules each time I build. Out of the blue, I started getting the following error when building on a mac...

[16:22:01] RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at traverse (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:7252:26) at visitEachNode (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14724:30) at Object.forEachChild (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14896:24) at traverse (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:7271:31) at visitNode (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14712:20) at Object.forEachChild (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14910:21) at traverse (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:7271:31) at visitEachNode (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14724:30) at Object.forEachChild (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:14896:24) at traverse (/Users/Development/dev/build/myapp/node_modules/typescript/lib/typescript.js:7271:31)

I went forward upgraded my Ionic 2 app to Ionic 3 (on my Windows machine), all of framework, Ionic native, and the CLI, which I wanted to anyway, however I am still getting a Maximum call stack size exceeded error, however this time it looks a bit different..

`[16:50:08] webpack started ...
Error: .//jszip/lib/index.js
Module build failed: RangeError: Maximum call stack size exceeded
at Object.forEachChild (D:\dev\myapp\node_modules\typescript\lib\typescript.js:14735:26)
at traverse (D:\dev\myapp\node_modules\typescript\lib\typescript.js:7271:31)
at Object.forEachReturnStatement (D:\dev\myapp\node_modules\typescript\lib\typescript.js:7251:16)
at checkAndAggregateReturnExpressionTypes (D:\dev\myapp\node_modules\typescript\lib\typescript.js:40055:16)
at getReturnTypeFromBody (D:\dev\myapp\node_modules\typescript\lib\typescript.js:39965:29)
at getReturnTypeOfSignature (D:\dev\myapp\node_modules\typescript\lib\typescript.js:31190:28)
at resolveNewExpression (D:\dev\myapp\node_modules\typescript\lib\typescript.js:39483:21)
at resolveSignature (D:\dev\myapp\node_modules\typescript\lib\typescript.js:39639:28)
at getResolvedSignature (D:\dev\myapp\node_modules\typescript\lib\typescript.js:39669:26)
at checkCallExpression (D:\dev\myapp\node_modules\typescript\lib\typescript.js:39696:29)
@ ./src/providers/file-logger.ts 58:0-28
@ ./src/app/app.module.ngfactory.ts
@ ./src/app/main.ts,./
/d3/d3.js
Module build failed: RangeError: Maximum call stack size exceeded
at RegExp.[Symbol.replace] (native)
at String.replace (native)
at formatStringFromArgs (D:\dev\myapp\node_modules\typescript\lib\typescript.js:2365:21)
at Object.chainDiagnosticMessages (D:\dev\myapp\node_modules\typescript\lib\typescript.js:2433:20)
at reportNonexistentProperty (D:\dev\myapp\node_modules\typescript\lib\typescript.js:38290:28)
at checkPropertyAccessExpressionOrQualifiedName (D:\dev\myapp\node_modules\typescript\lib\typescript.js:38332:
21)
at checkPropertyAccessExpression (D:\dev\myapp\node_modules\typescript\lib\typescript.js:38274:20)
at checkExpressionWorker (D:\dev\myapp\node_modules\typescript\lib\typescript.js:41158:28)
at checkExpression (D:\dev\myapp\node_modules\typescript\lib\typescript.js:41115:42)
at checkExpressionWithContextualType (D:\dev\myapp\node_modules\typescript\lib\typescript.js:40983:26)
@ ./src/pages/mypage/mypage.ts 61:0-25
@ ./src/app/app.module.ts
@ ./src/app/app.module.ngfactory.ts
@ ./src/app/main.ts

`
If I remove the C3 (graph library) and jszip (as indicated are problems in the above), then the errors goes away. If I use C3 and/or jszip in a newly created blank application, I do not get the errors (hence at this stage I can't provide a small example.

I have done many many builds, and have not seen this before. A forum suggestion was to report it as an app scripts issue, as I am doing here.

It is only when building with the --prod flag

Expected behavior:
To be able to build the application using the --prod flag. Is there some why to to alter the build scripts?
Is this some problem with the scripts config that can cause this?

Steps to reproduce:
This is hard, at this stage, it seems to only happen in my ongoing application, and not a new blank app. Perhaps it is the size (though it is not that big, around 6 pages, and a number of providers, maybe 10 or so - final build package of around 3.5M)

Other information:

I have asked this in the forum here, and again on Stack Overflow

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

Windows machine (after upgrade)

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 6.4.0
    Ionic CLI        : 3.0.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.0.0
    @ionic/cli-plugin-ionic-angular : 1.0.0
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v7.2.0
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed

Mac (before upgrade, but still has the problem)

Your system information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Xcode 8.3.2 Build version 8E2002

Copied from original issue: ionic-team/ionic-framework#11691

@jgw96
Copy link
Contributor Author

jgw96 commented May 17, 2017

Hello, thanks for using Ionic! So you have a custom build that pulls a new copy of your node_modules everytime you build?

@pjc2007
Copy link

pjc2007 commented May 18, 2017

Hi, actually by custom build I just mean there is a script that cleans out a project folder, downloads the project from the repo, does the npm install, build resources etc.

But in the end we just run stock ionic build, (eg ionic build android --release --prod) with no modifications.

I still get this problem if I just build manually. Perhaps we can take that custom build out of the equation (only mentioned to make the point that I get a fresh node_modules each time.)

I can give access to the private repo that this happens for if this will help diagnose?

@dschnelzer
Copy link

dschnelzer commented May 18, 2017

I'm having this same issue just doing

ionic cordova build --prod
and getting

[18:41:14]  webpack started ...
Error: ./~/d3/build/d3.js
Module build failed: RangeError: Maximum call stack size exceeded
    at getNodeLinks (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:24763:30)
    at getResolvedSymbol (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:32553:25)
    at isMatchingReference (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:32608:67)
    at getTypeAtFlowAssignment (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33168:21)
    at getTypeAtFlowNode (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33112:32)
    at getTypeAtFlowBranchLabel (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33264:36)
    at getTypeAtFlowNode (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33130:29)
    at getTypeAtFlowBranchLabel (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33264:36)
    at getTypeAtFlowNode (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33130:29)
    at getTypeAtFlowCondition (/Users/dschnelzer/Documents/projects/plynty/plynty-app/node_modules/typescript/lib/typescript.js:33224:32)
 @ ./src/components/plynty-donut/plynty-donut.ts 15:0-25
 @ ./src/app/app.module.ts
 @ ./src/app/app.module.ngfactory.ts
 @ ./src/app/main.ts
global packages:

    @ionic/cli-utils : 1.1.2
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.1.2

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.1.2
    @ionic/cli-plugin-ionic-angular : 1.1.2
    Ionic Framework                 : ionic-angular 2.3.0

System:

    Node       : v6.9.1
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : not installed
    ios-sim    : not installed

@pjc2007
Copy link

pjc2007 commented May 23, 2017

@dschnelzer Did you find any way around this issue yet dschnelzer? Of is there any other hints for this issue from anyone?

I am no longer able to build my app, and I need to get an update out soon. Nothing I have tried fixes it apart from removing some of the libs that I know build in a newly created app. Is this some just limited stack size (that can perhaps be increased), or is it some sort of infinite recursion I wonder...

@atlesp
Copy link

atlesp commented May 29, 2017

I suddenly got the samme issue on my Mac when building for ios with the command : ionic cordova build ios --prod

After some googling I found this https://forum.ionicframework.com/t/ionic-package-build-ios-profile-prod-fails-with-cert-issue/91544 and found that this command works:

ionic cordova build ios --profile prod --release

Not sure why it works. Changes in the CLI maybe?

@pjc2007
Copy link

pjc2007 commented May 30, 2017

@atlesp I can't try the above with the new CLI right now (and at work and I've only updated CLI at home), but are you sure the ionic cordova build ios --profile prod --release is actually running the ngc and minimization code?

Perhaps the above is not doing this as it is not finding the --prod, and we know that if we leave out the --prod that we don't get this error. Without the ngc and the minimization, we don't get all the optimisations that make a big difference in the performance.

You can open up the ipa file (rename to zip) and see if the final bundle looks minified etc (also you see the step ngc in the output while building)

@atlesp
Copy link

atlesp commented May 30, 2017

@pjc2007 you are right.

@imgx64
Copy link
Contributor

imgx64 commented May 30, 2017

I have the same problem. I tracked it down to a bug in TypeScript and filed a bug there: microsoft/TypeScript#16139 . Downgrading to TypeScript 2.3.0 fixed it.

@dschnelzer
Copy link

I still don't have ionic cordova build ios --prod working. In the meantime I've been using
ionic cordova build ios --aot --minifyjs --minifycss --release which definitely minimizes everything and makes a big difference in startup time. I plan to try some other versions of TypeScript to see if that helps. If you need something quickly, ionic cordova build ios --aot --minifyjs --minifycss --release is a good interim solution.

@youssmak
Copy link

@imgx64 thks

@pjc2007
Copy link

pjc2007 commented Jun 1, 2017

Sadly, using TypeScript 2.3.0 did not fix this for me, nor did running ionic build android --aot --minifyjs --minifycss --release, however if I leave out the --minifyjs , ie ionic build android --aot --minifycss --release without the -minifyjs it works building both Android and iOS. So it looks like the minification that is causing it! Which is weird as I thought the minification would be run AFTER the TypeScript transpiling.

The current error when using TypeScript 2.3.0 and the --minifyjs is

	[14:32:48]  build prod failed: Maximum call stack size exceeded
	[14:32:48]  ionic-app-script task: "build"
	[14:32:48]  RangeError: Maximum call stack size exceeded
	RangeError: Maximum call stack size exceeded
		at checkExpressionCached (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:41130:39)
		at H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:40197:32
		at traverse (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:7261:28)
		at visitEachNode (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:14785:30)
		at Object.forEachChild (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:14957:24)
		at traverse (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:7277:31)
		at visitNode (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:14773:20)
		at Object.forEachChild (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:14971:21)
		at traverse (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:7277:31)
		at visitEachNode (H:\dev\mobileapps\myapp\upgradeto3\node_modules\typescript\lib\typescript.js:14785:30)

The log file has some different information (this is from the Windows machine building Android)...

		0 info it worked if it ends with ok
	1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
	1 verbose cli   'C:\\Users\\peterc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
	1 verbose cli   'run',
	1 verbose cli   'ionic:build',
	1 verbose cli   '--',
	1 verbose cli   '--prod',
	1 verbose cli   '--release' ]
	2 info using [email protected]
	3 info using [email protected]
	4 verbose run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
	5 info lifecycle myapp@~preionic:build: myapp@
	6 silly lifecycle myapp@~preionic:build: no script for preionic:build, continuing
	7 info lifecycle myapp@~ionic:build: myapp@
	8 verbose lifecycle myapp@~ionic:build: unsafe-perm in lifecycle true
	9 verbose lifecycle myapp@~ionic:build: PATH: C:\Users\peterc\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;H:\dev\mobileapps\myapp\upgradeto3\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Brackets\command;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Notepad++;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Android\android-sdk\platform-tools;C:\Users\peterc\.dnx\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\peterc\AppData\Local\Microsoft\WindowsApps;C:\Users\peterc\AppData\Roaming\npm;C:\Program Files\Java\jre1.8.0_121\bin
	10 verbose lifecycle myapp@~ionic:build: CWD: H:\dev\mobileapps\myapp\upgradeto3
	11 silly lifecycle myapp@~ionic:build: Args: [ '/d /s /c', 'ionic-app-scripts build "--prod" "--release"' ]
	12 silly lifecycle myapp@~ionic:build: Returned: code: 1  signal: null
	13 info lifecycle myapp@~ionic:build: Failed to exec ionic:build script
	14 verbose stack Error: myapp@ ionic:build: `ionic-app-scripts build "--prod" "--release"`
	14 verbose stack Exit status 1
	14 verbose stack     at EventEmitter.<anonymous> (C:\Users\peterc\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
	14 verbose stack     at emitTwo (events.js:106:13)
	14 verbose stack     at EventEmitter.emit (events.js:191:7)
	14 verbose stack     at ChildProcess.<anonymous> (C:\Users\peterc\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
	14 verbose stack     at emitTwo (events.js:106:13)
	14 verbose stack     at ChildProcess.emit (events.js:191:7)
	14 verbose stack     at maybeClose (internal/child_process.js:877:16)
	14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
	15 verbose pkgid myapp@
	16 verbose cwd H:\dev\mobileapps\myapp\upgradeto3
	17 error Windows_NT 10.0.14393
	18 error argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\peterc\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:build" "--" "--prod" "--release"
	19 error node v6.9.4
	20 error npm  v4.2.0
	21 error code ELIFECYCLE
	22 error errno 1
	23 error myapp@ ionic:build: `ionic-app-scripts build "--prod" "--release"`
	23 error Exit status 1
	24 error Failed at the myapp@ ionic:build script 'ionic-app-scripts build "--prod" "--release"'.
	24 error Make sure you have the latest version of node.js and npm installed.
	24 error If you do, this is most likely a problem with the myapp package,
	24 error not with npm itself.
	24 error Tell the author that this fails on your system:
	24 error     ionic-app-scripts build "--prod" "--release"
	24 error You can get information on how to open an issue for this project with:
	24 error     npm bugs myapp
	24 error Or if that isn't available, you can get their info via:
	24 error     npm owner ls myapp
	24 error There is likely additional logging output above.
	25 verbose exit [ 1, true ]

@soumak77
Copy link
Contributor

soumak77 commented Jun 3, 2017

@imgx64 thanks for the solution, downgrading to typescript 2.3.0 worked for me

@pjc2007
Copy link

pjc2007 commented Jun 4, 2017

I tried again, updated to latest everything, except TypeScript 2.3.0 and I can now finally build production again, so @imgx64 thanks for that!

@airstep
Copy link

airstep commented Jun 17, 2017

For me problem was with jszip module... After remove it - build takes long, but success! TypeScript 2.3.0

@santamaria7
Copy link

I just downgraded Typescript to v2.3.0 and it's still not working.

@ghost
Copy link

ghost commented Jun 30, 2017

VadimDez/ng2-pdf-viewer#96

Similar issue reported here .

ionic info

Your system information:

ordova CLI: 6.3.1
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.0
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.7
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v4.6.0
Xcode version: Not installed

ionic platform ?

Installed platforms:
android 5.2.2
Available platforms:
amazon-fireos ~3.6.3 (deprecated)
blackberry10 ~3.8.0
browser ~4.1.0
firefoxos ~3.6.3
webos ~3.7.0
windows ~4.4.0
wp8 ~3.8.2 (deprecated)

@mhartington
Copy link
Contributor

Can anyone please provide a minimal project that has this error? I did some initial tests but really need a sample project posted to github to inspect further. Please provide one 😄

@tylervz
Copy link

tylervz commented Jul 6, 2017

@mhartington
Copy link
Contributor

Thanks @tylervz

So I was abel to replicate the error, but it seems to be due to a missing dependency. From your base project, I just installed D3 and it was able to build without an issue.

npm install d3

This _kind of _ makes sense, since C3 is built on top of D3, though the error isn't really clear. Could you test that out?

@jjacobs33589
Copy link

jjacobs33589 commented Jul 10, 2017

I'm having this problem too. I just updated my Ionic 2 app to Ionic 3 and the first time I ran ionic cordova run android --prod it worked fine and the app built on my phone. However, when I tried to run the same command again without making any changes to the code I got the error from above saying "Maximum call stack size exceeded".

If I delete the node_modules folder, run npm install and try to run my project again it works fine again but the second time fails with the same error.
`global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 6.4.0 
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 2.0.0
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.1.2 ios 4.1.1
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v6.10.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : not installed
ios-sim    : 5.0.13 
npm        : 3.10.10 `

I tried downgrading typescript to 2.3.0 but it didn't help.
I'm using the following plugin like @praveenpds mentioned and this seems to be where the problem is coming from but why does it build fine the first time but fail on subsequent runs?

https://github.com/VadimDez/ng2-pdf-viewer

If I remove this plugin the production build runs fine but when I add it back in the issue pops up again. An issue was filed there as well

VadimDez/ng2-pdf-viewer#96

But @mhartington commented on it saying it wasn't an issue with the plugin so it must be with the cli?

@tylervz
Copy link

tylervz commented Jul 12, 2017

@mhartington before running npm install d3, I checked to see if it was already installed and it was.

Tylers-Mac-mini:newProject tylervz$ npm list d3
[email protected] /Users/tylervz/src/mobile/newProject
└─┬ [email protected]
  └── [email protected]

After running npm install d3, I was able to build without an issue. I'm not really sure why upgrading d3 fixed it.

Tylers-Mac-mini:newProject tylervz$ npm list d3
[email protected] /Users/tylervz/src/mobile/newProject
├─┬ [email protected]
│ └── [email protected] 
└── [email protected]  extraneous

@danbucholtz
Copy link
Contributor

The best bet is to just give Node more memory. I'm not sure there's anything else we can do right now.

Thanks,
Dan

@JoeMeeks
Copy link

JoeMeeks commented Jul 13, 2017

@tylervz @mhartington @imgx64 I was able to stay on [email protected] and build with the --prod flag successfully after upgrading my d3 dependency from 3.5.16 to 4.9.1 (Ionic 3.5.0 + Ionic-App-Scripts 2.0.1). This required adding my webpack.config.js aliases to optimization.config.js so that my package.json build script looks like this:

"build:mpm": "ionic-app-scripts build --copy src/app/mpm/config/copy.config.js --sass src/app/mpm/config/sass.config.js --appNgModulePath src/app/mpm/app.module.ts --appEntryPoint src/app/mpm/main.ts --uglifyjs src/app/mpm/config/uglifyjs.config.js --tsconfig src/app/mpm/config/tsconfig.json --optimization src/app/mpm/config/optimization.config.js --webpack src/app/mpm/config/webpack.config.js --enableLint false --prod"

Thanks for the d3 clues! Now to refactor a grip of chart UI code...

@JoeMeeks
Copy link

There was also an Uglify-js error I had afterwards that was caused by case sensitivity of app.module.ts @import folder names. webpack/webpack#2972

@pika11
Copy link

pika11 commented Jul 14, 2017

@danbucholtz suggestion worked for me. I've added 3gb with --max-old-space-size=3072 and it completed the --prod build

@jjacobs33589
Copy link

I've added the suggestion from @danbucholtz and the project does build now but it takes about 20 minutes to build a production build vs less than 30 seconds without the --prod flag. The pdf viewer also doesn't work in the production app even though it works fine with a debug build.

@estacks
Copy link

estacks commented Aug 10, 2017

@mhartington Upgrading d3 to 4.10.0 solved this problem for me after upgrading to ionic-app-scripts 2.1.3 and ionic-angular 3.6.0.

@jhairau
Copy link

jhairau commented Sep 7, 2017

@jjacobs33589 Did you get a solution for PDF Viewer?

@Lingomat
Copy link

@danbucholtz There is something you could do. You could make it easier for us to increase node memory. In the past we could do this in package json but now it needs hacking on ~/AppData/npm/ionic.cmd on a Windows box, and probably something different elsewhere.

One should be able to have a working buildable app checked into git without having to hack in the global space. E.g. the 'other' prod build failure cause is typescript 2.4.1+, and that can simply be resolved from package.json.

@pjc2007
Copy link

pjc2007 commented Sep 12, 2017

I have just upgraded my Ionic, app-scripts etc, so I now have the following
`$ ionic info

cli packages: (C:\Users\pchapman\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.2.3 windows 5.0.0
Ionic Framework    : ionic-angular 3.6.1

System:

Android SDK Tools : 26.0.2
Node              : v6.11.2
npm               : 3.10.10
OS                : Windows 10

I can now use TypeScript 2.4 and not get this error any more . I was scared when it was stuck on thewebpack started ...` for quite a while, but it seemed to get past and succeed (at least for now)

@temiyemi
Copy link

So, I ran into this bug with building a production release for my app, with a c3 dependency. This started after I upgraded to [email protected] and @ionic/[email protected].

But, I finally got the production build process to complete by:

  1. Installing @types/d3@^3 and d3@^3 as a top-level dependency. I didn't have those before since c3 and @types/c3 readily bundles them.

  2. Upgrading to [email protected] the latest as at time of writing.

  3. And, finally, upgrading from [email protected] to [email protected]

Only, after steps 2 and 3 above was the production build able to complete without errors.

I hope this helps someone in a similar situation.

@Lingomat
Copy link

I also found that the latest Typescript fixed it for me.

@JoeMeeks
Copy link

Per @temiyemi's comment I also installed @types/d3@^3 and d3@^3 to upgraded to [email protected] and [email protected]. However, the Contentful (CMS API) dependency in my project would not compile with the --prod flag. I downgraded to [email protected] and all is well again.

Thanks for the suggestions, guys!

dependencies:

"d3": "3.5.17",
"ionic-angular": "3.7.1",
"rxjs": "5.4.3",

devDependencies

"@ionic/app-scripts": "2.1.4",
"@types/d3": "3.5.39",
"typescript": "2.4.2",

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests