Coder Social home page Coder Social logo

Comments (6)

rniemeyer avatar rniemeyer commented on July 28, 2024

You would want to take a look at the include option in the build file. It can help you add specific dependencies to be optimized.

from knockout-amd-helpers.

nmehlei avatar nmehlei commented on July 28, 2024

I tried that, and it was successfully included in the packaged file, but nevertheless your plugin downloaded it again ;) My guess would be somehow different paths or something like that, but I couldn't see from the library source how exactly the path has to be to be identical. Could that be the reason?

from knockout-amd-helpers.

rniemeyer avatar rniemeyer commented on July 28, 2024

@nmehlei could be. Can you post some details about your build file and structure? I committed an optimized build of the little example in this repository.

One thing that could be happening to you is that your ko.applyBindings call could be happening before your templates are defined in the optimized output. As a test, you can try calling ko.applyBindings in a setTimeout 0. When I optimized the example, I noticed that this was happening at first to my top-level templates.

from knockout-amd-helpers.

anacronw avatar anacronw commented on July 28, 2024

Thanks, that worked for me and it did not redownload the file.

It doesn't seem, however, that there's a way to automatically include all the template files. I see in the example that each template file is explicitly set. I see why, however, since the dependency is a dynamic require call - there's no way for the optimizer to really know beforehand.

from knockout-amd-helpers.

nmehlei avatar nmehlei commented on July 28, 2024

Sorry @rniemeyer, forgot to answer, but everything worked fine after I corrected the paths in the build file for r.js (in my case 'text!../../Content/Templates/bla..', the ../ were necessary and I didn't see that at first).
@Badunk you're right, there is no wildcard support. but I think you could use the power of nodejs to include a small script in your r.js build file that traverses your directories, builds a list and uses that...I think I read that somewhere.

from knockout-amd-helpers.

rniemeyer avatar rniemeyer commented on July 28, 2024

@Badunk @nmehlei - as far as dynamic dependencies, you can take a look at this article that I wrote that describes a grunt task to help. Should be possible to write something for other build systems as well.

from knockout-amd-helpers.

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.