Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline zen-observable #105

Merged
merged 9 commits into from
Jul 9, 2021
Merged

inline zen-observable #105

merged 9 commits into from
Jul 9, 2021

Conversation

brainkim
Copy link
Contributor

@brainkim brainkim commented Jul 8, 2021

@benjamn This what you meant?

Snowpack seems to be having a strange moment where zen-observable-ts’s super shim is ignored or erased. See apollographql/apollo-client#8467. This PR uses rollup to inline the zen-observable dependency. Not sure if any of this is wise.

module.js Outdated
Comment on lines 1 to 9
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function () {}; return { s: F, n: function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (e) { throw e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function () { it = it.call(o); }, n: function () { var step = it.next(); normalCompletion = step.done; return step; }, e: function (e) { didErr = true; err = e; }, f: function () { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up using Babel because that's what zen-observable uses. I don't love these injected helpers, but I also don't think we want to depend on @babel/runtime if we can help it.

@benjamn benjamn force-pushed the brian-inline-zen-observable branch from 3431866 to d6dc043 Compare July 8, 2021 21:50
Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this PR will fix the reproduction provided by @sebastienbarre in apollographql/apollo-client#8467. 🎉

@brainkim
Copy link
Contributor Author

brainkim commented Jul 8, 2021

Probably should gitignore module.js and index.js in the root if we’re using a prepublish command

package.json Outdated Show resolved Hide resolved
@benjamn benjamn merged commit e331060 into main Jul 9, 2021
benjamn added a commit that referenced this pull request Jul 9, 2021
Minor version bump due to the scope of internal changes from PR #105,
though the changes should be backwards-compatible.
benjamn added a commit to apollographql/apollo-client that referenced this pull request Jul 9, 2021
benjamn added a commit that referenced this pull request Aug 24, 2021
We implemented these methods explicitly in PR #1, but then PR #105 went
back to compiling `Observable` down to ES5 constructor functions.

In other words, the current implementations of `Observable` (both
CommonJS and ESM) automatically have these static methods, and they work
just like `Function.prototype.{call,apply}`, because `Observable` is
compiled in both cases from a `class` to a constructor function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants