[DevOps] Update webpack and eslint package version #1379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates all webpack and eslint packages and makes config/code changes as required. There is a lot here, but it had to be done all at once because so many packages depend on webpack.
Fixes: #1337
Related: #1260
Webpack
node.fs: 'empty'
replace it withresolve.fallback.fs: false.
"entry: './src/index.js'
: you can omit it, that's the default."output.path: path.resolve(__dirname, 'dist')
: you can omit it, that's the default."version
frompackage.json
because using named exports from JSON modules is no longer supported.eslint-loader
with recommendedeslint-webpack-plugin
.copy-webpack-plugin
from v5 to v10.patterns
.replaceML5Reference
to useendsWith('.html')
instead of a regex. There is no reason other than that I like it better!uglifyjs-webpack-plugin
withterser-webpack-plugin
new TerserPlugin
syntax with aninclude
option in order to apply minification toml5.min.js
only.webpack-dev-server
from v3 to v4.disableHostCheck
option was removed in favorallowedHosts: 'all'
"contentBase
/watchContentBase
options were moved tostatic
option"extract-text-webpack-plugin
.html-webpack-plugin
from v3 to v5.webpack-cli
from v2 to v4.webpack-merge
from v4 to v5.karma-webpack
from v3 to v5.Babel
useBuiltIns
option onpreset-env
as suggested by @joeyklee"usage"
. Maybe"entry"
is safer? But we pretty much have one single entry point so it's probably the same.indexEntryWithBabel
as it is no longer needed:@babel/preset-env
, IfuseBuiltIns: 'usage'
is specified in.babelrc
then do not include@babel/polyfill
in eitherwebpack.config.js
entry array nor source. Note,@babel/polyfill
still needs to be installed."corejs
version option and installedcore-js
package directly (instead of via@babel/polyfill
)@babel/polyfill
which is deprecated.core-js/stable
(to polyfill ECMAScript features) andregenerator-runtime/runtime
(needed to use transpiled generator functions)"package.json
. I do not know if there is any difference between having it there or in the webpack file.Eslint
eslint-loader
witheslint-webpack-plugin
, as explained above.eslint
v4 to v8eslint-config-airbnb-base
v12 to v15eslint-config-prettier
: v4 to v8eslint-nibble
v5 to v8eslint-plugin-import
minor version bumparrow-body-style
import/no-useless-path-segments
no-constructor-return
no-else-return
default-param-last
prefer-regex-literals
prefer-object-spread
lines-between-class-members
Karma
Karma was somewhat of an afterthought here, as we seem to be moving away from it in favor of Jest. However we do use webpack in our Karma setup so the webpack changes broke things.
karma.conf.js
instead of copy and pasting.const webpackConfig = require("./webpack.common.babel");
require
andmodule.exports
) in the webpack config file.optimization: { minimize: false }
.KARMA TESTS DO NOT WORK WITH THIS PR
The tests are not able to access the global
ml5
variable and get errors likeTypeError: Cannot destructure property 'neuralNetwork' of 'ml5' as it is undefined.
I got to this issue and didn't bother fixing it because I am of the opinion that we should move away from using a globalml5
in tests anyways. This has already been changed in #1345.🤷♀️ I merged in PR #1345 but the
import
syntax does not work with karma. Neither doesrequire
.