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.

Dynamic requires are not currently supported by rollup-plugin-commonjs

See original GitHub issue

When I use Rollup (https://rollupjs.org/) to bundle Winston, the following error is thrown when running the app:

node example/index.js        
/Users/mike/logging/lib/bundle.js:21
        throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
        ^

Error: Dynamic requires are not currently supported by rollup-plugin-commonjs
    at commonjsRequire (/Users/mike/logging/lib/bundle.js:21:8)
    at Function.get (/Users/mike/logging/lib/bundle.js:8108:31)
    at _getConsoleLogFormat (/Users/mike/logging/lib/bundle.js:10777:10)
    at _winstonConsole (/Users/mike/logging/lib/bundle.js:10792:13)
    at getTransports (/Users/mike/logging/lib/bundle.js:10814:13)
    at Object._init (/Users/mike/logging/lib/bundle.js:10820:17)
    at Object.<anonymous> (/Users/mike/logging/example/index.js:4:23)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)

The issue is caused by https://github.com/winstonjs/logform/blob/master/index.js#L27. Ideally, it’d be great to revert back to https://github.com/winstonjs/logform/commit/972dbece432dbda7a0aeae4c4a7ac8d549821a78#diff-168726dbe96b3ce427e7fedce31bb0bcL21. Although more verbose, it would open up Winston to being bundled by Rollup once https://github.com/winstonjs/winston/pull/1100 is merged.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
wyattjohcommented, Nov 16, 2017

This is also a major issue when trying to integrate with https://github.com/zeit/pkg.

0reactions
klardotshcommented, Apr 8, 2021

This issue also causes a slew of warnings (that then become runtime issues I have to assume, looking at the output files) with evanw/esbuild. It looks like my best workaround for the time being is to fork this repo and use https://classic.yarnpkg.com/en/docs/selective-version-resolutions/ to point at that fork?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to track down "Dynamic requires are not currently ...
I'm getting "Dynamic requires are not currently supported by rollup-plugin-commonjs" error in the runtime when I bundle and run my actual ...
Read more >
Dynamic requires are not currently supported by rollup-plugin ...
I'm trying to figure out how I can include Handlebars import Handlebars from 'handlebars'; for use in my project using rollupjs. Any ideas?...
Read more >
@rollup/plugin-commonjs - npm
Convert CommonJS modules to ES2015. Latest version: 24.0.0, last published: 14 days ago. Start using @rollup/plugin-commonjs in your project ...
Read more >
rollup.js
By default, Rollup will expect config files to be ES modules and bundle and transpile them and their relative imports to CommonJS before...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Step 4: Add plugins to handle non-ES modules. This is important if any of your dependencies use Node-style modules. Without it, you'll get...
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