Skip to content

Commit 9b38984

Browse files
committed
fix: use generic output file names
Previously, the CLI produced bundled files that were named after their package, i.e. denali-auth.fragment.js or my-cool-app.bundle.js. This introduced a problem, however, for projects with scoped package names, i.e. @denali-js/babel. Broccoli would write the resulting fragment file into the literal `@denali-js/` folder. This was primarily done to avoid problems when Broccoli tried to merge all the various addon fragments prior to the source map concat - they'data all be named the same thing, and thus overwrite each other. This change converts the compiled output to use generic filenames, i.e. `addon.fragment.js`. To avoid the overwriting problem, we put them into folders based on their package name during the build, before merging them together. The fact the concat step uses a recursive glob pattern allows us to do this without having to know what those folder names are at the concat step.
1 parent 0e8fe4d commit 9b38984

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

lib/builders/addon.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default class AddonBuilder extends BaseBuilder {
122122
header: bundleFragmentOpen(data),
123123
footer: bundleFragmentClose,
124124
wrapAsModules: true,
125-
outputFile: `${ this.pkg.name }.fragment.js`,
125+
outputFile: `addon.fragment.js`,
126126
baseDir: this.dir
127127
});
128128
return tree;

lib/builders/app.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const bundleClose = fs.readFileSync(path.join(__dirname, '..', 'templates', 'bun
1212

1313
export default class AppBuilder extends BaseBuilder {
1414

15+
bundleName = 'app';
16+
1517
shouldBuildDocs() {
1618
if (this.options.docs != undefined) {
1719
return this.options.docs;
@@ -28,17 +30,18 @@ export default class AppBuilder extends BaseBuilder {
2830
let addonBundles = this.addons.map((addon) => {
2931
this.debug(`including ${ addon.pkg.name } fragment in app bundle`);
3032
return new Funnel(addon.toTree(), {
31-
include: [
32-
`*fragment.js`,
33-
`*fragment.map`
33+
destDir: addon.pkg.name,
34+
files: [
35+
`addon.fragment.js`,
36+
`addon.fragment.map`
3437
]
3538
});
3639
});
3740
tree = new MergeTree(addonBundles.concat(tree), { annotation: 'merge app and addon runtimes' });
3841
tree = new Concat(tree, {
3942
header: bundleOpen({ pkgName: this.pkg.name, version: this.pkg.version }),
4043
footer: bundleClose,
41-
outputFile: `${ this.pkg.name }.bundle.js`
44+
outputFile: `${ this.bundleName }.bundle.js`
4245
});
4346
return tree;
4447
}

lib/builders/dummy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as Funnel from 'broccoli-funnel';
1010
export default class DummyBuilder extends AppBuilder {
1111

1212
packageFiles = [ 'package.json' ];
13+
bundleName = 'dummy';
1314

1415
addonBuilderUnderTest: AddonBuilder;
1516

0 commit comments

Comments
 (0)