Closed zdila closed 8 years ago
I am not familiar with webpack. attachMediaStream is an attribute of AdapterJS. It is a global function. Did you take this in account ?
Maybe I do something wrong, but in my case AdapterJS.attachMediaStream
is undefined
. It contains only following properties:
> Object.keys(AdapterJS)
< ["options", "VERSION", "onwebrtcready", "_onwebrtcreadies", "webRTCReady", "WebRTCPlugin", "onwebrtcreadyDone", "maybeThroughWebRTCReady", "TEXT", "_iceConnectionStates", "_iceConnectionFiredStates", "isDefined", "parseWebrtcDetectedBrowser", "maybeFixConfiguration", "addEvent", "renderNotificationBar"]
Regarding Webpack - it just packages the modules from npm (and bower) to single bundle.js
. If a module uses global variables, they are treaten as module-local variables and are not visible to other modules. But assigning to window.attachMediaStream
should work. Also it is possible to tell Webpack to bind module-local variables of specific module to window
so I can work it around. They say it is for "broken" modules.
oops, I missed the not... attachMediaStream is NOT an attribute of AdapterJS.
you should be able to access it globally.
OK, I can. But I must tell webpack to treat AdapterJS as "broken" module.
To "fix" it there may be more alternatives. One of:
window
(eg. window.attachMediaStream = ...
)@ncurrier I'm fine with setting window.attachMediaStream = attachMediaStream
Any opinion on this ?
It was hard but my workaround (using Webpack) is:
const ajs = require("imports?module=>false!exports?AdapterJS&attachMediaStream&getUserMedia&RTCPeerConnection&createIceServer!adapterjs");
const {AdapterJS, attachMediaStream, getUserMedia, RTCPeerConnection, createIceServer} = {...ajs};
I'll add attachMediaStream in AdapterJS and in window either today or tomorrow
PR merged and released: https://github.com/Temasys/AdapterJS/releases/tag/0.13.1
I am closing this issue, please feel free to re-open it if relevant.
All public properties should be added to window or better - should be exported from the module.
My current working solution (workaround) for webpack is to import adapterjs like this:
require('!script!adapterjs/publish/adapter.debug.js');
I agree. @letchoo we should do that in the near-ish future.
It is impossible to get
attachMediaStream
when using webpack and sourceimport AdapterJS from 'adapterjs';
Object
AdapterJS
has no reference toattachMediaStream
or other objects/functions.window.RTCPeerConnection
is available (because it is set to thewindow
object)