Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ersimont opened this issue Nov 2, 2017 · 4 comments
Open

Comments

@ersimont
Copy link
Contributor

ersimont commented Nov 2, 2017

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)
@bgotink
Copy link

bgotink commented Nov 2, 2017

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

@ersimont
Copy link
Contributor Author

ersimont commented Nov 3, 2017

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

@cyrilletuzi
Copy link

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.

@fulls1z3
Copy link

fulls1z3 commented Jan 5, 2018

@bgotink it worked for me too, congrats friend!

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

No branches or pull requests

4 participants