reTHINK-project / dev-service-framework

DEPRECATED! Service framework libs have been moved to dev-runtime-core repo
Apache License 2.0
1 stars 2 forks source link

Syncher class not compatible with Nodejs Environment #51

Closed NicoApizee closed 7 years ago

NicoApizee commented 8 years ago

The module "mutationobserver-shim" used in Syncher.js is browser specific and don't provide any implementation for nodejs (no MutationObserver API available).

We got error when loading hyperty :

window.MutationObserver=window.MutationObserver||window.WebKitMutationObserver||function(r){function w(a){this.g=[];this.k=a}function H(a){(function c(){var d=a.takeRecords();d.length&&a.k(d,a);a.f=setTimeout(c,w._period)})()}function t(a){var b={type:null,target:null,addedNodes:[],removedNodes:[],previousSibling:null,nextSibling:null,attributeName:null,attributeNamespace:null,oldValue:null},c;for(c in a)b[c]!==r&&a[c]!==r&&(b[c]=a[c]);return b}function I(a,b){var c=B(a,b);return function(d){var g=
^

ReferenceError: window is not defined
   at Object.<anonymous> (/home/jamal/Downloads/dev-runtime-nodejs/node_modules/mutationobserver-shim/dist/mutationobserver.min.js:3:1)
   at Module._compile (module.js:541:32)
   at Object.Module._extensions..js (module.js:550:10)
   at Module.load (module.js:458:32)
   at tryModuleLoad (module.js:417:12)
   at Function.Module._load (module.js:409:3)
   at Module.require (module.js:468:17)
   at require (internal/module.js:20:19)
   at Object.<anonymous> (/home/jamal/Downloads/dev-runtime-nodejs/dist/service-framework/Syncher.js:8:1)
   at Module._compile (module.js:541:32)

The window global reference dont exist on nodejs.

The official page dont include node in compatibility list : https://github.com/megawac/MutationObserver.js

vitormsilva commented 8 years ago

I removed the mutationObserver from syncher, it was there to give support the browsers which don't support the ObjectObserve and ArrayObserve.

Now should work on nodejs.

@dvilchez To continue to give support to other browsers different of Chrome and FF, I think the runtime-browser, need includes on rethink.js dist file this module:

import 'mutationobserver-shim';
import 'object.observe';
import 'array.observe';
dvilchez commented 8 years ago

well @vitormsilva, I think you mean include these polifylls on the distribution file but, I am not sure if it is a good practice or it is better only include it as a dependency on the documentation.

What do you think?

As a reference: http://programmers.stackexchange.com/questions/233980/javascript-bundle-a-required-but-common-polyfill-in-my-library http://stackoverflow.com/questions/6599815/what-is-the-difference-between-a-shim-and-a-polyfill

jboulmal commented 8 years ago

Ok @vitormsilva and @dvilchez the update is in the develop or in service-framework-nodejs branch ?

vitormsilva commented 8 years ago

@dvilchez, but if we include this as a dependency on the documentation, the bundle which is in the sandbox, don't will have access to that dependency, or has?

dvilchez commented 8 years ago

good point @vitormsilva, anyway according to canIuse web, any browser supporting web workers should support mutationobserver.

http://caniuse.com/#search=mutationobserver http://caniuse.com/#search=webworker

I think we can close this issue.

vitormsilva commented 7 years ago

We can close, because with the implementation of Proxy here we don't have this problem;