Dayjs: Module has no has no default export with ts and rollup

Created on 10 Jul 2018  路  10Comments  路  Source: iamkun/dayjs

import dayjs from 'dayjs'

compile with rollup , got error `Module

".../source/node_modules/dayjs/index" has no default export.

Most helpful comment

Try import * as dayjs from 'dayjs', it helped me 馃槂

All 10 comments

any updates on this?

Try import * as dayjs from 'dayjs', it helped me 馃槂

@Kikisek I did like what you mentioned...

like this:

import * as dayjs from dayjs

I am hitting this error now:

Uncaught TypeError: dayjs is not a function

@aibrahim3546 to be sure, do you have quotes around the second dayjs?

import * as dayjs from 'dayjs'

@waitingsong @iamkun I re-did the Typescript definition in #466 which should fix the problem of default import. The current index.d.ts file does not make much sense to expose class to the user.

Updates:

From v1.8.1 we could simply use import dayjs from 'dayjs' in a TypeScript project.

Looks like this was reverted again here https://github.com/iamkun/dayjs/pull/476, so it's broken again as of 1.8.4 for rollup and things that use rollup, ng-packagr etc

As @Smirking said, this is broken as of now and we have to use @Kikisek workaround.

Even with @Kikisek workaround, I'm getting:
TypeError: dayjs is not a function

version: 1.8.28

Also getting this version: 1.8.35

Was this page helpful?
0 / 5 - 0 ratings