fbjs
fbjs copied to clipboard
ERROR in ./node_modules/fbjs/lib/setImmediate.js Module not found: Error: [CaseSensitivePathsPlugin]
Case sensitivity issue from fbjs causing build to fail.
ERROR in ./node_modules/fbjs/lib/setImmediate.js
Module not found: Error: [CaseSensitivePathsPlugin] /Users/KaisMi01/sdev/capture-utility/node_modules/fbjs/lib/setimmediate.js
does not match the corresponding path on disk setImmediate.js
.
Got the same issue when running webpack on a project using draft-js which has fbjs as a dependency under windows.
This issue still exists, but it is likely caused not by fbjs itself.
What is setImmediate.js intended to do is to re-export setImmediate function from setimmediate npm package (note difference in "i" casing). The latest contains setImmediate.js module (with capital "i" again). So, when you require('setimmediate')
, you actually reference to node_modules/setimmediate/setImmediate.js
, which is the problem pointed out by Webpack CaseSensitivePathsPlugin, probably a "false positive" in this case.
It seems like an issue not to be fixed soon, as it does not create a big problem except with Webpack, so we have two options:
- Disable CaseSensitivePathsPlugin which could to be not a preferred solution.
- Replace
import('setimmediate')
withimport('setImmediate')
in fbjs — CaseSensitivePathsPlugin is satisfied while npm still resolves a package correctly. This can be achieved with simple Webpack loader.
webpack.fbjs.loader.js
module.exports = function(source) {
return source.replace(
/require\((['"])setimmediate(['"])\)/g,
"require($1setImmediate$2)"
);
};
webpack.config.js
config.module.rules.push({
test: /\.js$/,
include: /node_modules/,
use: path.resolve(__dirname, 'webpack.fbjs.loader.js')
});
This didn't work for me, I am working on the SPFx React TS project, and I created the file webpack.fbjs.loader.js and added the code In my webpack.extend.js file in fast-serve folder. But nothing happened. Please help me on this, using older version of spfx.