-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: _message_rpc_js__WEBPACK_IMPORTED_MODULE_8__.RPC is undefined #895
Comments
@filoozom are you using Waku Relay? Do you face this issue or is Vite properly handling CJS imports ? |
I've used |
Found the issue: babel does not process files with As React babel config in webpack: https://github.com/facebook/create-react-app/blob/9802941ff049a28da2682801bc182a29761b71f4/packages/react-scripts/config/webpack.config.js#L469 (the one with To fix it, one can from {
test: /\.(js|cjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{ helpers: true },
],
],
cacheDirectory: true,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,
// Babel sourcemaps are needed for debugging into node_modules
// code. Without the options below, debuggers like VSCode // show incorrect code and set breakpoints on the wrong lines. sourceMaps: shouldUseSourceMap,
inputSourceMap: shouldUseSourceMap,
},
}, to {
test: /\.(js|cjs|mjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{ helpers: true },
],
],
cacheDirectory: true,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,
// Babel sourcemaps are needed for debugging into node_modules
// code. Without the options below, debuggers like VSCode // show incorrect code and set breakpoints on the wrong lines. sourceMaps: shouldUseSourceMap,
inputSourceMap: shouldUseSourceMap,
},
}, (note if you use TypeScript then the |
An upstream PR is already open: https://github.com/facebook/create-react-app/pull/12605/files |
This is only specific to ReactJS that does not include Can be mitigating using |
I tried to open a master issue on react repo: facebook/create-react-app#12700 |
This is a bug report/
Problem
When using js-waku 0.25-rc.0 in ReactJS:
I am guessing it's because
RPC
is imported from a CJS module and the default webpack config of react scripts is not handling it properly:https://github.com/ChainSafe/js-libp2p-gossipsub/blob/master/src/message/rpc.js
Proposed Solutions
Need to check what is the best way to import CJS in an ESM package in the browser to ideally not have to touch the react scripts webpack config.
Note that this would also be resolved if
protons
was used instead: ChainSafe/js-libp2p-gossipsub#318The text was updated successfully, but these errors were encountered: