question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use debug with Rollup

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
Rich-Harriscommented, Jun 16, 2017

@StreetStrider that’s a fair assessment of what’s happening. But it sounds like this is probably a fixable bug in rollup-plugin-commonjs — I suspect it just doesn’t know what to make of this code:

exports = module.exports = require('./debug');

I’ve opened a related issue over there: https://github.com/rollup/rollup-plugin-commonjs/issues/204

1reaction
iFwucommented, Jan 17, 2019

If I don’t use dist version of debug, the arrow functions in src/browser will not run in IE11.

That’s not a problem with Rollup. You need to use Babel.

You can tell that I need to transpile, but when I use babel with typescript and it will cause this issue when compiled to common-js plugin of rollup.

This doesn’t make any sense. Can you explain, please?

After separating the node and browser build, the problem no longer exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use debug with Rollup · Issue #468 - GitHub
There're a troubles both using debug directly (via import debug from 'debug' ) and as a dependency to another package, with Rollup bundler....
Read more >
How to debug a Typescript library compiled with Rollup in a ...
The library is developed with typescript so I'm compiling it with rollup using the follow configuration: rollup.config.js
Read more >
how do you use the Chrome Debugger with the Rollup bundler?
I am playing with the new RC.0 release and I'm trying to inspect my code from the Chrome Debugger. I use npm run...
Read more >
Debugging Rollup! - YouTube
... out your way among the module bundlers. Here's a small video on how to debug, hack Rollup ! ... Your browser can't...
Read more >
rollup.js
When using the JavaScript API, the configuration passed to rollup.rollup must be an object and cannot be wrapped in a Promise or a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found