@@ -7,6 +7,19 @@ var fs = require('fs-extra');
7
7
8
8
var DEFAULT_SUPPORTED_TYPES = [ 'js' , 'css' ] ;
9
9
10
+ /**
11
+ * Adds a bundle if it doesn't already exist
12
+ *
13
+ * @name addBundleToManifest
14
+ * @param {Object } manifest The existing manifest object
15
+ * @param {string } bundleName The bundle to add
16
+ */
17
+ function addBundleToManifest ( manifest , bundleName ) {
18
+ manifest . bundles [ bundleName ] = manifest . bundles [ bundleName ] || {
19
+ assets : [ ]
20
+ } ;
21
+ }
22
+
10
23
/**
11
24
* A Broccoli plugin to generate an asset manifest from a given input tree.
12
25
* You can also provide a second tree that is a tree containing an existing
@@ -83,19 +96,10 @@ AssetManifestGenerator.prototype.build = function() {
83
96
return manifest ;
84
97
}
85
98
86
- if ( bundleInfo . isNewBundle ) {
87
- if ( manifest . bundles [ bundleName ] ) {
88
- throw new Error ( 'Attempting to add bundle "' + bundleName + '" to manifest but a bundle with that name already exists.' ) ;
89
- }
90
-
91
- manifest . bundles [ bundleName ] = {
92
- assets : [ ]
93
- } ;
94
- }
95
-
96
99
// If the asset is named "dependencies.manifest.json" then we should read
97
100
// the json in and set it as "dependencies" on the corresponding bundle.
98
101
else if ( assetName === 'dependencies.manifest.json' ) {
102
+ addBundleToManifest ( manifest , bundleName ) ;
99
103
var dependencies = fs . readJsonSync ( path . join ( inputPath , entry ) ) ;
100
104
manifest . bundles [ bundleName ] . dependencies = dependencies ;
101
105
}
@@ -109,6 +113,7 @@ AssetManifestGenerator.prototype.build = function() {
109
113
let contents = fs . readFileSync ( fullPath , 'utf-8' ) ;
110
114
111
115
if ( contents . trim ( ) !== '' ) {
116
+ addBundleToManifest ( manifest , bundleName ) ;
112
117
manifest . bundles [ bundleName ] . assets . push ( {
113
118
uri : generateURI ( path . posix . join ( prepend , entry ) ) ,
114
119
type : assetType
0 commit comments