vendredi 24 juin 2016

Add files to watch-list in karma preprocessor

I'm trying to get karma-rollup-preprocessor working with watch i.e. solve showpad/karma-rollup-preprocessor#3

In simple terms, Rollup returns a list of files that it reads (and one would ordinarily want to watch), so in the preprocessor I am trying to add files to the list karma watches. Basically I want to add this (or the working equivalent) to the preprocessor:

bundle.modules.forEach((module) => {
    files.unshift({
        pattern: module.id,  /* The full file path, from Rollup */
        watched: true,
        included: false,
        nocache: false,
        served: false,
    })
})

Where files is Karma's config.files.

The files are indeed being added to the watcher, but .on(fileList.changeFile) fails the _isIncluded. So it looks like the files also (or alternatively) must be added to the fileList.

Unfortunately when I try to add the fileList to the $inject, I get the error:

Error: Can not resolve circular dependency! (Resolving: preprocess -> preprocessor:rollup -> fileList -> preprocess).

I've looked at basically all the other preprocessors that look like they could also add includes, but I have found no indication of how to do it.

Is there a canonical way to add files Karma should watch from a preprocessor? Or otherwise how might one do this?

Aucun commentaire:

Enregistrer un commentaire