Reputation: 12705
I searched in existing issues on ng2-bootstrap Github project, but could not find anything similar. Same here on SO.
I'm working with an Angular 2 (2.1.0), TypeScript 2 (2.0.3), Webpack 2 (2.1.0-beta.25) application. Build chain has both a development build and a production one, with AOT and uglifyjs. Application depends on ng2-bootstrap TabsModule
and DropdownModule
(1.1.14).
Development build goes fine. When building with AOT, that fails with:
TypeError: providers.forEach is not a function
at CompileMetadataResolver.getProvidersMetadata (D:\myproj\node_modules\@angular\compiler\bundles\compiler.umd.js:14292:21)
at CompileMetadataResolver.getNgModuleMetadata (D:\myproj\node_modules\@angular\compiler\bundles\compiler.umd.js:14051:60)
at D:\myproj\node_modules\@angular\compiler\bundles\compiler.umd.js:12801:47
at Array.forEach (native)
at analyzeModules (D:\myproj\node_modules\@angular\compiler\bundles\compiler.umd.js:12800:17)
at OfflineCompiler.analyzeModules (D:\myproj\node_modules\@angular\compiler\bundles\compiler.umd.js:12826:18)
at CodeGenerator.codegen (D:\myproj\node_modules\@angular\compiler-cli\src\codegen.js:122:47)
at codegen (D:\myproj\node_modules\@angular\compiler-cli\src\main.js:7:81)
at Object.main (D:\myproj\node_modules\@angular\tsc-wrapped\src\main.js:30:16)
at Object.<anonymous> (D:\myproj\node_modules\@angular\compiler-cli\src\main.js:14:9)
I tried fiddling with local copy within node_modules\ng2-bootstrap\components
, adding a providers: []
both in respective xxx.module.js
and xxx.module.metadata.js
, but with no luck. Not sure if that constitutes any proof though.
Has anyone tried with AOT and recent ng2-bootstrap versions?
Upvotes: 0
Views: 1913
Reputation: 12705
After adding console logs to @angular compiler.umd.js
, the issue came out and - I'd like to make it clear - it is completely unrelated to ng2-bootstrap.
After recent changes, code definining main application module changed from this:
import { appProviders } from '../app/providers';
// ...
@NgModule({
providers: [appProviders],
// ...
to this:
import { appProviders as providers } from '../app/providers';
// ...
@NgModule({
providers,
// ...
basically passing an array (wrong) instead of an array of arrays (right).
The error message does not seem so helpful to get good context of the root cause, so I'm leaving this thread here, in case it might be helpful.
Upvotes: 1