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.

Incompatible with Webpack 5 due to process dependency

See original GitHub issue

Describe the bug

Webpack 5 removes process (see https://webpack.js.org/migrate/5/), effectively making it impossible to use this library since it has code like:

function asap(task) {
  var rawTask;

  if (freeTasks.length) {
    rawTask = freeTasks.pop();
  } else {
    rawTask = new RawTask();
  }

  rawTask.task = task;
  rawTask.domain = process.domain;
  (0, _raw.rawAsap)(rawTask);
}

Reproduction

Use react-dnd 11.x and Webpack 4. Add the following to your Webpack config:

    node: {
      Buffer: false, // WEBPACK 5: Remove
      process: false, // WEBPACK 5: Remove
    },

Expected behavior

react-dnd should work in Webpack 5 builds

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

8reactions
yoo-hooocommented, Oct 29, 2020

I had the same issue but I was able to fix it by updating my webpack config file from mainFields: ['main', 'browser'] to mainFields: ['browser', 'module', 'main'], since @react-dnd/asap exposes a browserified version via the module field in the package.json which doesn’t have any dependencies on process. @nishadthajudeen @csvan

4reactions
AlexanderFlatschercommented, Jan 18, 2021

I had the same issue but adding module to mainFields unfortunately caused new issues with other packages in my project. Therefore I’ve added the following resolve.alias to my webpack config to solve this error:

'@react-dnd/asap': '@react-dnd/asap/dist/esm/browser/asap.js'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade to Webpack 5 failing - node.js - Stack Overflow
You need to fix scripts/start.js file. There is a line in this file: const compiler = createCompiler(webpack, config, appName, urls, ...
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
Incompatible with Webpack - Google Groups
The Knockout errors are due to a current (fixed) bug in knockout 3.2.0 with how they defined their module wrapper code. Forcing the...
Read more >
[Fixed] NPM conflicting peer dependency error
compression-webpack-plugin@"9.0.1" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command ...
Read more >
How to Upgrade to React 17 and Webpack 5 Step by Step
3. Remove "Webpack" from dependencies and/or devDependencies in the package.json file in your project folder. 4. Run npm install or yarn, ...
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