Commit dfd5413b by Torkel Ödegaard

tech(systemjs): worked on making optimized builds work with systemjs builder

parent 93e424de
define([ define([
'./app2' './grafana'
], function(app) { ], function(app) {
'use strict'; 'use strict';
// backward compatability hack; // backward compatability hack;
console.log(app);
return app.default; return app.default;
}); });
import {GrafanaApp} from 'app/grafana_app';
export default new GrafanaApp();
(function bootGrafana() {
'use strict';
System.import('app/app').then(function(app) {
console.log(app);
app.init();
}).catch(function(err) {
console.log('Loading app module failed: ', err);
});
})();
...@@ -93,5 +93,6 @@ export class GrafanaApp { ...@@ -93,5 +93,6 @@ export class GrafanaApp {
console.log('Application boot failed:', err); console.log('Application boot failed:', err);
}); });
} }
} }
export default new GrafanaApp();
...@@ -41,7 +41,7 @@ System.config({ ...@@ -41,7 +41,7 @@ System.config({
meta: { meta: {
'vendor/angular/angular.js': { 'vendor/angular/angular.js': {
format: 'amd', format: 'global',
deps: ['jquery'], deps: ['jquery'],
exports: 'angular', exports: 'angular',
}, },
......
...@@ -57,25 +57,14 @@ ...@@ -57,25 +57,14 @@
}; };
</script> </script>
<!-- build:js [[.AppSubUrl]]/public/app/app.js --> <!-- build:js [[.AppSubUrl]]/public/app/boot.js -->
<script src="[[.AppSubUrl]]/public/vendor/npm/es6-shim/es6-shim.js"></script> <script src="[[.AppSubUrl]]/public/vendor/npm/es6-shim/es6-shim.js"></script>
<script src="[[.AppSubUrl]]/public/vendor/npm/es6-promise/dist/es6-promise.js"></script> <script src="[[.AppSubUrl]]/public/vendor/npm/es6-promise/dist/es6-promise.js"></script>
<script src="[[.AppSubUrl]]/public/vendor/npm/systemjs/dist/system.src.js"></script> <script src="[[.AppSubUrl]]/public/vendor/npm/systemjs/dist/system.src.js"></script>
<script src="[[.AppSubUrl]]/public/vendor/npm/rxjs/bundles/Rx.js"></script>
<script src="[[.AppSubUrl]]/public/vendor/npm/angular2/bundles/angular2-polyfills.js"></script>
<script src="[[.AppSubUrl]]/public/vendor/npm/angular2/bundles/angular2.dev.js"></script>
<script src="[[.AppSubUrl]]/public/app/systemjs.conf.js"></script> <script src="[[.AppSubUrl]]/public/app/systemjs.conf.js"></script>
<script src="[[.AppSubUrl]]/public/app/boot.js"></script>
<!-- endbuild --> <!-- endbuild -->
<script>
System.import('app/app').then(function(app) {
console.log(app)
app.init();
}).catch(function(err) {
console.log('Loading app module failed: ', err);
});
</script>
[[if .GoogleAnalyticsId]] [[if .GoogleAnalyticsId]]
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
......
...@@ -10,20 +10,19 @@ module.exports = function(grunt) { ...@@ -10,20 +10,19 @@ module.exports = function(grunt) {
'clean:release', 'clean:release',
'copy:public_to_gen', 'copy:public_to_gen',
'typescript:build', 'typescript:build',
'karma:test', // 'karma:test',
'phantomjs', 'phantomjs',
'css', 'css',
// 'htmlmin:build', 'htmlmin:build',
'ngtemplates', 'ngtemplates',
'cssmin:build', 'cssmin:build',
'ngAnnotate:build', 'ngAnnotate:build',
'requirejs:build', 'systemjs:build',
'concat:js', 'concat:js',
'clean:temp', // 'filerev',
'filerev', // 'remapFilerev',
'remapFilerev',
'usemin', 'usemin',
'uglify:genDir' // 'uglify:genDir'
]); ]);
// task to add [[.AppSubUrl]] to reved path // task to add [[.AppSubUrl]] to reved path
......
...@@ -13,6 +13,7 @@ module.exports = function(config) { ...@@ -13,6 +13,7 @@ module.exports = function(config) {
], ],
dest: '<%= genDir %>/css/grafana.dark.min.css' dest: '<%= genDir %>/css/grafana.dark.min.css'
}, },
cssLight: { cssLight: {
src: [ src: [
'<%= genDir %>/vendor/css/normalize.min.css', '<%= genDir %>/vendor/css/normalize.min.css',
...@@ -24,13 +25,24 @@ module.exports = function(config) { ...@@ -24,13 +25,24 @@ module.exports = function(config) {
], ],
dest: '<%= genDir %>/css/grafana.light.min.css' dest: '<%= genDir %>/css/grafana.light.min.css'
}, },
js: { js: {
src: [ src: [
'<%= tempDir %>/vendor/requirejs/require.js', '<%= genDir %>/vendor/npm/es6-shim/es6-shim.js',
'<%= tempDir %>/app/require_config.js', '<%= genDir %>/vendor/npm/es6-promise/es6-promise.js',
'<%= tempDir %>/app/app.js', '<%= genDir %>/vendor/npm/systemjs/dist/system.js',
'<%= genDir %>/app/systemjs.conf.js',
'<%= genDir %>/app/boot.js',
],
dest: '<%= genDir %>/app/boot.js'
},
bundle_and_boot: {
src: [
'<%= genDir %>/app/app_bundle.js',
'<%= genDir %>/app/boot.js',
], ],
dest: '<%= genDir %>/app/app.js' dest: '<%= genDir %>/app/boot.js'
}, },
}; };
}; };
...@@ -3,7 +3,7 @@ module.exports = function(config) { ...@@ -3,7 +3,7 @@ module.exports = function(config) {
build: { build: {
expand: true, expand: true,
cwd: '<%= genDir %>', cwd: '<%= genDir %>',
src: '**/*.css', src: ['css/*.css', 'vendor/css/*.css'],
dest: '<%= genDir %>' dest: '<%= genDir %>'
} }
}; };
......
...@@ -7,7 +7,7 @@ module.exports = function(config) { ...@@ -7,7 +7,7 @@ module.exports = function(config) {
options: { options: {
bootstrap: function(module, script) { bootstrap: function(module, script) {
return "define('app/core/partials', ['app/core/core_module'], function(coreModule) { \n" + return "define('app/core/partials', ['app/core/core_module'], function(coreModule) { \n" +
"coreModule.run(['$templateCache', function($templateCache) { \n" + "coreModule.default.run(['$templateCache', function($templateCache) { \n" +
script + script +
'\n}]);' + '\n}]);' +
'\n});'; '\n});';
......
...@@ -2,7 +2,6 @@ module.exports = function(grunt) { ...@@ -2,7 +2,6 @@ module.exports = function(grunt) {
"use strict"; "use strict";
grunt.registerTask('systemjs:build', function() { grunt.registerTask('systemjs:build', function() {
var path = require("path");
var Builder = require('systemjs-builder'); var Builder = require('systemjs-builder');
var done = this.async(); var done = this.async();
...@@ -11,11 +10,23 @@ module.exports = function(grunt) { ...@@ -11,11 +10,23 @@ module.exports = function(grunt) {
var builder = new Builder('public_gen', 'public_gen/app/systemjs.conf.js'); var builder = new Builder('public_gen', 'public_gen/app/systemjs.conf.js');
console.log('Starting systemjs-builder'); console.log('Starting systemjs-builder');
var modules = [
'app/app',
'app/features/all',
'app/plugins/panels/**/*',
'app/plugins/datasource/graphite/**/*',
'app/plugins/datasource/influxdb/**/*',
'app/plugins/datasource/elasticsearch/**/*',
];
var expression = modules.join(' + ');
builder builder
.bundle('app/app + app/features/all', 'public_gen/app/app.js') .bundle(expression, 'public_gen/app/app_bundle.js')
.then(function() { .then(function() {
console.log('Build complete'); console.log('Build complete');
done(); done();
grunt.task.run('concat:bundle_and_boot');
}) })
.catch(function(err) { .catch(function(err) {
console.log('Build error'); console.log('Build error');
...@@ -23,5 +34,4 @@ module.exports = function(grunt) { ...@@ -23,5 +34,4 @@ module.exports = function(grunt) {
done(); done();
}); });
}); });
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment