diff --git a/app/assets/javascripts/lib/d3.js b/app/assets/javascripts/lib/d3.js deleted file mode 100644 index a9dd32edbed..00000000000 --- a/app/assets/javascripts/lib/d3.js +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable func-names, space-before-function-paren */ - -window.d3 = require('d3'); diff --git a/app/assets/javascripts/users/calendar.js b/app/assets/javascripts/users/calendar.js index 5111b260e1c..754d448564f 100644 --- a/app/assets/javascripts/users/calendar.js +++ b/app/assets/javascripts/users/calendar.js @@ -1,5 +1,6 @@ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, camelcase, vars-on-top, object-shorthand, comma-dangle, eqeqeq, no-mixed-operators, no-return-assign, newline-per-chained-call, prefer-arrow-callback, consistent-return, one-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, no-else-return, max-len */ -/* global d3 */ + +import d3 from 'd3'; (function() { var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }; diff --git a/app/views/projects/graphs/charts.html.haml b/app/views/projects/graphs/charts.html.haml index fa28db6c71f..464ac34d961 100644 --- a/app/views/projects/graphs/charts.html.haml +++ b/app/views/projects/graphs/charts.html.haml @@ -1,6 +1,7 @@ - @no_container = true - page_title "Charts" - content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('common_d3') = page_specific_javascript_bundle_tag('graphs') = render "projects/commits/head" diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 05291c65b50..680f8ae6c8f 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -1,6 +1,7 @@ - @no_container = true - page_title "Contributors" - content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('common_d3') = page_specific_javascript_bundle_tag('graphs') = render 'projects/commits/head' diff --git a/app/views/projects/pipelines/charts.html.haml b/app/views/projects/pipelines/charts.html.haml index fbf783afe44..4a5043aac3c 100644 --- a/app/views/projects/pipelines/charts.html.haml +++ b/app/views/projects/pipelines/charts.html.haml @@ -1,6 +1,7 @@ - @no_container = true - page_title "Charts", "Pipelines" - content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('common_d3') = page_specific_javascript_bundle_tag('graphs') = render 'head' diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index af091f9ab88..76cd330e80a 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,7 +1,7 @@ - page_title @user.name - page_description @user.bio - content_for :page_specific_javascripts do - = page_specific_javascript_bundle_tag('lib_d3') + = page_specific_javascript_bundle_tag('common_d3') = page_specific_javascript_bundle_tag('users') - header_title @user.name, user_path(@user) - @no_container = true diff --git a/config/webpack.config.js b/config/webpack.config.js index 243007be4b7..eb453b5997b 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -19,6 +19,7 @@ var config = { entry: { common: './commons/index.js', common_vue: ['vue', 'vue-resource'], + common_d3: ['d3'], application: './application.js', blob_edit: './blob_edit/blob_edit_bundle.js', boards: './boards/boards_bundle.js', @@ -40,7 +41,6 @@ var config = { snippet: './snippet/snippet_bundle.js', terminal: './terminal/terminal_bundle.js', users: './users/users_bundle.js', - lib_d3: './lib/d3.js', vue_pipelines: './vue_pipelines_index/index.js', }, @@ -116,6 +116,12 @@ var config = { }, }), + // create cacheable common library bundle for all d3 chunks + new webpack.optimize.CommonsChunkPlugin({ + name: 'common_d3', + chunks: ['graphs', 'users'], + }), + // create cacheable common library bundles new webpack.optimize.CommonsChunkPlugin({ names: ['application', 'common', 'manifest'],