Coder Social home page Coder Social logo

Backbone shim about cajon HOT 4 CLOSED

requirejs avatar requirejs commented on July 19, 2024
Backbone shim

from cajon.

Comments (4)

jrburke avatar jrburke commented on July 19, 2024

cajon detects usage of node module APIs (like require/exports) and if detected, wraps the content in a define() function wrapper, then evals it. Since backbone tries to call node APIs if in node, cajon detects the API usage and wraps in a define() function wrapper.

This changes the scope and "this" value when Backbone executes. Since backbone does not try to use the node APIs to fetch jquery (instead tries to grab it off "this"/global, which is goofy in some respects), it fails.

What I can look at doing is to avoid doing the define() wrapping if there is a shim config set up for the file. I need to set up a backbone test to confirm the fix though. Will try to sort it out soon.

from cajon.

grydstedt avatar grydstedt commented on July 19, 2024

Ah, gotcha. Is the temp workaround to change the root.jQuery to a requjre('jquery') in backbone? I'll try it out

On Mar 20, 2013, at 7:08 PM, James Burke [email protected] wrote:

cajon detects usage of node module APIs (like require/exports) and if detected, wraps the content in a define() function wrapper, then evals it. Since backbone tries to call node APIs if in node, cajon detects the API usage and wraps in a define() function wrapper.

This changes the scope and "this" value when Backbone executes. Since backbone does not try to use the node APIs to fetch jquery (instead tries to grab it off "this"/global, which is goofy in some respects), it fails.

What I can look at doing is to avoid doing the define() wrapping if there is a shim config set up for the file. I need to set up a backbone test to confirm the fix though. Will try to sort it out soon.


Reply to this email directly or view it on GitHub.

from cajon.

jrburke avatar jrburke commented on July 19, 2024

Another option is to use the amdified version of backbone from https://github.com/amdjs/backbone, but understand if you do not want to take fork like that.

from cajon.

jrburke avatar jrburke commented on July 19, 2024

This is now fixed in the just-releases cajon 0.1.4. However, a change was also needed in the optimizer, to not do the cjsTranslate wrapping, tracked in requirejs/r.js#408. That fix will go out in r.js 2.1.6, which may be another week or so away. In the meantime, you can use the latest master snapshot if you want to do builds that work with this setup.

This is also a demo-shim directory in this repo that I used to confirm the changes.

from cajon.

Related Issues (15)

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.