Comments (4)
Thanks for reporting this. I as well encountered the warning and wasn't sure about its origin. That's clearly something to be urgently fixed as especially CI tools will immediately error-out as compilation warnings are typically escalated to errors.
The issue will be worked on with high priority.
from vrpc-js.
Branch bugfix/36-dynamic-require-in-vrpcadapter-js-breaks-webpack-5 created!
from vrpc-js.
As we were discussing this for the Connectware, we saw that the problem with the dynamic require
is a problem only in the frontend. The usage of that feature, on the other hand, is only in the backend (the protocol-mapper, as you remember). So one solution here would be to separate it out of the main VrpcAdapter class into something that can be require
-d in the backend but not in the frontend.
from vrpc-js.
To add more information, as we are updating the front-end bundler, the new Webpack v5 has found some issues regarding vrpc that required custom configuration.
Dealing with the dynamic resolver
The bundler will go through all the dependencies referenced by the entry point file (usually src/index.js
) and attempt to bundle every referenced file into N output files on the created bundle.
Therefore the dynamic resolver should not work on the frontend, as the dynamic files will never be loaded there.
Due to the dynamic resolver though, webpack will try then to load every file (included python scripts on other misc files), in order to, I think, achieve the least amount of module-not-found-failures.
To fix this, I had to add this custom webpack v5 resolver rule:
{
/**
* if vrpc, ignore non js/jsx files
*/
test: { and: [/(node_modules\/vrpc)/i, { not: [/\.(js|jsx)$/] }] },
loader: 'ignore-loader'
}
Before, the react-scripts would just ignore the errors when loading files, and use only js files that were successfully parsed.
Fallbacks and global definitions
I also noticed some references to node core libraries/classes, such as os
, fs
, Buffer
and path
.
The react-scripts bundler pre-loaded these into the outputted bundle which omitted any errors.
As Webpack removes the kid bicycle wheels, I had to add these configurations:
Fallback configuration, so I can tell webpack to load my browserfied alternatives instead of telling me os
is not compatible with frontend.
{
os: require.resolve("os-browserify/browser"),
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"path": require.resolve("path-browserify"),
fs: false
}
Define plugin configuration so I can tell Webpack that a global variable named Buffer
needs to exist
{
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}
I'm not saying all the libs above are used on the vrpc, but some for sure are, I would suggest having a strictly front-end section of the vrpc project so it can either load the browserfied versions of that code, or not use them all together.
Let me know if you need more comments.
from vrpc-js.
Related Issues (20)
- Trying to wrap a C++ class that is non-copyable will fail to compile, unless a operator<< is defined for the class, too. HOT 2
- When embedding C++ code provide a possibility to execute the client call asynchronously
- Missing error event when agent fails to connect HOT 1
- Attaching to instances won't reliable work when using many agents HOT 1
- Add actual code to all examples and integrate them to testing pipeline HOT 1
- VrpcLocal callback stops working after a second instance have been created HOT 1
- Allow the remote client to unregister an offline agent HOT 1
- Remove the domain inconsistency in the VrpcRemote API HOT 1
- Fix VrpcRemote documentation/behaviour
- C++ compile failure on addon with vrpc 2.4.0 HOT 1
- "Random" ProxyId runs into collisions on 'state' event emitters HOT 4
- Broken links in README HOT 1
- Inject clear information about instance-, proxy- and client id into the proxy instance HOT 1
- Instances: conceptually move from "named" and "anonymous" to "shared" and "isolated" modes HOT 1
- Exceptions on a VrpcLocal callback cause process crash HOT 3
- is it possible to implement this with custom MQTT Server? HOT 1
- Add possibility to set a custom MQTT client Id in VrpcAgent HOT 3
- Missing error handling of failed MQTT subscribes HOT 1
- Provide Adapter and Agent for browsers as well HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vrpc-js.