Skip to content

Commit 1819afe

Browse files
committed
build: Update the broccoli scripts to 1.0
1 parent cae1370 commit 1819afe

File tree

8 files changed

+448
-541
lines changed

8 files changed

+448
-541
lines changed

addon/ng2/blueprints/ng2/files/ember-cli-build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ module.exports = function(defaults) {
77
vendorNpmFiles: []
88
});
99
return app.toTree();
10-
}
10+
};

addon/ng2/blueprints/ng2/files/src/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818

1919
"files": [
20-
"app/main.ts",
20+
"app.ts",
2121
"typings.d.ts"
2222
]
2323
}

lib/broccoli/angular2-app.js

+20-34
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ var Project = require('ember-cli/lib/models/project');
1010

1111
module.exports = Angular2App;
1212

13-
function Angular2App(defaults, options, additionalPaths) {
13+
function Angular2App(defaults, options) {
1414
this._initProject();
1515
this._notifyAddonIncluded();
1616
this.options = options;
17-
this.additionalPaths = additionalPaths || [];
1817
}
1918

2019
Angular2App.prototype.toTree = function() {
2120
var sourceDir = 'src';
2221

2322
var sourceTree = new Funnel('src', {
23+
include: ['*.ts', '**/*.ts', '**/*.d.ts'],
2424
destDir: 'src'
2525
});
2626

@@ -41,33 +41,31 @@ Angular2App.prototype.toTree = function() {
4141
'angular2/bundles/upgrade.dev.js'
4242
];
4343

44-
45-
4644
if (this.options && this.options.vendorNpmFiles) {
4745
vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles);
4846
}
4947

5048
var tsconfig = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8'));
51-
var tsConfigCompilerOptions = tsconfig.compilerOptions;
52-
53-
54-
// TODO(i): why do we need these additional paths? remove?
55-
tsConfigCompilerOptions.rootFilePaths = this.additionalPaths.map(function(name) {
56-
return path.join(process.cwd(), sourceDir, name)
57-
});
58-
59-
// TODO(i): kill rootFilePaths in broccoli-typescript and use tsconfig.json#files instead
60-
tsConfigCompilerOptions.rootFilePaths = tsConfigCompilerOptions.rootFilePaths.
61-
concat(tsconfig.files.map(function(p) {
62-
// TODO(i): this is a hack - for some reason we need to prefix all paths with srcDir because
63-
// tsc's "rootDir" doesn't take effect when resolving "files" paths
64-
return path.join(sourceDir, p);
65-
}));
49+
// Add all spec files to files. We need this because spec files are their own entry
50+
// point.
51+
fs.readdirSync(sourceDir).forEach(function addPathRecursive(name) {
52+
const filePath = path.join(sourceDir, name);
53+
if (filePath.match(/\.spec\.[jt]s$/)) {
54+
tsconfig.files.push(name);
55+
} else if (fs.statSync(filePath).isDirectory()) {
56+
// Recursively call this function with the full sub-path.
57+
fs.readdirSync(filePath).forEach(function(n) {
58+
addPathRecursive(path.join(name, n));
59+
});
60+
}
61+
});
6662

63+
// Because the tsconfig does not include the source directory, add this as the first path
64+
// element.
65+
tsconfig.files = tsconfig.files.map(name => path.join(sourceDir, name));
6766

6867
var srcAndTypingsTree = mergeTrees([sourceTree, typingsTree]);
69-
70-
var tsTree = compileWithTypescript(srcAndTypingsTree, tsConfigCompilerOptions);
68+
var tsTree = new compileWithTypescript(srcAndTypingsTree, tsconfig);
7169

7270
tsTree = new Funnel(tsTree, {
7371
srcDir: 'src',
@@ -95,28 +93,16 @@ Angular2App.prototype.toTree = function() {
9593
destDir: 'vendor'
9694
});
9795

98-
var thirdPartyJsTree = new Funnel('node_modules', {
99-
include: ['ng2*/bundles/*.js'],
100-
exclude: ['ng2*/bundles/*.min.js', 'ng2*/bundles/*.standalone.js'],
101-
});
102-
103-
var thirdPartyJs = new Concat(thirdPartyJsTree, {
104-
inputFiles: ['**/*.js'],
105-
outputFile: '/thirdparty/libs.js',
106-
allowNone: true
107-
});
108-
10996
var merged = mergeTrees([
11097
assetTree,
11198
tsSrcTree,
11299
tsTree,
113100
jsTree,
114101
this.index(),
115102
vendorNpmTree,
116-
thirdPartyJs
117103
], { overwrite: true });
118104

119-
return mergeTrees([merged, new SwManifest(merged)]);
105+
return mergeTrees([merged, new SwManifest([merged])]);
120106
};
121107

122108
/**

0 commit comments

Comments
 (0)