obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
667 stars 96 forks source link

Export using commonjs-module in webpack so it can be imported using static imports #171

Closed artdevgame closed 4 years ago

artdevgame commented 4 years ago

Related Issue (if applicable):

170

Description:

The dist version can now be imported using static imports. Previously this was not working for me.

artdevgame commented 4 years ago

I don't understand the build errors, any chance someone can help me figure them out please?

haganbmj commented 4 years ago

Sorry for the delay, lost interest in this a year ago and it's fallen into disarray lol Looking into the build failures now. It's failing while trying to build the type definitions, specifically using the github api to pull the source files from obs-websocket. It might just be a matter of environment variable exposure between forks and the main repo...

haganbmj commented 4 years ago

Apparently it's getting rate limited. I would assume it's because of the matrix builds running 2 each for both the pr and push jobs?

'x-ratelimit-limit': '60',
'x-ratelimit-remaining': '53',

I'll look at if caching the response can take care of that. In the meantime though let me know if a umd does what you want.

Exporting as a pure CommonJS prevents the window level import. A UMD does the following to switch based on the environment.

(function webpackUniversalModuleDefinition(root, factory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if(typeof define === 'function' && define.amd)
        define([], factory);
    else if(typeof exports === 'object')
        exports["OBSWebSocket"] = factory();
    else
        root["OBSWebSocket"] = factory();
})(window, function() {
haganbmj commented 4 years ago
travis-fork

Forks don't get the secrets so maybe it's getting thrown in with other requests on travis. That or I'm just misreading the error and the issue is simply passing an undefined token.

haganbmj commented 4 years ago

Just added a commit to remove the header for non-token builds. Might just watch it and see if that's sufficient.

haganbmj commented 4 years ago

@Lange you probably have much better knowledge about all the module types and how that jazz works. If you don't foresee any issues with a umd I'd want to merge this in and try to tag a release. Want to verify that my npm tokens are still valid.

haganbmj commented 4 years ago

v4.0.0 is available in npm and bower now.