angular-quickstart-lib icon indicating copy to clipboard operation
angular-quickstart-lib copied to clipboard

Angular 5.0: build.js: TypeError: args.indexOf is not a function

Open ersimont opened this issue 8 years ago • 4 comments

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)

ersimont avatar Nov 02 '17 01:11 ersimont

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.'))

bgotink avatar Nov 02 '17 08:11 bgotink

Thank you. I can confirm this new code worked for me.

ersimont avatar Nov 03 '17 01:11 ersimont

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.

cyrilletuzi avatar Nov 03 '17 12:11 cyrilletuzi

@bgotink it worked for me too, congrats friend!

fulls1z3 avatar Jan 05 '18 12:01 fulls1z3