-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): Add preprocessorOrder
option to config for when prepr…
#1899
Conversation
@@ -355,7 +355,7 @@ | |||
"engines": { | |||
"node": "0.10 || 0.12 || 4 || 5" | |||
}, | |||
"version": "0.13.21", | |||
"version": "0.13.22", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this, version bumps are generated automatically on release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The problem now is that I'll have nothing to reference in the browserify change
I'd like to put a different solution for this on the table: Allow Example JSON: {
"preprocessors": [
[ ".js", "googmodule" ],
[ ".js", "coverage" ]
]
} @sjelin Could you provide us with an example project + karma configuration that fails with the current version of karma? |
@nikku we were having problems with a config file like: "preprocessors": {
"**/*.js": [ "googmodule" ],
"**/client/**/*.js": [ "coverage" ]
}, Which caused The problem with the |
11b6e5b
to
1730273
Compare
@nikku have you tried doing sth like this: "preprocessors": {
"!(client)/**/*.js": [ "googmodule" ],
"client/**/*.js": ["googmodule", "coverage" ]
}, You would need to explicitly define the top level path, but you wouldn't need to add any code to karma to get this working. |
Yes, that would probably work in this instance. But users may have a more complicated group of files they need coverage data for. For instance: "preprocessors": {
"a/**/*.js": ["googmodule", "coverage" ],
"**/b/*.js": ["googmodule", "coverage" ],
"c*d/*.js": ["googmodule", "coverage" ],
"<else *.js>": [ "googmodule" ]
}, In this case I have no idea what pattern goes in the Plus, while it's good that it requires no karma code change, it feels like a hack. I want |
@@ -36,7 +36,7 @@ var createNextProcessor = function (preprocessors, file, done) { | |||
} | |||
} | |||
|
|||
var createPreprocessor = function (config, basePath, injector) { | |||
var createPreprocessor = function (config, basePath, ppOrder, injector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this? I'd rather not risk breaking other preprocessors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. We could use a custom property of config
like !!preprocessorOrder
which would never be needed to match a real file. I'm also open to any other ideas.
@sjelin Ok, how does the following (switched order of preprocessor definitions) behave then?
|
I mean, that works (sometimes at least), but it's not supposed to work. It relies on |
@sjelin what happens if you do: "preprocessors": {
"**/*.js": [ "googmodule" ],
"**/client/**/*.js": ["googmodule", "coverage" ]
}, |
I think you mean: "preprocessors": {
"**/*.js": [ "googmodule" ],
"**/client/**/*.js": ["coverage", "googmodule"]
}, since Currently there is no de-duplication in |
Yes that's what I meant. I think it would be a very good solution to introduce deduping here and use that order as it would be much more explicit and would solve the more complex use case where you want different orders of the same preprocessors in different files. As long as we properly document this it wouldn't be a hidden feature. |
Ok, I'm good with that. |
+1 if you get that properly explained to people, too. |
thanks sammy fix travis :) |
1730273
to
ab46284
Compare
Ok, I wrote it the other way. I know what you're going to say: "Why is it so complicated?" It turns out merging arrays, trying to keep their orders in tact as much as possible, isn't easy. I'm more than open to similar solutions. |
c8ed95f
to
a99e897
Compare
* header comment above | ||
* | ||
* For those who care, this is very slow, and taking | ||
* O(list2.length*list2.length*(list1.length + list2.length)) time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 who would have guessed we find some big O notation in here one day
/* Merge two lists, removing duplicates, and doing everything possible to | ||
* maintain the order of the two lists. | ||
* | ||
* This function guarantees that the order of list1 is preserved (that is, if x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: Please use //
for comments to be consistent with the rest of the code
@sjelin nice work, didn't expect this to get that complicated though :D I left some style nitpicks but other than that I'm pretty happy with this solution |
Also the commit message needs to mention that this is a breaking change, as it might change the order of preprocessors for some expecting the old behaviour. |
faeee46
to
5de42cb
Compare
All comments addressed! Though tbh once I split the list merging into its own repo (https://github.com/sjelin/combine-lists), most of the comments were no longer relevant. |
Thanks, nearly there, looks like linting is unhappy now. ( |
…, intelligently merge the list of preprocessors, deduping and trying to preserve the order This could be a breaking change, some users might rely on the old order, or on some preprocessors being run multiple times
5de42cb
to
59642a6
Compare
Fixed the lint problems. Looks like some of the e2e tests are failing. Are they flaky though? It seems pretty random |
@sjelin restarted them, yes they are super flaky atm sometimes travis gets so slow they time out :( |
feat(config): Add `preprocessorOrder` option to config for when prepr…
Thanks |
…ocessors
must be run in a specific order.
Some karma users at Google discovered karma-coverage needs to be run before
karma-googmodule-preprocessor, hence we need this feature.
This required an update to
karma-browserify
, which can be found here: nikku/karma-browserify#168.Since this version is not yet released, this will break travis.