Angular 5.0: build.js: TypeError: args.indexOf is not a function
Upgrading to angular 5.0 seems to break build.js. It fails on this expression:
ngc({ project: `${tempLibFolder}/tsconfig.lib.json` })
It looks like main.js has changed quite a bit for ngc. It used to parse that argument using
new tsc.NgcCliOptions(args)
Now it uses
require('minimist')(args)
If you change
ngc({ project: `${tempLibFolder}/tsconfig.lib.json` })
to
ngc([ '--project', `${tempLibFolder}/tsconfig.lib.json` ])
it should work again.
Note that the call to ngc will no longer return a promise. It looks like it now runs everything synchronously. This can easily be fixed by chaining the promises a little differently:
// Compile to ES2015.
.then(() => ngc({ project: `${tempLibFolder}/tsconfig.lib.json` })
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
.then(() => console.log('ES2015 compilation succeeded.'))
)
// Compile to ES5.
.then(() => ngc({ project: `${tempLibFolder}/tsconfig.es5.json` })
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
.then(() => console.log('ES5 compilation succeeded.'))
)
becomes
// Compile to ES2015.
.then(() => ngc([ '--project', `${tempLibFolder}/tsconfig.lib.json` ]))
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
.then(() => console.log('ES2015 compilation succeeded.'))
// Compile to ES5.
.then(() => ngc([ '--project', `${tempLibFolder}/tsconfig.es5.json` ]))
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
.then(() => console.log('ES5 compilation succeeded.'))
Thank you. I can confirm this new code worked for me.
I confirm it works too, thanks a lot !
For information, I did a fork of the starter, up to date with Angular 5 : https://github.com/cyrilletuzi/angular-quickstart-lib
Not sure how to handle the PR here, as a Angular 4 version should still be available.
@bgotink it worked for me too, congrats friend!