Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update addon for FastBoot 1.0 #90

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* eslint-env node */
'use strict';

const path = require('path');
const Funnel = require('broccoli-funnel');
const Merge = require('broccoli-merge-trees');
const fastbootTransform = require('fastboot-transform');
const existsSync = require('exists-sync');

let FONT_FILES = [
'Roboto-Thin.woff2',
'Roboto-Thin.woff',
Expand Down Expand Up @@ -39,13 +45,33 @@ module.exports = {
});
}

if (!process.env.EMBER_CLI_FASTBOOT && !(app.options['materialize-shim'] || {}).omitJS) {
app.import(`${app.bowerDirectory }/materialize/dist/js/materialize.js`);
if (!(app.options['materialize-shim'] || {}).omitJS) {
app.import('vendor/materialize/materialize.js');
app.import('vendor/materialize-shim.js', {
exports: {
materialize: ['default']
}
});
}
},

treeForVendor(tree) {
let trees = [];

if (tree) {
trees.push(tree);
}

let materializePath = path.join(this.project.root, this.app.bowerDirectory, 'materialize', 'dist', 'js');
if (existsSync(materializePath)) {
let materializeTree = fastbootTransform(new Funnel(materializePath, {
files: ['materialize.js'],
destDir: 'materialize'
}));

trees.push(materializeTree);
}

return new Merge(trees);
}
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
"android"
],
"dependencies": {
"broccoli-funnel": "^1.2.0",
"broccoli-merge-trees": "^2.0.0",
"ember-cli-babel": "^6.1.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-sass": "^6.1.3",
"ember-cli-htmlbars": "^2.0.1"
"exists-sync": "^0.0.4",
"fastboot-transform": "^0.1.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
22 changes: 12 additions & 10 deletions vendor/materialize-shim.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* globals define, Materialize */
if (typeof FastBoot === 'undefined') {
/* globals define, Materialize */

(function() {
(function() {

function generateModule(name, values) {
define(name, [], function() {
'use strict';
function generateModule(name, values) {
define(name, [], function() {
'use strict';

return values;
});
}
return values;
});
}

generateModule('materialize', { 'default': Materialize });
})();
generateModule('materialize', { 'default': Materialize });
})();
}
12 changes: 9 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ broccoli-funnel-reducer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/broccoli-funnel-reducer/-/broccoli-funnel-reducer-1.0.0.tgz#11365b2a785aec9b17972a36df87eef24c5cc0ea"

broccoli-funnel@^1.0.0, broccoli-funnel@^1.0.1, broccoli-funnel@^1.0.6, broccoli-funnel@^1.1.0:
broccoli-funnel@^1.0.0, broccoli-funnel@^1.0.1, broccoli-funnel@^1.0.6, broccoli-funnel@^1.1.0, broccoli-funnel@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-1.2.0.tgz#cddc3afc5ff1685a8023488fff74ce6fb5a51296"
dependencies:
Expand Down Expand Up @@ -1304,7 +1304,7 @@ broccoli-sri-hash@^2.1.0:
sri-toolbox "^0.2.0"
symlink-or-copy "^1.0.1"

broccoli-stew@^1.2.0, broccoli-stew@^1.3.3:
broccoli-stew@^1.2.0, broccoli-stew@^1.3.3, broccoli-stew@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/broccoli-stew/-/broccoli-stew-1.5.0.tgz#d7af8c18511dce510e49d308a62e5977f461883c"
dependencies:
Expand Down Expand Up @@ -2712,7 +2712,7 @@ [email protected]:
version "0.0.3"
resolved "https://registry.yarnpkg.com/exists-sync/-/exists-sync-0.0.3.tgz#b910000bedbb113b378b82f5f5a7638107622dcf"

[email protected]:
[email protected], exists-sync@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/exists-sync/-/exists-sync-0.0.4.tgz#9744c2c428cc03b01060db454d4b12f0ef3c8879"

Expand Down Expand Up @@ -2837,6 +2837,12 @@ [email protected]:
dependencies:
broccoli-funnel "^1.0.1"

fastboot-transform@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/fastboot-transform/-/fastboot-transform-0.1.0.tgz#c00c3c4f376b4e788278cec5cb8d35488e083c07"
dependencies:
broccoli-stew "^1.5.0"

[email protected], fastboot@^1.0.0-rc.3:
version "1.0.0-rc.6"
resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-1.0.0-rc.6.tgz#09af88b41d1b31fda96be425c857e34b2323115b"
Expand Down