computmaxer / karma-jspm

Other
74 stars 50 forks source link

CP-837 Fix to honor the "useBundles" jspm Karma configuration option #81

Closed frayer closed 9 years ago

frayer commented 9 years ago

In my karma.conf.js file I was using the jspm { useBundles: false } configuration as shown below. It wasn't honoring that setting and was trying to load my bundles even if I set it to false. My change is to move where the exclusion of the SystemJS bundles is performed, and changes how we do it.

In the 0.18.x versions of SystemJS, they only add or update to existing bundle configuration with the System.config method. See core.js. You can't set it back to an empty map with System.config.

karma-jspm is loading in my "./config.js" file which has bundles defined in it and then it's being configured and can't be removed with the System.config call. I'm open to alternative implementations, but this one is working for me locally.

I can produce a small sample project to show the issue if that helps.

module.exports = function(config) {
  config.set({
    ...
    ...
    jspm: {
        useBundles: false
    }
    ...
    ...
  })
}
maxwellpeterson-wf commented 9 years ago

It looks like this will be addressed by the merging of #84. Does that seem right or am I missing something?

frayer commented 9 years ago

This is still an issue for me, but lets make sure we're on the same version of JSPM first because that might be the difference. Just today I put together an example (https://github.com/frayer/karma-jspm-useBundle-defect) showing the issue, and I used JSPM version 0.16.0-beta.7. This runs against the 0.18.x versions of SystemJS.

What version of JSPM/SystemJS is karma-jspm@2.0.1-beta.2 designed to be functional against?

If you look at how SystemJS implements the System.config method now, you'll see that they allow you to add or modify entries to the bundles configuration, but you can't delete bundles completely or set it back to an empty array or map with the System.config method. In adapter.js of this project, the following is System.config call is invoked, however it doesn't actually delete bundles that may have previously been configured due to the way it's implemented in SystemJS 0.18.x now.

System.config({
    bundles: []
});

In my scenario, I have bundles defined in my JSPM config.js file. However I don't want them used at all during testing. I just want to pull in the original unbundled sources.

The fix working for me is to override the underlying System.bundles property with an empty map like so:

if(!karma.config.jspm.useBundles){
    System.bundles = {}
}

Please try out the project I put together which shows this happening. Please let me know though if I'm missing something.

https://github.com/frayer/karma-jspm-useBundle-defect

maxwellpeterson-wf commented 9 years ago

Ok, I see. I've reopened this PR but you will have to fix the merge conflicts that have occurred because of #84.

frayer commented 9 years ago

Thanks for reopening. I'll take care of the merge conflicts and let you know.

frayer commented 9 years ago

I rebased to your master. Take a look and let me know if you see any issues.

maxwellpeterson-wf commented 9 years ago

+1 @trentgrover-wf @evanweible-wf

evanweible-wf commented 9 years ago

+1

maxwellpeterson-wf commented 9 years ago

@jayudey-wf ready for merge

jayudey-wf commented 9 years ago

QA Resource Approval: +10

Merging into master.