jlengstorf / learn-rollup

This is an example project to accompany a tutorial on using Rollup.
https://code.lengstorf.com/learn-rollup-js/
ISC License
191 stars 61 forks source link

Your method of importing debug results in an error #29

Closed jasonburrows closed 7 years ago

jasonburrows commented 7 years ago

When I try to import and use debug the way you are:

import debug from 'debug';
const log = debug('app:log');

It results in the error Module "..../debug/index" has no default export.. I have to import it like this:

import * as debug from 'debug';

which then results in a rollup error:

Cannot call a namespace ('debug')

Any idea what the difference might be?

jlengstorf commented 7 years ago

@jasonburrows Hmm... that's odd. Can you share the repo you're working in?

I'd start by checking version numbers; it's possible debug and/or rollup have new releases that changed behavior. Beyond that, I'd need to take a look at the code to help troubleshoot.

jasonburrows commented 7 years ago

@jlengstorf Hi - I apologize for not returning and adding to this issue when I learned more.

It turns out that my problems were due to importing @types/debug. If I remove @types/debug, everything works using your suggested method of importing. I'm not sure why, but since I'm not actually using any of the type information offered in @types/debug, I just moved on.

Regardless, it seems to be a bug with @types/debug, not your project, debug, or rollup.

I didn't even think about it - I'm used to just importing that type information and did it on autopilot without considering it may have been the source of the problem.

jlengstorf commented 7 years ago

Thanks for the clarification. Closing this; let me know if it turns out there's something in this config that was interfering with @types/debug.