Skip to content

Commit 0d16d31

Browse files
committed
idk, what happened, but something is funky now. Nested dependencies are a huge inconvience like this, and should be resolved automatically
1 parent 2657eb2 commit 0d16d31

File tree

6 files changed

+66
-8
lines changed

6 files changed

+66
-8
lines changed

angular-cli-build.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ module.exports = function(defaults) {
1515
'es6-shim/es6-shim.js',
1616
'reflect-metadata/**/*.+(ts|js|js.map)',
1717
'rxjs/**/*.+(js|js.map)',
18-
'@angular/**/*.+(js|js.map)'
19-
]
18+
'@angular/**/*.+(js|js.map)',
19+
20+
// for testing...
21+
'xhr-interceptor/**/*.js',
22+
'methods/**/*.js',
23+
'http-browserify/**/*.js',
24+
'path-to-regexp/**/*.js',
25+
],
2026
});
2127
};

config/karma.conf.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
module.exports = function (config) {
55
config.set({
66
basePath: '..',
7-
frameworks: ['jasmine'],
7+
frameworks: ['jasmine', 'commonjs'],
88
plugins: [
99
require('karma-jasmine'),
10-
require('karma-chrome-launcher')
10+
require('karma-chrome-launcher'),
11+
require('karma-commonjs'),
1112
],
1213
customLaunchers: {
1314
// chrome setup for travis CI using chromium
@@ -24,7 +25,11 @@ module.exports = function (config) {
2425
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
2526
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
2627
{ pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false },
27-
28+
{ pattern: 'dist/vendor/xhr-interceptor/**/*', served: true, watched: false },
29+
{ pattern: 'dist/vendor/methods/**/*', served: true, watched: false },
30+
'dist/vendor/methods/index.js',
31+
'dist/vendor/http-browserify/index.js',
32+
'dist/vendor/path-to-regexp/index.js',
2833
{ pattern: 'config/karma-test-shim.js', included: true, watched: true },
2934

3035
// Distribution folder.
@@ -34,7 +39,11 @@ module.exports = function (config) {
3439
// Vendor packages might include spec files. We don't want to use those.
3540
'dist/vendor/**/*.spec.js'
3641
],
37-
preprocessors: {},
42+
preprocessors: {
43+
'dist/vendor/http-browserify/**/*.js': ['commonjs'],
44+
'dist/vendor/methods/**/*.js': ['commonjs'],
45+
'dist/vendor/xhr-interceptor/**/*.js': ['commonjs'],
46+
},
3847
reporters: ['progress'],
3948
port: 9876,
4049
colors: true,

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
"jasmine-spec-reporter": "2.5.0",
3535
"karma": "0.13.22",
3636
"karma-chrome-launcher": "0.2.3",
37+
"karma-commonjs": "^1.0.0",
3738
"karma-jasmine": "0.3.8",
39+
"object-assign": "^4.1.0",
40+
"path-to-regexp": "^1.5.3",
3841
"protractor": "3.3.0",
3942
"ts-node": "0.5.5",
4043
"tslint": "3.11.0",
4144
"typescript": "1.8.10",
42-
"typings": "0.8.1"
45+
"typings": "0.8.1",
46+
"xhr-interceptor": "^1.3.0"
4347
}
4448
}

src/app/app.component.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ import {
88
} from '@angular/core/testing';
99
import { AppComponent } from './app.component';
1010

11+
import { Interceptor } from 'xhrinterceptor';
12+
1113
beforeEachProviders(() => [AppComponent]);
1214

1315
describe('App: AngularCli3rdpartyNestedDependencyIssue', () => {
16+
let interceptor;
17+
18+
beforeEach(() => {
19+
interceptor = new Interceptor;
20+
});
21+
1422
it('should create the app',
1523
inject([AppComponent], (app: AppComponent) => {
1624
expect(app).toBeTruthy();

src/system-config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,36 @@
77
**********************************************************************************************/
88
/** Map relative paths to URLs. */
99
const map: any = {
10+
// for testing
11+
'xhrinterceptor': 'vendor/xhr-interceptor',
12+
'methods': 'vendor/methods',
13+
'http': 'vendor/http-browserify',
14+
'path-to-regexp': 'vendor/path-to-regexp',
1015
};
1116

1217
/** User packages configuration. */
1318
const packages: any = {
19+
'xhrinterceptor': {
20+
format: 'cjs',
21+
defaultExtension: 'js',
22+
main: 'index.js'
23+
},
24+
'methods': {
25+
format: 'cjs',
26+
defaultExtension: 'js',
27+
main: 'index.js'
28+
},
29+
'http': {
30+
format: 'cjs',
31+
defaultExtension: 'js',
32+
main: 'index.js'
33+
},
34+
'path-to-regexp': {
35+
format: 'cjs',
36+
defaultExtension: 'js',
37+
main: 'index.js'
38+
},
39+
1440
};
1541

1642
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -49,7 +75,8 @@ System.config({
4975
map: {
5076
'@angular': 'vendor/@angular',
5177
'rxjs': 'vendor/rxjs',
52-
'main': 'main.js'
78+
'main': 'main.js',
79+
'xhrinterceptor': 'vendor/xhr-interceptor'
5380
},
5481
packages: cliSystemConfigPackages
5582
});

src/typings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55
/// <reference path="../typings/browser.d.ts" />
66
declare var module: { id: string };
7+
declare module 'xhrinterceptor' {
8+
export class Interceptor{
9+
}
10+
}

0 commit comments

Comments
 (0)