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 process working in 1.2.6 now failing in 1.3 #1573

Closed
budcribar opened this issue Jan 28, 2017 · 14 comments
Closed

aot process working in 1.2.6 now failing in 1.3 #1573

budcribar opened this issue Jan 28, 2017 · 14 comments
Labels

Comments

@budcribar
Copy link

Fails during the rollup step in the aot process
rollup -c rollup-config.js produces

Cannot call a namespace ('moment')
node_modules\ng2-bootstrap\datepicker\date-formatter.js (6:15)
4: }
5: DateFormatter.prototype.format = function (date, format) {
6: return moment(date.getTime()).format(format);
^
7: };
8: return DateFormatter;

@budcribar
Copy link
Author

rollup config:

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

export default {
entry: 'app/main.js',
dest: 'dist/build.js', // output a single application bundle
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: [

     'node_modules/rxjs/**',
     'node_modules/ng2-truncate/dist/**',
     'node_modules/ng2-bootstrap/**',
     'node_modules/ng2-pagination/**',
     'node_modules/angular2-highcharts/**'
    ],
     namedExports: {
            'node_modules/angular2-highcharts/index.js': ['ChartModule'],
             'node_modules/ng2-pagination/index.js': ['Ng2PaginationModule'],                   
             'node_modules/ng2-truncate/dist/index.js': ['TruncateModule'],

                   
        }

  }),
  uglify()

]
}

@budcribar budcribar reopened this Jan 28, 2017
@valorkin
Copy link
Member

it could be fixed with build configuration
check comments here: #1556

@valorkin
Copy link
Member

@budcribar please try a solution from PR
if it will not work, please give a note in PR

@xclayl
Copy link

xclayl commented Feb 3, 2017

I'm had the same issue (rollup js failing). Using version 1.2.6 fixed it for me. Setting
"allowSyntheticDefaultImports": true
had no impact on my angular2 project (rollup still failed with 1.3.0)

@valorkin
Copy link
Member

valorkin commented Feb 3, 2017

@xclayl please try v1.3.3

@xclayl
Copy link

xclayl commented Feb 6, 2017

@valorkin Thanks, but 1.3.3 still fails with the "moment" error when doing the AOT build. I deleted my node_modules folder and ran "npm install" before testing.

@valorkin
Copy link
Member

valorkin commented Feb 6, 2017

@xclayl does it works with "allowSyntheticDefaultImports": true ?

@robdunnwinning
Copy link

This issue still occurs with "allowSyntheticDefaultImports": true.

Changing:
import * as moment from 'moment';
to
import moment from 'moment';

in /src/datepicker/date-formatter.ts seems to have fixed the problem for me with v1.3.3 however I have not had a look to see if there are any regressions from changing this.

@nastakhov
Copy link

nastakhov commented Feb 24, 2017

Still doesn't work for 1.3.3
Forced to use ng2-bootstrap 1.2.6

"Cannot call a namespace ('moment')"
allowSyntheticDefaultImports: true doesn't help

@kisdaniel
Copy link

I also have the same issue and downgrading to 1.2.6 not solves my problem it also shows the same error:

node_modules/ng2-bootstrap/datepicker/date-formatter.js (6:15)
4:     }
5:     DateFormatter.prototype.format = function (date, format) {
6:         return moment(date.getTime()).format(format);
                  ^
7:     };
8:     return DateFormatter;

What I can do is change this line in date-formatter.js
from
import * as moment from 'moment';
to
import moment from 'moment';

@valorkin
Copy link
Member

valorkin commented Mar 5, 2017

For some reason this doesn't work for me:
import moment from 'moment';

.<

@budcribar
Copy link
Author

I am still having this problem in 3 different projects. Is there a workaround other than reverting back to 1.2.6?

@valorkin
Copy link
Member

 I am using angular-cli and AoT works fine,
what are you using?

@xclayl
Copy link

xclayl commented Mar 12, 2017

I haven't tried this yet, but my system.js differs from the recommendation here (angular2 quickstart-based): https://github.com/valor-software/angular2-quickstart/blob/master/README.md

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

No branches or pull requests

6 participants