Giter VIP home page Giter VIP logo

Comments (9)

kmalakoff avatar kmalakoff commented on August 10, 2024

I can reproduce your test case with your zip file. Thank you!

Knockback is packaged in a UMD2 format using webpack which should support most common loading schemes...see this configuration file.

There might three reasons:

  1. The libraries are adding themselves to window when loaded through AMD

  2. Webpack is adding them to window when loaded through AMD. I've looked at the code generated by webpack and it looks like there is a function for these external references webpackLoadOptionalExternalModuleAmd. Have you stepped into that to see what it does?

  3. I am added them to window. I don't see anywhere in my code where I'm putting things on window. See here where I cache the references internally.

If it is a problem for you rather than just an inconvenience, can you step through your code and pinpoint where they are added to window?

from knockback.

franzludilabel avatar franzludilabel commented on August 10, 2024

Hi,

I have looked over your code and couldnt find anything. Dont take my
word for it, I'm still new to the javascript world :)

I dont believe its Knockout.js fault (point 1)) because if you load it
without backbone, window.ko stays undefined.

I have partially read the Webpack code that you pointed out but without
success :).
But I do think thats Webpack fault.

I dont have any problem with it right now but I thought as a principle
that one library should never impact the behavior of an other.

It seems you already had some difficulties to properly configure Webpack :P
webpack/webpack#424

Le 22/01/2016 18:05, Kevin Malakoff a écrit :

I can reproduce your test case with your zip file. Thank you!

Knockback is packaged in a UMD2 format using webpack which should
support most common loading schemes...see this configuration file
https://github.com/kmalakoff/knockback/blob/master/config/builds/library/knockback.webpack.config.coffee.

There might three reasons:

  1. The libraries are adding themselves to window when loaded through AMD

  2. Webpack is adding them to window when loaded through AMD. I've
    looked at the code generated by webpack
    https://github.com/kmalakoff/knockback/blob/master/knockback.js#L13
    and it looks like there is a function for these external references
    webpackLoadOptionalExternalModuleAmd. Have you stepped into that to
    see what it does?

  3. I am added them to window. I don't see anywhere in my code where
    I'm putting things on window. See here
    https://github.com/kmalakoff/knockback/blob/master/src/core/kb.coffee#L224
    where I cache the references internally.

If it is a problem for you rather than just an inconvenience, can you
step through your code and pinpoint where they are added to window?


Reply to this email directly or view it on GitHub
#148 (comment).

Ludilabel Ludilabel Restant à votre entière disposition.
Bien cordialement.

Franz BUDON
Tel. 05 34 66 11 23
ludilabel.fr http://www.ludilabel.fr/
Rejoignez nos 75 000 fans
sur Facebook : facebook.com/ludilabel.fr
https://www.facebook.com/ludilabel.fr

from knockback.

kmalakoff avatar kmalakoff commented on August 10, 2024

Thanks for looking into this.

If it is in webpack and actually doesn't do anything bad functionally, I would probably just let it slide. It might be a lot of work to fix it in webpack....

from knockback.

trockets avatar trockets commented on August 10, 2024

This is a knockback.js issue. Just ran into this and its a bit disappointing.

At line 3100 of knockback-core.js (version 1.1.0)

if (typeof window !== "undefined" && window !== null) {
	  ref = ['_', 'Backbone', 'Parse', 'ko', '$'];
	  for (i = 0, len = ref.length; i < len; i++) {
	    key = ref[i];
	    if (kb[key] && !Object.prototype.hasOwnProperty.call(window, key)) {
	      window[key] = kb[key];
	    }
	  }
	}

Here the knockback dependencies are actually all being added to the window. There is also a similar issue where amd/commonjs conventions are broken at line 821 (same file)

kb.$ = window.jQuery || window.$;

try {	 
  kb.$ || (kb.$ = __webpack_require__(7));
} catch (undefined) {}

Here kb.$ is pulling from the window first and then falling back to require. IMO it should be doing the require first. In my testing, I was finding that this can load an incorrect version of jQuery.

from knockback.

kmalakoff avatar kmalakoff commented on August 10, 2024

@ambiguousFoo there was a reason in some configuration. I think maybe jQuery and Parse were't playing nice with some loaders. Mind you, that was many years ago before module systems were common...

You can find the lines pulling dependencies from or putting dependencies on window here, here, and here.

I can try a build without any of the exposing...

from knockback.

kmalakoff avatar kmalakoff commented on August 10, 2024

Try the version in master and let me know if it works for you.

from knockback.

kmalakoff avatar kmalakoff commented on August 10, 2024

@ambiguousFoo and @franzludilabel. With 1.2.0, Knockback doesn't republish the internal symbols for underscore, Backbone, and Knockout (although Backbone will add itself inside its library to window, but I cannot do anything about that).

Also, references to jQuery have been removed from Knockback.

from knockback.

franzludilabel avatar franzludilabel commented on August 10, 2024

from knockback.

kmalakoff avatar kmalakoff commented on August 10, 2024

@franzludilabel thank you for the kind words and sharing a link to your work. Looks great!

from knockback.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.