several things to help webpack compile speed

closes CNVS-25714

TEST PLAN:
web pack should compile in like 60 seconds rather than 600

Change-Id: I74716d9cccfd0253693660c0b4ad4368e91b72e7
Reviewed-on: https://gerrit.instructure.com/68497
Tested-by: Jenkins
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
This commit is contained in:
Ethan Vizitei 2015-12-08 14:41:14 -07:00 committed by Ethan Vizitei
parent c2077e75d7
commit 765507f63e
9 changed files with 183 additions and 6154 deletions

View File

@ -2,7 +2,7 @@
# * Make assignments (due date) events non-resizable. Having an end date on them doesn't
# make sense.
# requires jQuery, and vendor/fullcalendar
# requires jQuery
define [
'i18n!calendar'

View File

@ -16,9 +16,13 @@ CompiledReferencePlugin.prototype.apply = function(compiler){
compiler.plugin("normal-module-factory", function(nmf) {
nmf.plugin("before-resolve", function(result, callback) {
var requestString = result.request;
// this references a coffesscript file in canvas
if(/^compiled\//.test(requestString)){
// this references a coffesscript file in canvas
result.request = requestString.replace("compiled/", "coffeescripts/");
}else if(/^spec\/javascripts\/compiled/.test(requestString)){
// this references a coffesscript spec file in canvas
result.request = requestString.replace("spec/javascripts/compiled/", "");
}
// this references a coffeescript file in a canvas plugin

View File

@ -5,6 +5,7 @@ var CompiledReferencePlugin = require("./CompiledReferencePlugin");
var bundleEntries = require("./bundles");
var ShimmedAmdPlugin = require("./shimmedAmdPlugin");
var BundleExtensionsPlugin = require("./BundleExtensionsPlugin");
var path = require('path');
module.exports = {
devtool: 'eval',
@ -26,16 +27,15 @@ module.exports = {
'ic-tabs': "bower/ic-tabs/dist/amd/main",
'bower/axios/dist/axios': 'bower/axios/dist/axios.amd'
},
modulesDirectories: [
'app',
'app/views',
'client_apps',
'gems/plugins',
'public/javascripts',
'public/javascripts/vendor',
'node_modules',
"client_apps/canvas_quizzes/vendor/js",
"client_apps/canvas_quizzes/vendor/packages"
root: [
__dirname + "/../public/javascripts",
__dirname + "/../app",
__dirname + "/../app/views",
__dirname + "/../client_apps",
__dirname + "/../gems/plugins",
__dirname + "/../public/javascripts/vendor",
__dirname + "/../client_apps/canvas_quizzes/vendor/js",
__dirname + "/../client_apps/canvas_quizzes/vendor/packages"
],
extensions: [
"",
@ -53,6 +53,7 @@ module.exports = {
loaders: [
{
test: /\.js$/,
include: path.resolve(__dirname, "../public/javascripts"),
loaders: [
"jsHandlebarsHelpers",
"pluginsJstLoader",
@ -61,14 +62,23 @@ module.exports = {
},
{
test: /\.jsx$/,
exclude: /(node_modules|bower_components)/,
include: [
path.resolve(__dirname, "../app/jsx"),
/app\/client_apps\/canvas_quizzes\/apps\//
],
exclude: [/(node_modules|bower)/, /public\/javascripts\/vendor/, /public\/javascripts\/translations/],
loaders: [
'babel',
'babel?cacheDirectory=tmp',
'jsxYankPragma'
]
},
{
test: /\.coffee$/,
include: [
path.resolve(__dirname, "../app/coffeescript"),
path.resolve(__dirname, "../spec/coffeescripts"),
/gems\/plugins\/.*\/app\/coffeescripts\//
],
loaders: [
"coffee-loader",
"jsHandlebarsHelpers",
@ -77,22 +87,36 @@ module.exports = {
] },
{
test: /\.handlebars$/,
include: [
path.resolve(__dirname, "../app/views/jst"),
/gems\/plugins\/.*\/app\/views\/jst\//
],
exclude: /bower/,
loaders: [
"i18nLinerHandlebars"
]
},
{
test: /\.hbs$/,
include: [
path.resolve(__dirname, "../app/coffeescript/ember"),
/app\/coffeescripts\/ember\/screenreader_gradebook\/templates\//,
/app\/coffeescripts\/ember\/shared\/templates\//
],
exclude: /bower/,
loaders: [
"emberHandlebars"
]
},
{
test: /\.json$/,
include: path.resolve(__dirname, "../public/javascripts"),
exclude: [/(node_modules|bower)/, /public\/javascripts\/vendor/],
loader: "json-loader"
},
{
test: /vendor\/jquery-1\.7\.2/,
include: path.resolve(__dirname, "../public/javascripts/vendor"),
loader: "exports-loader?window.jQuery"
},
{
@ -118,6 +142,69 @@ module.exports = {
}),
new webpack.IgnorePlugin(/\.md$/),
new webpack.IgnorePlugin(/(CHANGELOG|LICENSE|README)$/),
new webpack.IgnorePlugin(/package.json/)
new webpack.IgnorePlugin(/package.json/),
new webpack.PrefetchPlugin("./app/coffeescripts/calendar/ContextSelector.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/calendar/TimeBlockRow.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/react_files/components/FolderTree.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/react_files/components/Toolbar.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/react_files/utils/moveStuff.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/grade_summary/OutcomeLineGraphView.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/grade_summary/OutcomeView.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/groups/manage/AssignToGroupMenu.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/groups/manage/EditGroupAssignmentView.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/groups/manage/GroupUserView.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/views/MoveDialogSelect.coffee"),
new webpack.PrefetchPlugin("./app/coffeescripts/widget/TokenInput.coffee"),
new webpack.PrefetchPlugin("./app/jsx/assignments/ModerationApp.jsx"),
new webpack.PrefetchPlugin("./app/jsx/authentication_providers/AuthTypePicker.jsx"),
new webpack.PrefetchPlugin("./app/jsx/context_modules/FileSelectBox.jsx"),
new webpack.PrefetchPlugin("./app/jsx/course_wizard/Checklist.jsx"),
new webpack.PrefetchPlugin("./app/jsx/dashboard_card/DashboardCard.jsx"),
new webpack.PrefetchPlugin("./app/jsx/due_dates/DueDates.jsx"),
new webpack.PrefetchPlugin("./app/jsx/due_dates/DueDateCalendarPicker.jsx"),
new webpack.PrefetchPlugin("./app/jsx/epub_exports/CourseListItem.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/AppDetails.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/AppList.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/Configurations.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/ConfigurationForm.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/ConfigurationFormUrl.jsx"),
new webpack.PrefetchPlugin("./app/jsx/external_apps/components/ExternalToolsTableRow.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/BreadcrumbCollapsedContainer.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/CurrentUploads.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/DialogPreview.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/FilesApp.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/FilePreview.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/ShowFolder.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/UploadButton.jsx"),
new webpack.PrefetchPlugin("./app/jsx/files/utils/openMoveDialog.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/grid/components/column_types/headerRenderer.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/grid/components/dropdown_components/assignmentHeaderDropdownOptions.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/grid/components/gradebook.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/grid/wrappers/columnFactory.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/SISGradePassback/PostGradesApp.jsx"),
new webpack.PrefetchPlugin("./app/jsx/gradebook/SISGradePassback/PostGradesDialogCorrectionsPage.jsx"),
new webpack.PrefetchPlugin("./app/jsx/grading/gradingPeriodCollection.jsx"),
new webpack.PrefetchPlugin("./app/jsx/grading/gradingStandardCollection.jsx"),
new webpack.PrefetchPlugin("./app/jsx/groups/components/PaginatedGroupList.jsx"),
new webpack.PrefetchPlugin("./app/jsx/shared/ColorPicker.jsx"),
new webpack.PrefetchPlugin("./app/jsx/theme_editor/ThemeEditorAccordion.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/common/js/core/dispatcher.js"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/bundles/routes.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/routes/event_stream.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/routes/question.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/views/answer_matrix.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/views/answer_matrix/inverted_table.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/views/question_inspector.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/views/question_inspector/answers/essay.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/events/js/stores/events.js"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/statistics/js/stores/reports.js"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/statistics/js/stores/statistics.js"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/statistics/js/views/app.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/statistics/js/views/questions/multiple_choice.jsx"),
new webpack.PrefetchPlugin("./client_apps/canvas_quizzes/apps/statistics/js/views/summary/report.jsx"),
new webpack.PrefetchPlugin("./public/javascripts/axios.js"),
new webpack.PrefetchPlugin("./public/javascripts/bower/k5uploader/lib/ui_config_from_node.js"),
new webpack.PrefetchPlugin("./public/javascripts/bower/reflux/dist/reflux.min.js")
]
};

View File

@ -182,6 +182,7 @@ pluginBundles.forEach(function(entryFilepath){
entries['instructure-common'] = [
'ajax_errors',
'coffeescripts/bundles/common',
'classnames',
'compiled/helpDialog',
'compiled/badge_counts',
'compiled/behaviors/activate',
@ -192,23 +193,70 @@ entries['instructure-common'] = [
'compiled/behaviors/ping',
'compiled/behaviors/tooltip',
'compiled/behaviors/ujsLinks',
'compiled/collections/AssignmentOverrideCollection',
'compiled/collections/DateGroupCollection',
'compiled/collections/GroupUserCollection',
'compiled/editor/stocktiny',
'compiled/grade_calculator',
'compiled/jquery/ModuleSequenceFooter',
'compiled/jquery/serializeForm',
'compiled/license_help',
'compiled/models/Assignment',
'compiled/models/grade_summary/CalculationMethodContent',
'compiled/models/AssignmentOverride',
'compiled/models/DateGroup',
'compiled/models/Group',
'compiled/models/Outcome',
'compiled/models/Progress',
'compiled/models/Pseudonym',
'compiled/models/Section',
'compiled/models/TurnitinSettings',
'compiled/models/User',
'compiled/PandaPub',
'compiled/registration/incompleteRegistrationWarning',
'compiled/tours',
'compiled/util/brandableCss',
'compiled/util/DateValidator',
'compiled/util/PandaPubPoller',
'compiled/util/Popover',
'compiled/util/round',
'compiled/views/CollectionView',
'compiled/views/DialogBaseView',
'compiled/views/DialogFormView',
'compiled/views/editor/KeyboardShortcuts',
'compiled/views/MessageStudentsDialog',
'compiled/views/PaginatedCollectionView',
'compiled/views/PaginatedView',
'compiled/views/PublishButtonView',
'compiled/views/PublishIconView',
'compiled/views/TreeBrowserView',
'compiled/views/ValidatedFormView',
'compiled/views/ValidatedMixin',
'i18nObj',
'instructure',
'jquery.instructure_forms',
'jquery.toJSON',
'jst/_avatar',
'jst/collectionView',
'jst/DialogFormWrapper',
'jst/editor/KeyboardShortcuts',
'jst/EmptyDialogFormWrapper',
'jst/ExternalTools/_external_tool_menuitem',
'jst/messageStudentsDialog',
'jst/outcomes/_calculationMethodExample',
'jst/paginatedCollection',
'jst/PaginatedView',
'jsx/shared/helpers/createStore',
'link_enrollment',
'LtiThumbnailLauncher',
'media_comments',
'page_views',
'reminders',
'translations/_core_en',
'reminders'
];
entries['vendor'] = [
'Backbone',
'bower/classnames/index',
'bower/handlebars/handlebars.runtime',
'handlebars',
'jquery',
@ -227,8 +275,8 @@ entries['vendor'] = [
'vendor/backbone-identity-map',
'vendor/backbone',
'vendor/date',
'vendor/d3.v3',
'vendor/firebugx',
'vendor/fullcalendar',
'vendor/graphael',
'vendor/i18n',
'vendor/i18n_js_extension',

View File

@ -0,0 +1,21 @@
// This file has a bad name, it's really a webpack loader, but
// in order to let webpack build everything without changing any of the
// app javascript, we're giving it the name to match the existing
// require statements.
module.exports = function(input){
throw "Should not ever make it to the actual fullcalendar loader because those resources don't exist";
}
// This adapts the functionality of an old fullcalendar_plugin.js that would load
// the lib with it's languages on board. We're keeping
// it as a loader for now to avoid changing the existing app javascripts
// while transitioning to webpack
module.exports.pitch = function(remainingRequest, precedingRequest, data) {
this.cacheable();
return "" +
"define([\"bower/fullcalendar/dist/fullcalendar\", \"bower/fullcalendar/dist/lang-all\"], function(fc, lang){\n " +
" return fc;\n" +
"});";
};

View File

@ -48,7 +48,7 @@
"testem": "~0.7.1",
"uglify-js": "~2.4.12",
"vinyl-fs": "0.3.7",
"webpack": "^1.12.2",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.12.0",
"worker-loader": "^0.6.0",
"xsslint": "0.1.2"
@ -61,6 +61,7 @@
"preupdate": "script/gem_npm update",
"webpack": "webpack --progress --color --watch",
"webpack-development": "webpack --progress --color",
"webpack-stats": "webpack --profile --json",
"webpack-test": "NODE_ENV=test webpack --progress --color --config webpack.test.config.js",
"webpack-test-watch": "NODE_ENV=test webpack --progress --color --watch --config webpack.test.config.js",
"webpack-production": "NODE_ENV=production webpack --progress --color --config webpack.production.config.js"

View File

@ -10,7 +10,7 @@
// core functions into plugin code. It's disgusting, I'm sorry, but this is how
// we make a transition without changing app code. This "realTinymce" thing
// works because we define an alias in webpack.config.js
var assign = require("lodash").assign;
var assign = require("lodash.underscore").extend;
var tinymceCore = require("realTinymce");
assign(window.tinymce, tinymceCore.tinymce);
module.exports = window.tinymce;

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,8 @@ testWebpackConfig.plugins = [
];
testWebpackConfig.resolve.alias.qunit = "qunitjs/qunit/qunit.js";
testWebpackConfig.resolve.modulesDirectories.push('spec/coffeescripts');
testWebpackConfig.resolve.modulesDirectories.push('spec/javascripts/support');
testWebpackConfig.resolve.root.push(__dirname + '/spec/coffeescripts');
testWebpackConfig.resolve.root.push(__dirname + '/spec/javascripts/support');
testWebpackConfig.module.loaders.push({
test: /\/spec\/coffeescripts\//,
loaders: ["qunitDependencyLoader"]