Skip to content

Commit

Permalink
Broccolify #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed May 12, 2014
1 parent 1a21080 commit 76c535f
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ node_modules
bundle/
*~
publish_to_bower/
bower_components/
142 changes: 142 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
var fs = require('fs');
var pickFiles = require('broccoli-static-compiler');
var compileES6 = require('broccoli-es6-concatenator');
var findBowerTrees = require('broccoli-bower');
var mergeTrees = require('broccoli-merge-trees');
var defeatureify = require('broccoli-defeatureify');

var configJson = JSON.parse(fs.readFileSync("features.json").toString());

var defeatureifyConfig = {
enabled: configJson.features,
debugStatements: configJson.debugStatements,
namespace: configJson.namespace,
enableStripDebug: configJson.enableStripDebug
};

function moduleNameToPath(modulePath) {
var pathParts = modulePath.split('/');
var outputPathParts = [];

if (pathParts[0] !== 'packages_es6') {
outputPathParts = ['packages_es6', pathParts[0]]
if (pathParts[1] !== 'tests') {
outputPathParts.push('lib');
}
if (pathParts.length === 1) {
outputPathParts.push('main');
} else {
outputPathParts = outputPathParts.concat(pathParts.slice(1))
}
} else {
outputPathParts.push(modulePath);
}

return outputPathParts.join('/') + '.js';
}

function pathToModuleName(path) {
return moduleName = path
.replace('packages_es6/', '')
.replace('lib/', '')
.replace(/\/main$/, '')
.slice(0, -3);
}

var legacyFilesToAppend = [
'packages_es6/ember-metal/lib/vendor/backburner.amd.js',
'packages_es6/ember-routing/lib/vendor/router.amd.js',
'packages_es6/ember-routing/lib/vendor/route-recognizer.amd.js',
'rsvp/main.js',
'metamorph/main.js',
];

var testConfig = pickFiles('tests', {
srcDir: '/',
files: ['**/*.*'],
destDir: '/tests'
});

//['container', 'ember-metal', 'ember-debug',
// 'ember-runtime', 'ember-views', 'ember-extension-support',
// 'ember-testing', 'ember-handlebars-compiler', 'ember-handlebars',
// 'ember-routing', 'ember-application']
//.forEach(function(packageName) {
// packages.push(pickFiles('packages_es6/' + packageName, {
// srcDir: '/',
// destDir: '/'
// }))
//});

var loader = pickFiles('packages/loader/lib', {
files: ['main.js'],
srcDir: '/',
destDir: '/loader'
});

var rsvp = pickFiles('packages/rsvp/lib', {
files: ['main.js'],
srcDir: '/',
destDir: '/rsvp'
});

var metamorph = pickFiles('packages/metamorph/lib', {
files: ['main.js'],
srcDir: '/',
destDir: '/metamorph'
});

var bowerFiles = [
pickFiles('bower_components/qunit/qunit', {
srcDir: '/',
destDir: '/qunit'
}),

pickFiles('bower_components/jquery', {
files: ['jquery.js'],
srcDir: '/',
destDir: '/jquery'
}),

pickFiles('bower_components/handlebars', {
files: ['handlebars.js'],
srcDir: '/',
destDir: '/handlebars'
}),
];

bowerFiles = mergeTrees(bowerFiles);

var packages = pickFiles('packages_es6', {
srcDir: '/',
destDir: 'packages_es6'
});

var sourceTrees = [packages, loader, rsvp, metamorph];
sourceTrees = mergeTrees(sourceTrees, {overwrite: true});

var packagesJs = compileES6(sourceTrees, {
loaderFile: 'loader/main.js',
ignoredModules: [ ],
inputFiles: [ 'packages_es6/**/lib/**/*.js' ],
legacyFilesToAppend: legacyFilesToAppend,
wrapInEval: true,
outputFile: '/dist/ember.js',
moduleNameToPath: moduleNameToPath,
pathToModuleName: pathToModuleName
});

var testsJs = compileES6(sourceTrees, {
loaderFile: 'loader/main.js',
ignoredModules: [ ],
inputFiles: [ 'packages_es6/**/tests/**/*.js' ],
legacyFilesToAppend: legacyFilesToAppend,
wrapInEval: true,
outputFile: '/dist/ember-tests.js',
moduleNameToPath: moduleNameToPath,
pathToModuleName: pathToModuleName
});

var defeaturedJs = defeatureify(mergeTrees([packagesJs, testsJs], {overwrite: true}), defeatureifyConfig);

module.exports = mergeTrees([defeaturedJs, testConfig, bowerFiles]);
9 changes: 9 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "ember",
"dependencies": {
"handlebars": "~1.3.0",
"jquery": "~1.9.1",
"qunit": "~1.12.0",
"loader": "git://github.com/stefanpenner/loader.js#1.0.0"
}
}
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
"defeatureify": "~0.2.0",
"yuidocjs": "~0.3.46",
"es6-module-transpiler": "~0.4.0",
"glob": "~3.2.8"
"glob": "~3.2.8",
"broccoli": "0.9.0",
"broccoli-bower": "^0.2.0",
"broccoli-env": "0.0.1",
"broccoli-es6-concatenator": "0.1.4",
"broccoli-static-compiler": "0.1.4",
"broccoli-uglify-js": "0.1.3",
"broccoli-merge-trees": "0.1.3",
"broccoli-es6-import-validate": "0.1.0",
"broccoli-template": "0.1.1",
"broccoli-replace": "0.1.5",
"broccoli-defeatureify": "0.2.0"
}
}
52 changes: 52 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember</title>
<link rel="stylesheet" href="/qunit/qunit.css">
<script src="/qunit/qunit.js"></script>
<script src="/tests/qunit_configuration.js"></script>
<script src="/handlebars/handlebars.js"></script>

<script type="text/javascript">
window.loadScript = function(url) {
document.write(unescape('%3Cscript src="'+url+'"%3E%3C/script%3E'));
};
</script>

<script type="text/javascript">
// Load custom version of jQuery if possible (assign to window so IE8 can use in later blocks)
var jQueryVersion = QUnit.urlParams.jquery;
if (jQueryVersion) {
loadScript('https://code.jquery.com/jquery-'+jQueryVersion+'.js');
}
// Close the script tag to make sure document.write happens
</script>

<script type="text/javascript">
// Fallback to default jQuery
if (jQueryVersion !== 'none' && !window.jQuery) {
loadScript('/jquery/jquery.js');
}
// Close the script tag to make sure document.write happens
</script>

<script src="/tests/ember_configuration.js"></script>
<script src="/dist/ember-tests.js"></script>
<script>
var packages = (QUnit.urlParams.package || "*").split(",");
var packageRegexp = new RegExp('^('+packages.join('|')+')/');


for (var moduleName in Ember.__loader.registry) {
if (moduleName.match(packageRegexp) && moduleName.match(/_test$/)) {
requireModule(moduleName);
}
}
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
Loading

0 comments on commit 76c535f

Please sign in to comment.