nikku / karma-browserify

A fast Browserify integration for Karma that handles large projects with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pipe preprocessors

ouhouhsami opened this issue · comments

Hello,

I tried karma-bro and it occurs that if I use

preprocessors: {
        'src/index.js': ['other-preprocessor', 'browserify']
    }

the file returned by browserify preprocessor is not the one processed by other-preprocessor but the original file src/index.js browserified.

Have you ever had this use case? (in my case, 'other-preprocessor' is a es6-transpiler).

Cheers,

You'll need to use a browserify transform rather than a preprocessor

https://github.com/thlorenz/es6ify

Ok Ben, thanks for you answer.
But could you explain me why browserify preprocessor don't work as a pipe? (it's also the case with other karma browserify preprocessors)
Also, the link you gave me use traceur, and I use es6-transpiler. Anyway, I'll take a close look at this.

Cheers

Seems like es6-browserify should work fine.

Preprocessors can normally be chained but the way karma-bro works is a bit of a hack. It has to insert a bundle file as a framework, but Karma does not give frameworks the ability to perform async operations. So instead it needs to insert a shim file that later is added to the karma files array and later receives the bundled code. It also reads the files directly versus grabbing Karma's representation of them.

This will hold, by the way, for anything you want to change with your code. Once you're using Browserify, you need to use transforms. If you wanted to use Istanbul, for example, you'd use a transform and not a preprocessor.