Skip to content

Commit

Permalink
Ignore fastboot build output file if app unused/disable fastboot (#468)
Browse files Browse the repository at this point in the history
Ignore fastboot build output file if app unused/disable fastboot
  • Loading branch information
houfeng0923 authored Mar 28, 2020
1 parent 4df1bf0 commit 6d6e700
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ module.exports = {

// Only include public/fetch-fastboot.js if top level addon
treeForPublic() {
return !this.parent.parent ? this._super.treeForPublic.apply(this, arguments) : null;
const fastbootEnabled = process.env.FASTBOOT_DISABLED !== 'true'
&& !!this.project.findAddonByName('ember-cli-fastboot');
return !this.parent.parent && fastbootEnabled
? this._super.treeForPublic.apply(this, arguments) : null;
},

cacheKeyForTree(treeType) {
Expand Down
57 changes: 57 additions & 0 deletions test/without-fastboot-build-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';
const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-fs'));

const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;

describe('it builds without ember-cli-fastboot', function() {
this.timeout(300000);

let app;

beforeEach(function() {
app = new AddonTestApp();
});

it('builds no exist dist/ember-fetch/fetch-fastboot.js', function() {
return app
.create('dummy', { skipNpm: true })
.then((app) =>
app.editPackageJSON((pkg) => {
delete pkg.devDependencies['ember-cli-fastboot'];
})
)
.then(() => app.run('npm', 'install'))
.then(() => app.runEmberCommand('build'))
.then(function() {
expect(app.filePath('dist/index.html')).to.be.a.file();
expect(app.filePath('dist/ember-fetch')).to.not.be.a.path();
});
});

it('build with process.env.FASTBOOT_DISABLED', function() {
process.env.FASTBOOT_DISABLED = 'true';
return app
.create('dummy', { skipNpm: true })
.then((app) =>
app.editPackageJSON((pkg) => {
pkg.devDependencies['ember-cli-fastboot'] = '*';
})
)
.then(() => app.run('npm', 'install'))
.then(() => app.runEmberCommand('build'))
.then(function() {
expect(app.filePath('dist/index.html')).to.be.a.file();
expect(app.filePath('dist/ember-fetch')).to.not.be.a.path();
})
.then(
function() {
delete process.env.FASTBOOT_DISABLED;
},
function() {
delete process.env.FASTBOOT_DISABLED;
}
);
});
});

0 comments on commit 6d6e700

Please sign in to comment.