phoenix 1.4 webworker
Able to use phoenix.js in webworker. It worked in 1.3.4
Failed since webworker does not have window object.
```
!(function(e, t) {
'object' == typeof exports && 'object' == typeof module
? (module.exports = t())
: 'function' == typeof define && define.amd
? define([], t)
: 'object' == typeof exports
? (exports.Phoenix = t())
: (e.Phoenix = t());
})(window, function() {
````
how are you requiring the source? If you require the es6 modules directly than our built phoenix.js, does it work? Thanks!
I copied down 1.4.0 phoenix JS and threw it in my project, because I lack the expertise to require ES6 modules directly in our build system. This allowed it to work. However, setting the main in package.json to a build that doesn't work in all cases seems dangerous and confusing for people trying to get this to work. Would it be possible to end up with a more system-agnostic priv/static/phoenix.js file and/or set main to be phoenix.js and let consumers minify and bundle on their own terms?
This is how it works in 1.3.4 and the same imports fail in 1.4 due to the fact that webworker does not have window object by design.
import { Socket as PhoenixSocket } from 'phoenix';
import { createAbsintheSocketLink } from '@absinthe/socket-apollo-link';
import * as AbsintheSocket from '@absinthe/socket';
This is fixed on master. If/when the globalTarget: 'universal' support lands in webpack, we can simply our current global lookup. Thanks!
https://github.com/webpack/webpack/issues/6525
@chrismccord can you release this fix as a minor patch? absinthe-socket depends on phoenix.js which makes it not usable on worker environments or Next.js.
@chrismccord maybe phoenix NPM package should be versioned independently form the Phoenix itself. Instead it should use protocol version as a version. It could simplify bug fixes releases like this one.
Most helpful comment
@chrismccord can you release this fix as a minor patch? absinthe-socket depends on phoenix.js which makes it not usable on worker environments or Next.js.