Skip to content

Cannot use debug with Rollup #468

@StreetStrider

Description

@StreetStrider

There're a troubles both using debug directly (via import debug from 'debug') and as a dependency to another package, with Rollup bundler.

  1. import debug from 'debug':

Non-existent export 'default' is imported from node_modules/debug/src/browser.js

I believe this is because of that dynamic stuff.

  1. import SocketIo from 'socket.io-client' which has debug as a dependency:

'default' is not exported by 'node_modules/socket.io-client/node_modules/debug/src/browser.js'

As far as I understood, the main idea behind browser.js is to import kinda «base» debug object and upgrade it with browser-specific methods' implementations. I believe this can be rewritten in more static and bundler-friendly way. Like requiring base, propagate it with methods and then export as a default in different statements which would simplify the analysis by Rollup and other-like.

I'm not an active debug user, but debug is very popular tool, so many of my packages' of choice using it as a dependency. So I stumble upon it when bundling, from time to time. Leveraging any workarounds is diffcult, since I do not have precision control over dependencies of my dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions