Skip to content

Commit 42dee47

Browse files
authored
Merge pull request #374 from kratiahuja/add-fastboot-assets-api
Expose API for fastboot addons to update fastboot manifest.
2 parents cb87f92 + 0b992fc commit 42dee47

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ module.exports = {
177177
// forward the request to the next middleware (example other assets, proxy etc)
178178
next();
179179
}
180-
})
180+
});
181181
}
182182
},
183183

lib/broccoli/fastboot-config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ FastBootConfig.prototype.readAssetManifest = function() {
115115
}
116116
};
117117

118+
FastBootConfig.prototype.updateFastBootManifest = function(manifest) {
119+
this.project.addons.forEach(function(addon) {
120+
if (addon.updateFastBootManifest) {
121+
manifest = addon.updateFastBootManifest(manifest);
122+
123+
if (!manifest) {
124+
throw new Error(`${addon.name} did not return the updated manifest from updateFastBootManifest hook.`);
125+
}
126+
}
127+
});
128+
129+
return manifest;
130+
}
131+
118132
FastBootConfig.prototype.buildManifest = function() {
119133
var appFileName = path.basename(this.outputPaths.app.js).split('.')[0];
120134
var appFile = 'fastboot/' + appFileName + '.js';
@@ -127,6 +141,8 @@ FastBootConfig.prototype.buildManifest = function() {
127141
htmlFile: this.htmlFile
128142
};
129143

144+
manifest = this.updateFastBootManifest(manifest);
145+
130146
var rewrittenAssets = this.readAssetManifest();
131147

132148
if (rewrittenAssets) {

test/package-json-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ describe('generating package.json', function() {
6464
var pkg = fs.readJsonSync(app.filePath('/dist/package.json'));
6565

6666
expect(pkg.fastboot.manifest).to.deep.equal({
67-
appFiles: ['fastboot/module-whitelist.js'],
67+
appFiles: ['fastboot/module-whitelist.js', 'ember-fastboot-build-example/bar.js'],
6868
htmlFile: 'index.html',
69-
vendorFiles: ['fastboot/vendor.js']
69+
vendorFiles: ['ember-fastboot-build-example/foo.js', 'fastboot/vendor.js']
7070
});
7171
});
7272

@@ -221,7 +221,8 @@ function addFastBootDeps(app) {
221221
pkg['devDependencies']['fake-addon-2'] = "*";
222222
pkg['fastbootDependencies'] = ["rsvp"];
223223
pkg['dependencies'] = {
224-
rsvp: "3.2.1"
224+
rsvp: "3.2.1",
225+
"ember-fastboot-build-example": "0.1.1"
225226
};
226227
});
227228
}

0 commit comments

Comments
 (0)