Webpack build of kurento-client-js circular links

I encountered an error while trying to create kurento-client-js using Webpack 2 + babel.

WARNING in ./node_modules/kurento-client/lib/register.js 60:20-33 Critical dependency: the request of a dependency is an expression 

When executed, this leads to

 Uncaught Error: Cannot find module "." 

I believe the problem itself is caused by require inside /lib/register.js

 //kurento-clinet/lib/register.js if (constructor == undefined) return register(require(name)); 

And the code causing the error:

 //kurento-clinet/lib/index.js //this module requires kurento-client resulting in circular reference register('kurento-client-core') 

The kurento bower package contains a distribution built using a browser.

Interestingly, someone tried to create kurento-client-js using webpack. Share your experience.

EDIT

Trace stack error circular dependency:

 Uncaught TypeError: Cannot read property 'MediaObject' of undefined at Object._typeof (KurentoClient.js:42) at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19) at Object._typeof (index.js:44) at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19) at Object.module.exports (HubPort.js:21) at __webpack_require__ (bootstrap 0d7eac46304670c5f3b5:19) at Object._typeof (index.js:32) at ... 
+7
javascript webpack babeljs kurento
source share
1 answer

First of all, webpack complains about dynamic dependency (which cannot be resolved when building the package). This is not a circular addiction.

I started working like this:

1) in your main.js application main.js need manually all the modules for which the register() function may be needed

 require('kurento-client-core') require('kurento-client-elements') require('kurento-client-filters') const kc = require('kurento-client-core/lib/index.js') console.log(kc) 

2) use this webpack plugin to completely ignore unresolved / dynamic calls to require()

 //in webpack.config.js plugins:[ function() { this.parser.plugin('call require', function(expr) { if (expr.arguments.length !== 1) { return; } const param = this.evaluateExpression(expr.arguments[0]); if (!param.isString() && !param.isConditional()) { return true; } }); } //... other plugins ] 

Webpack2 will warn about the old plugin format, but it works

Credits go: fooobar.com/questions/847470 / ...

0
source share

All Articles