cujojs / wire

A light, fast, flexible Javascript IOC container
Other
861 stars 68 forks source link

Allow import of a context-spec into another. #162

Closed ouadi closed 10 years ago

ouadi commented 10 years ago

Hello Dears,

I'm working on adding a new feature that alllows import of a context-spec into another.

The idea is inspired from the feature provided by Spring where a context would import the content of another context using the <import /> element.

My goal is to add support of the following declaration in wire-spec

var spec = {
    $import: 'another/wire/spec';
};

Or:

var spec = {
    $import: [
        'another/wire/spec-1',
        'another/wire/spec-2',
        ...
        'another/wire/spec-n'];
};

The content of wire-specs declared with the new keyword $import will be inlined with the importing wire-spec.

To do so, I have forked cujojs/wire repository then clone it. The npm install has been executed with success. However, npm test has failed with the following message.

$ npm test

> wire@0.10.7 test /.../cujojs-wire
> buster-test -e node

Error: lib/loader/id resolve should generate normalized ids
  TypeError: Object referee.assert() has no method 'claim'
    TypeError: Object referee.assert() has no method 'claim'
          at Object.buster.testCase.resolve.should generate normalized ids (/.../cujojs-wire/test/node/lib/loader/moduleId-test.js:50:12)
          at asyncFunction (/.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:224:19)
          at callTestFn (/.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:334:27)
          at /.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:37:23
          at /.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:37:23
          at Object.then (/.../cujojs-wire/node_modules/buster/node_modules/when/when.js:207:55)
          at Object.bane.createEventEmitter.runTest (/.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:629:26)
          at Object.<anonymous> (/.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:597:29)
          at bound (/.../cujojs-wire/node_modules/buster/node_modules/lodash/dist/lodash.js:483:19)
          at /.../cujojs-wire/node_modules/buster/node_modules/buster-test/lib/test-runner.js:182:29

Repeated exceptions:
  should generate normalized ids
  should normalize plugin ids
  should return base when id is falsy or .
  should return id when id is not relative
  should return base when id is only leading dots
  should return empty string for falsy
  should return base id
  should call parent loader with normalized ids

  TypeError: Object referee.assert() has no method 'claim'
    TypeError: Object referee.assert() has no method 'claim'
250 tests, 374 assertions, 1 runtime ... 8 errors
npm ERR! weird error 1
npm ERR! not ok code 0
$ 

What I'm missing?

Cheers

Younes

briancavalier commented 10 years ago

Hey @ouadi, it seems like something changed in one of the devDependencies that we use for testing. It appears to be either gent or buster or perhaps something about the integration between those two. I'll look into it ASAP and let you know what I find. Thanks for reporting the problem!

As for the $import feature, I'll think about where might be the best place to implement it. Due to the way wire works, the imports will have to be gathered and mixed into the spec very early, likely before any real wiring starts, and definitely before any plugins are allowed to execute.

ouadi commented 10 years ago

Hi @briancavalier ,

I have already implemented and tested the $imports feature. I will initiate a PR for validation and, eventualy, integration in the main stream.

Warm regards

Younes

briancavalier commented 10 years ago

Wow, that's great @ouadi! I just merged #163 which should fix the testing issue. Pull latest master and let me know if it works for you.

ouadi commented 10 years ago

Perfect @briancavalier. All tests complete with success including.

I have submitted a PR (see #164 ). Did you see it?

briancavalier commented 10 years ago

Thanks for confirming, @ouadi. Yeah, I saw #164, but I haven't had time to look at it. I should have time this weekend to dig into it.

Let's close this issue and we can use #164 for discussion.