ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Fix --aot compilation Uncaught Error: Unexpected value 'Ng2DatetimePickerModule' imported by the module 'AppModule' #87

Closed vinagreti closed 7 years ago

vinagreti commented 7 years ago

When compiling in AOT mode, I'm getting this error:

Uncaught Error: Unexpected value 'Ng2DatetimePickerModule' imported by the module 'AppModule'

To fix it, I had to import the module as follow:

import { Ng2DatetimePickerModule } from 'ng2-datetime-picker/src';

Note that I had to put /src at the end of the import statement to compile in AOT mode.

To fix it, you have two options: 1 - Change the docs to tell the users that they should import from 'ng2-datetime-picker/src';`; 2 - Place an index.ts exporting the module at the root folder so the compiler will find it in AOT mode.

Using: "angular-cli": "1.0.0-beta.21", "ng2-datetime-picker": "^0.9.10",

allenhwkim commented 7 years ago

That's strange. The following should work as it is. I will double check it.

package.json

 "main": "dist/ng2-datetime-picker.umd.js",
 "module": "dist/index.js",
 "typings": "dist/index.d.ts",
vinagreti commented 7 years ago

I'm using: "angular-cli": "1.0.0-beta.21", "ng2-datetime-picker": "^0.9.10",

The problem occurs when I run ng serve --aot or ng build --aot

allenhwkim commented 7 years ago

This plunker works fine without even defining any. https://plnkr.co/edit/ApJNv9?p=preview

//noinspection TypeScriptCheckImport
import { Ng2DatetimePickerModule, Ng2DateTime } from 'ng2-datetime-picker';
allenhwkim commented 7 years ago

Can you upgrade to 0.12.0? Then, let's see what happens.

vinagreti commented 7 years ago

You are using system.js here, not angular-cli, that uses webpack.

I'll update and let you know what happens!

allenhwkim commented 7 years ago

I have also tested with webpack and ngc, and both worked fine

vinagreti commented 7 years ago

Yes, it works with version 0.12. Thanks a lot! You can close this issue!