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

Fix rollup error. #1556

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Conversation

jimmytheneutrino
Copy link
Contributor

I couldn't use ng2-bootstrap's datepicker as is with rollupjs because rollup cannot process import * as moment from 'moment', instead import moment from 'moment' should work.
See rollup/rollup#670

Rollup cannot process `import * as moment from 'moment'`, instead `import moment from 'moment'` should work.
See rollup/rollup#670
@valorkin
Copy link
Member

Thanks, I will try this with webpack and system.js and merge

@jimmytheneutrino
Copy link
Contributor Author

I realized that I actually did break typescript compilation. Setting
"allowSyntheticDefaultImports": true
fixes it. I am not sure if you want to go ahead with this option but IMHO it is not dangerous and is the simplest fix for the problem (one other option is, e.g., fixing moment's modules).

@valorkin
Copy link
Member

There are were an issue with such imports earlier, when ts typings was in issue

@codecov-io
Copy link

Current coverage is 84.96% (diff: 100%)

Merging #1556 into development will not change coverage

@@           development      #1556   diff @@
=============================================
  Files               82         82          
  Lines             2301       2301          
  Methods             20         20          
  Messages             0          0          
  Branches           298        298          
=============================================
  Hits              1955       1955          
  Misses             246        246          
  Partials           100        100          

Powered by Codecov. Last update 9568c14...5f898a4

@valorkin
Copy link
Member

valorkin commented Feb 8, 2017

with import moment from 'moment';

I am getting

Error at /home/valorkin/work/open-source/ng2-bootstrap/src/datepicker/date-formatter.ts:1:8: 
Module '"/home/valorkin/work/open-source/ng2-bootstrap/node_modules/moment/moment"' has no default exp

from ngc -p src ;(
seems to be a dead end, we need to find a way how to configure rollup

@jimmytheneutrino
Copy link
Contributor Author

Yeah. See my previous comment. Setting "allowSyntheticDefaultImports" to true fixes it.

@jimmytheneutrino
Copy link
Contributor Author

Btw, if anyone needs this fix urgently, I temporarily published version 1.3.0 with this fix included at https://github.com/jimmytheneutrino/ng2-bootstrap/releases/tag/v1.3.0-fix.2 .

This should work with npm/yarn like this:

"ng2-bootstrap": "https://github.com/jimmytheneutrino/ng2-bootstrap/releases/download/v1.3.0-fix.2/dist.tgz"

@valorkin valorkin merged commit 27a0229 into valor-software:development Mar 9, 2017
valorkin pushed a commit that referenced this pull request Jun 15, 2017
@codez
Copy link

codez commented Jul 11, 2017

In the 1.7.1 npm, date-formatter.js still contains import * as moment from 'moment';, which fails the rollup process. Is this a regression or how does this statement get there?

@valorkin
Copy link
Member

Merge conflict, actually

@jimmytheneutrino
Copy link
Contributor Author

jimmytheneutrino commented Jul 11, 2017

In our project we ended up creating a utility module a la

import * as realMoment from 'moment';
export const moment = (realMoment as any).default ? (realMoment as any).default : realMoment;

and using it like
import {moment} from './util/moment'; .

This should be ok for all environments.

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

Successfully merging this pull request may close these issues.

4 participants