Skip to content

Commit 4c77d87

Browse files
author
Ben Warzeski
authored
[DRAFT] webpack update (#1512)
* webpack update * remove jshint * remove unused import * cleanup * merge conflicts * remove old artifacts * debug logging for initial test validation * linting * test fixes * more linting * remove debug logging * make javascript * translations * documentation update * remove debug * fix tinyMCE integration * fix test * remove npm update from `make javascript` * version bump to 2.11.0
1 parent ac502d8 commit 4c77d87

File tree

143 files changed

+27242
-9920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+27242
-9920
lines changed

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RC_ENV=development
2+
NODE_ENV=development
3+
BABEL_ENV=development
4+
NODE_PATH=./openassessment/xblock/static/js/src
5+
BROWSER=none

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { createConfig } = require('@edx/frontend-build');
2+
3+
const config = createConfig('eslint');
4+
5+
// These rule overrides should be removed at a later date, and the associated code fixed.
6+
config.rules["import/no-named-as-default"] = "off";
7+
config.rules["no-underscore-dangle"] = "off";
8+
config.rules["prefer-rest-params"] = "off";
9+
config.rules["no-unused-vars"] = "off";
10+
config.rules["no-param-reassign"] = "off";
11+
config.rules["no-alert"] = "off";
12+
config.rules["no-new"] = "off";
13+
config.rules["func-names"] = "off";
14+
config.rules["max-classes-per-file"] = "off";
15+
config.rules["prefer-destructuring"] = "off";
16+
config.rules["no-prototype-builtins"] = "off";
17+
18+
config.globals["gettext"] = "readonly";
19+
config.globals["ngettext"] = "readonly";
20+
config.globals["$"] = "readonly";
21+
config.globals["MathJax"] = "readonly";
22+
config.globals["_"] = "readonly";
23+
config.globals["Logger"] = "readonly";
24+
config.globals["XBlock"] = "readonly";
25+
config.globals["Backbone"] = "readonly";
26+
config.globals["Backgrid"] = "readonly";
27+
config.globals["rewriteStaticLinks"] = "readonly";
28+
29+
module.exports = config;

.jshintrc

Lines changed: 0 additions & 158 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ update-npm-requirements: ## update NPM requrements
6969
cp ./node_modules/backgrid/lib/backgrid*.js $(STATIC_JS)/lib/backgrid/
7070
cp ./node_modules/backgrid/lib/backgrid*.css $(STATIC_CSS)/lib/backgrid/
7171

72-
javascript: update-npm-requirements ## Minify JavaScript source files
73-
node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/lms/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js > "$(STATIC_JS)/openassessment-lms.min.js"
74-
node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/studio/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js > "$(STATIC_JS)/openassessment-studio.min.js"
72+
javascript: ## Webpack JavaScript source files
73+
npm run build
7574

7675
sass: ## Compile SASS files
7776
python scripts/compile_sass.py
@@ -109,7 +108,6 @@ check_translations_up_to_date: extract_translations compile_translations generat
109108
################
110109

111110
quality: ## Run linting and code quality checks
112-
./node_modules/.bin/jshint $(STATIC_JS)/src -c .jshintrc --verbose
113111
npm run lint
114112
./scripts/run-pycodestyle.sh
115113
./scripts/run-pylint.sh

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { createConfig } = require('@edx/frontend-build');
2+
3+
module.exports = createConfig('babel');

docs/developers_guide.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,21 @@ If any changes are made to the .html files, it is necessary to re-do the transla
7979

8080
The above command will generate translations files which will have to be checked into git.
8181

82-
Minifying js/html
82+
Building JS
83+
------------
84+
This is required if there were any JS changes:
85+
86+
- from local directory (not in lms shell)
87+
- ``npm run build``
88+
89+
Minifying css
8390
-----------------
84-
This is required if there were any js/html changes:
91+
This is required if there were any scss changes:
8592

8693
- be inside the shell
8794
- ``cd /edx/src/edx-ora2``
8895
- ``source edx-ora2/bin/activate``
89-
- ``make javascript sass``
96+
- ``make sass``
9097

9198
Running Unit Tests
9299
------------------
@@ -107,4 +114,4 @@ Other Resources
107114
---------------
108115
`ORA user documentation <http://edx.readthedocs.org/projects/edx-partner-course-staff/en/latest/exercises_tools/open_response_assessments/index.html>`_
109116

110-
`ORA analytics documentation <https://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/ora2_data.html>`_
117+
`ORA analytics documentation <https://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/ora2_data.html>`_

env.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
default_env: &default_env
2+
RC_ENV: development
3+
NODE_ENV: development
4+
BABEL_ENV: development
5+
NODE_PATH: './openassessment/xblock/static/js/src'
6+
BROWSER: none
7+
8+
development:
9+
<<: *default_env
10+
11+
production:
12+
<<: *default_env
13+
RC_ENV: production
14+
NODE_ENV: production
15+
BABEL_ENV: production

karma.conf.js

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// Karma configuration
2+
const webpackConfig = require('./webpack.dev.config.js');
23

34
module.exports = function(config) {
45
config.set({
56

67
// base path that will be used to resolve all patterns (eg. files, exclude)
7-
basePath: 'openassessment/xblock/static/',
8+
basePath: 'openassessment/xblock/static',
89

910

1011
plugins: [
@@ -15,7 +16,8 @@ module.exports = function(config) {
1516
'karma-coverage',
1617
'karma-sinon',
1718
'karma-jasmine-html-reporter',
18-
'karma-spec-reporter'
19+
'karma-spec-reporter',
20+
'karma-webpack'
1921
],
2022

2123
// frameworks to use
@@ -42,26 +44,17 @@ module.exports = function(config) {
4244
pattern: '../../../node_modules/moment/min/moment-with-locales.min.js',
4345
served: true, included: false
4446
},
45-
{
46-
pattern: '../../../node_modules/edx-ui-toolkit/src/js/utils/date-utils.js',
47-
served: true, included: false
48-
},
49-
{
50-
pattern: '../../../node_modules/edx-ui-toolkit/src/js/utils/string-utils.js',
51-
served: true, included: false
52-
},
5347
//
54-
'js/src/oa_shared.js',
55-
'js/src/*.js',
56-
'js/src/lms/*.js',
57-
'js/src/studio/*.js',
58-
'js/spec/test_shared.js',
59-
'js/spec/*.js',
60-
'js/spec/lms/*.js',
61-
'js/spec/studio/*.js',
48+
{ pattern: 'js/fixtures/*.html' },
49+
{ pattern: 'js/spec/*.js', watched: false },
50+
{ pattern: 'js/spec/**/*.js', watched: false },
51+
{ pattern: 'js/src/oa_shared.js', watched: false },
52+
{ pattern: 'js/src/*_index.js', watched: false },
53+
{ pattern: 'js/src/**/*.js', watched: false },
54+
6255
// fixtures
6356
{
64-
pattern: 'js/fixtures/*.html',
57+
pattern: 'js/fixtures/*.json',
6558
served: true, included: false
6659
}
6760
],
@@ -74,11 +67,14 @@ module.exports = function(config) {
7467
// preprocess matching files before serving them to the browser
7568
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
7669
preprocessors: {
77-
'js/src/*.js': 'coverage',
78-
'js/src/lms/*.js': 'coverage',
79-
'js/src/studio/*.js': 'coverage'
70+
'js/src/*_index.js': ['webpack'],
71+
'js/src/**/*.js': ['webpack', 'coverage'],
72+
'js/spec/*.js': ['webpack'],
73+
'js/spec/**/*.js': ['webpack'],
74+
'js/src/oa_shared.js': ['webpack'],
8075
},
8176

77+
webpack: webpackConfig,
8278

8379
// test results reporter to use
8480
reporters: ['spec', 'coverage'],
@@ -105,12 +101,27 @@ module.exports = function(config) {
105101

106102
// start these browsers
107103
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
108-
browsers: ['PhantomJS'],
104+
browsers: ['HeadlessChrome'],
105+
customLaunchers: {
106+
HeadlessChrome: {
107+
base: 'ChromeHeadless',
108+
flags: [
109+
'--no-sandbox',
110+
'--headless',
111+
'--disable-gpu',
112+
'--disable-translate',
113+
'--disable-extensions'
114+
]
115+
}
116+
},
109117

110118
// Continuous Integration mode
111119
// if true, Karma captures browsers, runs the tests and exits
112-
singleRun: true
120+
singleRun: true,
113121

114-
});
122+
resolve: {
123+
extensions: ['', '.js'],
124+
}
115125

126+
});
116127
};
41 Bytes
Binary file not shown.
41 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)