Skip to content
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

AOT/ngc: config._d.getTime is not a function -> can't import Modules from 'ng2-bootstrap/ng2-bootstrap' #1179

Closed
goleary opened this issue Oct 28, 2016 · 9 comments

Comments

@goleary
Copy link
Contributor

goleary commented Oct 28, 2016

when I try import { CarouselModule } from 'ng2-bootstrap/ng2-bootstrap' it builds correctly but I get the following runtime error:
image

The same happens for the TooltipModule (haven't tested any others).

If i use import { CarouselModule } from 'ng2-bootstrap/component/carousel' however it works fine.
I see in the documentation that one can use either method? why does one of them fail?

NOTE: I am using ngc for AOT compilation & Rollup for tree shaking prior to seeing the error, haven't tested without.

@Martin-Luft Martin-Luft changed the title Can't import Modules from 'ng2-bootstrap/ng2-bootstrap' AOT/ngc: config._d.getTime is not a function -> can't import Modules from 'ng2-bootstrap/ng2-bootstrap' Nov 1, 2016
@alanhe421
Copy link

u should post your package.json。
we need know version of package

@goleary
Copy link
Contributor Author

goleary commented Nov 10, 2016

Sorry for the delay in response, I am using the latest version on npm: 1.1.16

here are my dependencies:

  "dependencies": {
    "@angular/common": "2.0.2",
    "@angular/compiler": "2.0.2",
    "@angular/compiler-cli": "^0.6.2",
    "@angular/core": "2.0.2",
    "@angular/forms": "2.0.2",
    "@angular/http": "2.0.2",
    "@angular/platform-browser": "2.0.2",
    "@angular/platform-browser-dynamic": "2.0.2",
    "@angular/upgrade": "2.0.2",
    "angular2-infinite-scroll": "^0.2.1",
    "bootbox": "^4.4.0",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "es6-shim": "^0.35.1",
    "file-saver": "^1.3.3",
    "hopscotch": "^0.2.5",
    "jquery": "^2.2.0",
    "knockout": "^3.4.0",
    "knockout-mapping": "^2.6.0",
    "knockout-secure-binding": "^0.5.5",
    "lodash": "^4.12.0",
    "ng2-bootstrap": "^1.1.16",
    "optimal-select": "^3.3.0",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "rxjs-es": "5.0.0-beta.12",
    "systemjs": "0.19.39",
    "zone.js": "^0.6.25"
  },

@goleary
Copy link
Contributor Author

goleary commented Nov 10, 2016

let me know if I can provide any more info

@valorkin
Copy link
Member

@goleary can you drop rollup config? and search issues about rollup? usually commonjs plugin is missing

@goleary
Copy link
Contributor Author

goleary commented Nov 17, 2016

I searched around and tried the solution here: #1188 but it didn't fix the problem.

I wouldn't say this is high priority as I already used the other import statement to get it working, I'm just curious why it isn't working as advertised in the docs

rollup config:

import typescript from 'rollup-plugin-typescript';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

class RollupNG2 {
  constructor(options){
    this.options = options;
  }
  resolveId(id, from){
    if (id.indexOf('rxjs/') >= 0){
      console.log(id, from);
    }
    if (id.startsWith('rxjs/')){
      var result = `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`;
      if (!__dirname.startsWith("/")) { 
        return result.replace(/\//g, "\\");
      }
      return result;
    }
  }
}

const rollupNG2 = (config) => new RollupNG2(config);

export default {
  sourceMap: false, //to figure out how to use sourceMap later
  plugins: [
    typescript(),
    rollupNG2(),
    nodeResolve({
      jsnext: true,
      main: true,
      browser: true
    }),
    commonjs()
  ]
}


@valorkin
Copy link
Member

from v1.1.16-9 and ng v2.4
works fine with AoT
new docs preview http://valorkin.github.io/ng2-bootstrap/#/

@goleary
Copy link
Contributor Author

goleary commented Dec 30, 2016

Thanks, I'll try the upgraded version later today!

@goleary
Copy link
Contributor Author

goleary commented Dec 30, 2016

just curious, I've never seen major.minor.patch-# versions on npm before. I had to remove and reinstall the package just to get the new code (instead of updating as I am using 6 operator on version in package.json). Is this to be expected or is there some problem?

@valorkin
Copy link
Member

This versioning is achieved via npm version pre-release, actually it is just a semver
You can expect some breaking changes in how you import modules. And removed hack for modals. All else is mostly the same + popover, a lot of fixes, tests and docs

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

3 participants