Giter VIP home page Giter VIP logo

Comments (8)

bendrucker avatar bendrucker commented on June 12, 2024

You'd have to supply that yourself since there isn't a way to make prebundle async. The ideal way to do it is to drop the Karma CLI entirely and compose a gulp task (karma-as-promised should be helpful there). Generate the external bundle there, perhaps even to a tmp folder, and then load it in your Karma files array.

from karma-browserify.

deitch avatar deitch commented on June 12, 2024

Ah, so multiple builds, each with its own set of files, is not really from within karma. Instead I would just do:

        files : [
          'test/unit/**/*Spec.js',
            'app/dist/vendor.js'
        ],
        preprocessors: {
            'test/unit/**/*Spec.js' : ['browserify']
        },

and build my app/dist/vendor.js (or whatever other path I want) as part of a separate gulp/grunt/npm task. Since it changes so infrequently, updating that one manually (without watchify) is not the end of the world... and gulp.watch could probably watch it for me anyways?

from karma-browserify.

bendrucker avatar bendrucker commented on June 12, 2024

It would be cool if Karma had an async interface for adding files, but unfortunately it doesn't. That essentially means that all the files need to exist before Karma runs. By the way, I use browserify-shim to use Angular as a window global with a plain old concatenated vendor file. Makes it a whole lot easier since you can just add your vendor files directly to the Karma files array.

from karma-browserify.

deitch avatar deitch commented on June 12, 2024

Yeah, I used to have my own "angular-cjs.js" and "jquery-cjs.js" files to shim, but now I use browserify-shim. Much easier.

I do like browserify, but in an angular world, you almost wish the two were merged, so it could read the angular modules and find the relevant files.

I will close this out. Thanks for the assistance.

from karma-browserify.

bendrucker avatar bendrucker commented on June 12, 2024

Well Angular modules don't actually specify file structure relations like CommonJS, nor are they intended to. Angular's modules are design for dependency injection and have no opinion about how they load them. That said, I'm with you that it's a mess. Angular is supposed to ship with CommonJS support on npm in 1.3. Then there will be a transition process where everyone who wrote their modules to expect window.angular has to go fix them. I generally find the average quality of popular (50+ stars) Angular modules to be extremely low. The best way to prepare is to write everything with browserify-shim. Then it's a one line fix to your package when Angular can be required.

from karma-browserify.

deitch avatar deitch commented on June 12, 2024

I haven't delved too deeply into most of the modules, but I have seen a lot of junk.

Yeah, I like the cleanliness of it. The less I have to do inside individual files for maintenance, the better.

Is it supposed to finally ship with npm support? I would very much like to do npm install angular and be done with it. Then I can require('angular') or maybe require('angular/angular-resource') natively.

from karma-browserify.

bendrucker avatar bendrucker commented on June 12, 2024

Yes: angular/angular.js#2877

You +1'd it 3 days ago! 😄

Slated for rc5 which I'm guessing will land in 2 weeks.

from karma-browserify.

deitch avatar deitch commented on June 12, 2024

I know I +1'd it... but I didn't realize they had agreed.

Oh, now I see the "added to 1.3.0 milestone". That will be nice.

from karma-browserify.

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.