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

ngc: Error: Unexpected value... #145

Closed
scottopolis opened this issue Oct 12, 2016 · 12 comments
Closed

ngc: Error: Unexpected value... #145

scottopolis opened this issue Oct 12, 2016 · 12 comments
Assignees

Comments

@scottopolis
Copy link

scottopolis commented Oct 12, 2016

Rollup doesn't let you build if using an npm module that doesn't support AoT compiling, which seems to be all of the ones I try ;)

ionic serve works because it's not using AoT compiling.

This seems to be an issue with ngc in the ionic build script, here's the error I get:

ngc: Error: Unexpected value 'DynamicComponentModule' imported by the module 'AppModule'

I'm using a normal import:

import {DynamicComponentModule} from 'angular2-dynamic-component/index';
@NgModule({
...
imports: [
IonicModule.forRoot(MyApp),
DynamicComponentModule
],
...

Steps to reproduce:

  1. Start with ionic 2 starter project
    npm install core-js@~2.4.0 --save
    npm install ts-metadata-helper --save
    npm install angular2-dynamic-component --save
  2. In app.module.ts, add:
import {DynamicComponentModule} from 'angular2-dynamic-component/index';
@NgModule({
imports: [
    DynamicComponentModule
  ]
})
  1. Run ionic build

Which @ionic/app-scripts version are you using?

Whatever comes with Ionic 2.1.0

If this is not solvable, is there a way to disable the AoT compiling in rollup.js temporarily so I can build?

@danbucholtz
Copy link
Contributor

danbucholtz commented Oct 12, 2016

@scottopolis,

This is not a rollup error. The is an ngc error. It can't build - so it hasn't gotten to the bundle step yet. More than likely that library author is not distributing their library correctly or hasn't tested in an Angular 2 app.

Thanks,
Dan

@scottopolis
Copy link
Author

@danbucholtz thanks Dan, is there anything specific I can recommend the author to do to support ngc?

@danbucholtz
Copy link
Contributor

@scottopolis,

Can you spin up a new Angular project via the Angular CLI and test this out? It may be an issue on our end but let's figure out for sure. So far, from what I've seen 8/10 it has been an issue with the library itself. Let me know how it goes and we'll go from there.

Thanks,
Dan

@danbucholtz danbucholtz self-assigned this Oct 12, 2016
@scottopolis
Copy link
Author

Will do. I know they are using commonjs as the module for compiling, would that be the cause?

@scottopolis
Copy link
Author

I started a new angular 2 project using this project: https://github.com/angular/quickstart/blob/master/README.md

I added the DynamicComponentModule as described above, and I can run the project without errors. I ran npm run tsc because that's the only build command available.

The project author is saying he doesn't get this error, so I'm thinking it might be something wrong in ionic-app-scripts.

@danbucholtz
Copy link
Contributor

npm run tsc does not run ngc so you wouldn't get that error.

Can you do this with with the Angular CLI? https://github.com/angular/angular-cli

Use the webpack version of it.

Thanks,
Dan

@danbucholtz
Copy link
Contributor

Please let me know if your issue is resolved @scottopolis. This more than likely is not an Ionic issue, but I'd like to help anyway. I'm going to close this but will re-open if needed.

Thanks,
Dan

@scottopolis
Copy link
Author

Hi Dan, I used the angular cli to test this again in a fresh project, and there were no issues building using DynamicComponentModule.

I updated to the latest ionic cli and ionic-app-scripts, then installed a fresh Ionic project with no modifications, and then installed DynamicComponentModule, and I'm getting the same error:

[08:13:43]  Error: Unexpected value 'DynamicComponentModule' imported by the module 'AppModule'
[08:13:43]  ngc failed
[08:13:43]  ionic-app-script task: "build"
[08:13:43]  Error: Error

To reproduce the error, create a new Ionic 2 project, then:

npm install core-js --save
npm install ts-metadata-helper --save
npm install angular2-dynamic-component --save

Add the module:

import {DynamicComponentModule} from 'angular2-dynamic-component/index';

@NgModule({
    imports: [DynamicComponentModule]
})

Then build:

ionic build

Thanks for your help!

@danbucholtz
Copy link
Contributor

@scottopolis,

Does the angular CLI use ngc yet?

@scottopolis
Copy link
Author

@danbucholtz I'm not sure, I used the latest version

@danbucholtz
Copy link
Contributor

Hi @scottopolis,

This is an issue with the library, not Ionic.

screen shot 2016-10-17 at 9 39 47 pm

screen shot 2016-10-17 at 9 39 34 pm

Angular Libraries that can utilize ngc require .metadata.json files to be included with the package.

In order to disable ngc builds, in your package.json build command, append a --dev flag at the end.

Thanks,
Dan

@scottopolis
Copy link
Author

Thanks for the follow up Dan, this has been very helpful for me!

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

2 participants