donejs / bitballs

A basketball tourney application.
https://donejs.com/bitballs.html
MIT License
11 stars 17 forks source link

KefirJS Weirdness #332

Closed justinbmeyer closed 6 years ago

justinbmeyer commented 6 years ago

For some reason, require("kefir") in can-kefir is getting the Module object in bitcentive. This is now failing because can-kefir tries to set a property on Kefir. But the object is sealed and an error is thrown.

Kefir seems to be identified as an AMD module:

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (factory((global.Kefir = global.Kefir || {})));
}(this, function (exports) { 'use strict';

But what's odd is that kefir does this with the exports object:

var Kefir = { Observable: Observable, Stream: Stream, Property: Property, never: never, later: later, interval: interval, sequentially: sequentially,
      fromPoll: fromPoll, withInterval: withInterval, fromCallback: fromCallback, fromNodeCallback: fromNodeCallback, fromEvents: fromEvents, stream: stream,
      constant: constant, constantError: constantError, fromPromise: fromPromise, fromESObservable: fromESObservable, combine: combine, zip: zip, merge: merge,
      concat: concat$1, Pool: Pool, pool: pool, repeat: repeat, staticLand: staticLand };

    Kefir.Kefir = Kefir;

    exports.dissableDeprecationWarnings = dissableDeprecationWarnings;
    exports.Kefir = Kefir;
    exports.Observable = Observable;
    exports.Stream = Stream;
    exports.Property = Property;
    exports.never = never;
    exports.later = later;
    exports.interval = interval;
    exports.sequentially = sequentially;
    exports.fromPoll = fromPoll;
    exports.withInterval = withInterval;
    exports.fromCallback = fromCallback;
    exports.fromNodeCallback = fromNodeCallback;
    exports.fromEvents = fromEvents;
    exports.stream = stream;
    exports.constant = constant;
    exports.constantError = constantError;
    exports.fromPromise = fromPromise;
    exports.fromESObservable = fromESObservable;
    exports.combine = combine;
    exports.zip = zip;
    exports.merge = merge;
    exports.concat = concat$1;
    exports.Pool = Pool;
    exports.pool = pool;
    exports.repeat = repeat;
    exports.staticLand = staticLand;
    exports['default'] = Kefir;

    Object.defineProperty(exports, '__esModule', { value: true });

I feel like this must be tripping stuff up ...

I can see where Object.preventExtensions(m); is called, but not sure why it is.

For some reason, while I'm running can-kefir's tests. The Object.preventExtensions() is called, but called after can-kefir.js has been executed.

justinbmeyer commented 6 years ago

This was for bitcentive.