Commit graph

30 commits

Author SHA1 Message Date
Stephen Niedzielski c8c93d0859 Hygiene: replace deprecated Webpack plugin
Replace NamedModulesPlugin with `optimisations.namedModules = true`. Not
to be confused with `optimization.namedModules` which is deprecated.

https://github.com/webpack/webpack/releases/tag/v4.0.0
https://github.com/webpack/webpack/releases/tag/v4.16.0

Bug: T212527
Change-Id: Ie5c7b74e294b012f270de8a6ebc660bf5e75d478
2019-01-07 19:00:01 +00:00
Stephen Niedzielski a922331d36 Hygiene: remove unused Webpack plugins
Remove the LoaderOptionsPlugin and DefinePlugin from the Webpack
configuration. These plugins *do not* alter production or development
build products or appear to impact Redux interaction.

Bug: T212527
Change-Id: I4ca2bde2346011167f86f7f4a331048a2e92263b
2019-01-03 20:02:45 +00:00
Stephen Niedzielski 81a2f4acb0 Hygiene: copy MobileFrontend Webpack learnings
Copy learnings from MobileFrontend's Webpack configuration. If nothing
else, the files are more consistent and easier to diff. When the change
to rename source maps is excluded, the build products are identical.

The following changes were copied:

- DRY up the output directory and source map extension as variables. For
  the latter, rename the source map from ".json" to ".map.json". Without
  renaming, the build products are unchanged.
- Reduce verbosity. Only report warnings and errors.
- Fail to build when an error occurs.
- Update ordering and add comments for easier reasoning and diffing with
  MobileFrontend.

Bug: T212527
Change-Id: Icf11dff91358ad021932aa209c65ed8aac77d12b
2019-01-02 21:30:12 +00:00
Shreyas Minocha 22226f3367
Switch from babel-preset-env to @babel/preset-env
Replace:
    - babel-preset-env@1.6.0 with @babel/preset-env@7.2.0
    - babel-register@6.24.1 with @babel/register@7.0.0
    - babel-loader@7.1.4 with babel-loader@8.0.4

Add:
    - @babel/core@7.2.0

---

- babel-preset-env, @babel/preset-env
  babel-preset-env moved to @babel/preset-env in the Babel monorepo.
  This appears to have incremented the version from v1.6.0[0] to 7.x to
  match the rest of the Babel packages but appears to otherwise be
  undocumented.[1,3]

  [0] https://github.com/babel/babel-preset-env/blob/24b99ec/README.md
  [1] https://github.com/babel/babel/blob/efa571a/CHANGELOG.md

- @babel/preset-env, @babel/register
  *Many* changes as identified by package [2] and summarized [3].

  Node.js v6 or above now required.

  New dependency on @babel/core.

  Support for ES2018 and browserslist v4.

  `modules: false` is now the default for preset-env + babel-loader. The
  .babelrc has been updated.

  New babel-upgrade tool.

  babel.config.js can replace .babelrc. Popups doesn't seem to need it.

  TypeScript and JSX fragment support.

  [2] https://github.com/babel/babel/blob/efa571a/CHANGELOG.md
  [3] https://babeljs.io/blog/2018/08/27/7.0.0

- babel-loader
  Support for Babel 7.x.

  The following warning is printed when building but perhaps this is due
  to another dependency:

    (node:14559) DeprecationWarning: loaderUtils.parseQuery() received a
    non-string value which can be problematic, see
    https://github.com/webpack/loader-utils/issues/56 parseQuery() will
    be replaced with getOptions() in the next major version of
    loader-utils.

  https://github.com/webpack/loader-utils/issues/56#issuecomment-286117000
  https://github.com/babel/babel-loader/releases/tag/v7.1.5
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.0
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.1
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.2
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.3
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.4
  (v8.0.0-beta.5 was erroneous.)
  https://github.com/babel/babel-loader/releases/tag/v8.0.0-beta.6
  https://github.com/babel/babel-loader/releases/tag/v8.0.0
  https://github.com/babel/babel-loader/releases/tag/v8.0.1
  https://github.com/babel/babel-loader/releases/tag/v8.0.2
  https://github.com/babel/babel-loader/releases/tag/v8.0.3
  https://github.com/babel/babel-loader/releases/tag/v8.0.4

Bug: T197883
Change-Id: Ie3a5404630fde87ea7fe618a842950ed8c0c6494
2018-12-11 13:09:45 +05:30
Stephen Niedzielski fe2c3b23ee Hygiene: replace call to rm with clean-webpack-plugin
The invocation of `rm -rf resources/dist` in package.json
(`check-built-assets`) is replaced with clean-webpack-plugin.
The benefit of this change is that calling `npm run build` now works the
same as the `check-built-assets` script.

Bug: T193522
Change-Id: I64f048855ddceb7159279671b2174a7937e169ff
2018-06-18 09:09:28 -05:00
Stephen Niedzielski 367b12a278 Hygiene: bump ESLint to ES6 and lint more files
- Bump the ESLint configuration ECMAScript 2015 given that we use Babel
  and have a safeguard to verify build products are ES5.

- Lint more files including all tests and the Webpack and Grunt configs.

Change-Id: I099cbe009eda2349ddc051976ace0d9f6c55fa30
2018-05-01 14:47:51 -05:00
jdlrobson bb2ad2ed38 Up the max asset and entry point sizes
40kb seems a good time to pause and reflect on the total size.
The current maximum is impossible to meet without no further
changes to the code.

12kb is also more flexible than 11.5

Change-Id: I5ee8c236d90542afacc0e8de513a45a15ccd529b
2018-03-27 12:57:17 -07:00
Stephen Niedzielski c4b50b04ac Hygiene: remove unused resources
In I7395e3438836149becdd576942bdaf6f21b4163f the settings templates
were rewritten so that they no longer displayed an image.

descriptionText and images were dropped from the template but not from
the template provider. These are artifacts from relating to that patch
and are no longer used.

Change-Id: I1be7ef288d37f338e83dab3cf041e628a06608d2
2018-03-21 17:07:18 -05:00
Stephen Niedzielski 0bee0906d4 Hygiene: replace var with let and const
eslint \
    --cache \
    --max-warnings 0 \
    --report-unused-disable-directives \
    --fix \
    src tests

Change-Id: I051275126ae7fa9affd16c2504017c0584f2d9c7
2018-03-20 14:14:02 -05:00
Stephen Niedzielski 42816702eb Hygiene: replace Mustache templates w/ ES6 strings
Replace Mustache.js templates with template literals. An effort was made
to minimize additional refactoring, so feel free to ask for more but it
ain't coming in this PS.

Bug: T165036
Change-Id: I4a6a1d93a2922c3a9ef3ae93c47da17a35c644f0
2018-03-20 08:06:02 -05:00
Stephen Niedzielski e5df865d51 Hygiene: enable Babel transpilation
Enable the Babel transpiler so that ES6 template literals,
destructuring, and arrow functions can be used in production.
"last n versions" syntax was not used so that builds are more
reproducible.

Bug: T165036
Change-Id: I553b6d14cc368c7b4366f68d13038c3d505f5429
2018-03-20 07:59:14 -05:00
Stephen Niedzielski d35286a064 Update: upgrade to Webpack 4 & improve output size
Upgrade from Webpack v2.0.12 to v4.1.1. There have been many changes to
Webpack... Noticeable in the bundle size is that a number of files are
now inlined and generally minification is improved.

Changes related to the upgrade include:

- Remove unsupported UglifyJS options which link back to T188081. These
  appear to have been anticipatory but never acted on and it isn't clear
  whether they even worked or not.
- Pass the -p plag for production optimizations; pass the -d flag since
  production doesn't support watching.
- NamedModulesPlugin is now on by default but only in development mode
  so no change was made.
- Webpack command line client now must be installed separated and
  appears in package.json as webpack-cli.

https://github.com/webpack/webpack/releases/tag/v2.2.0
https://github.com/webpack/webpack/releases/tag/v2.2.1
https://github.com/webpack/webpack/releases/tag/v2.3.0
https://github.com/webpack/webpack/releases/tag/v2.3.1
https://github.com/webpack/webpack/releases/tag/v2.3.2
https://github.com/webpack/webpack/releases/tag/v2.3.3
https://github.com/webpack/webpack/releases/tag/v2.4.0
https://github.com/webpack/webpack/releases/tag/v2.4.1
https://github.com/webpack/webpack/releases/tag/v2.5.0
https://github.com/webpack/webpack/releases/tag/v2.5.1
https://github.com/webpack/webpack/releases/tag/v2.6.0
https://github.com/webpack/webpack/releases/tag/v2.6.1
https://github.com/webpack/webpack/releases/tag/v3.0.0
https://github.com/webpack/webpack/releases/tag/v3.1.0
https://github.com/webpack/webpack/releases/tag/v3.2.0
https://github.com/webpack/webpack/releases/tag/v3.3.0
https://github.com/webpack/webpack/releases/tag/v3.4.0
https://github.com/webpack/webpack/releases/tag/v3.4.1
https://github.com/webpack/webpack/releases/tag/v3.5.0
https://github.com/webpack/webpack/releases/tag/v3.5.1
https://github.com/webpack/webpack/releases/tag/v3.5.2
https://github.com/webpack/webpack/releases/tag/v3.5.3
https://github.com/webpack/webpack/releases/tag/v3.5.4
https://github.com/webpack/webpack/releases/tag/v3.5.5
https://github.com/webpack/webpack/releases/tag/v3.5.6
https://github.com/webpack/webpack/releases/tag/v3.6.0
https://github.com/webpack/webpack/releases/tag/v3.7.0
https://github.com/webpack/webpack/releases/tag/v3.7.1
https://github.com/webpack/webpack/releases/tag/v3.8.0
https://github.com/webpack/webpack/releases/tag/v3.8.1
https://github.com/webpack/webpack/releases/tag/v3.9.0
https://github.com/webpack/webpack/releases/tag/v3.9.1
https://github.com/webpack/webpack/releases/tag/v3.10.0
https://github.com/webpack/webpack/releases/tag/v3.11.0
https://github.com/webpack/webpack/releases/tag/v4.0.0
https://medium.com/webpack/webpack-4-released-today-6cdb994702d4
https://github.com/webpack/webpack/releases/tag/v4.0.1
https://github.com/webpack/webpack/releases/tag/v4.1.0
https://github.com/webpack/webpack/releases/tag/v4.1.1

Bug: T165036
Change-Id: Ic146e680d368fee7ee207b484460ce94f8bd7283
2018-03-20 07:55:37 -05:00
Stephen Niedzielski a836890788 Hygiene: add Webpack performance requirements
Webpack has some simple but useful options for specifying performance
limits. This patch enables asset and entry point (+ all dependencies)
filesize requirements for production builds. This helps us track
minified but uncompressed filesizes which are reported by
mw.loader.inspect() (including CSS).

https://webpack.js.org/configuration/performance/

Bug: T165036
Change-Id: I331ff34f50270be2912fd8cef5219cafc6957e80
2018-03-19 09:39:53 -05:00
Stephen Niedzielski 4eb9c0efa8 Hygiene: move SVG string to file
- Add SVG Inline Loader for Webpack. This allows SVG files to be
  imported.

- Update the Webpack and test configurations to use the new loader.

- Scope the ESLint rules down to just JavaScript files so that linting
  isn't attempted on the SVG.

Bug: T165036
Change-Id: I00bccff4c3167975c19d577be6343dcaca7ddb2d
2018-03-14 12:04:28 -07:00
joakin 0502d90f60 Hygiene: Consistent quotes in webpack.config.js
Change-Id: Id1315f3dad411aad1395642c6fcb2b781503de73
2018-02-26 12:38:41 +01:00
joakin 5154739a46 Hygiene: Add comment about @nomin and source-maps in production
Clarify why we don't have source maps in production and the interaction
with ResourceLoader's production mode, and reference phab task.

Bug: T188081
Change-Id: I4c5f60585429792ee3047268ad44449ab47fcff4
2018-02-26 12:36:46 +01:00
jdlrobson 14e78466b2 Do not include @nomin instruction in dist build
When bundled by ResourceLoader this can interfere with debugging
of other concatenated files.

The nomin instruction introduced in 7bd29bb058
was meant to avoid RL minifying an already
uglified bundle, but that shouldn't matter here.

Bug: T177344
Change-Id: I90829668544e7c4ff7ddfdbb90d91b88a27a69f4
2017-10-11 14:34:18 -07:00
Piotr Miazga f8498ce70c Store map files under .json extension
We cannot serve .map files from production servers. This makes
Popups extension difficult to debug. As a simplest solution we
decided to store map files as .json files so we can easily access
js maps files.

Changes:
 - changed webpack config to store map files under .json extension

Bug: T173491
Change-Id: Iaa55f75a8c5f3e8f1f169b3ac33241cc54f0413f
2017-08-29 21:18:35 +02:00
joakin 7bd29bb058 Enable production settings for the production bundle
It enables certain optimizations, see:
* https://webpack.js.org/guides/production-build/

Code is minified by uglifyjs.

Aditional changes:
* Add banner so that sources are not minified by ResourceLoader

Bug: T160061
Change-Id: I50c9148ebf2d860db42a24225bc128bfcfe56927
2017-05-11 10:37:45 +02:00
joakin 9ff7ecebc5 Hygiene: Make webpack.config.js conform to eslint
Bug: T160061
Change-Id: I81ccdb34108660b7f3637d6cb17aa4e3a84c68f5
2017-05-10 20:52:07 +02:00
Sam Smith 29df4b11be build: Make webpack config compatible with v2.3.0
webpack@2.3.0 expects the output.filename config variable to be a
relative path.

Change-Id: If82a0d6d69e0400c1d5b5722ea7dd6bd55160204
2017-03-22 11:32:35 +00:00
joakin eff14acbba Tooling: Use latest stable webpack
Webpack 1.14.0 is an old version, switch to using latest stable which
has better documentation, tree shaking, ES2015 modules and a core team
of contributors with funding. See https://webpack.js.org/

Additional changes:
* Recompile the frontend assets

Change-Id: I2c5940276e99dee104d04c6a0b83d8ab36a99df5
2017-03-08 19:27:40 +01:00
joakin 1b81d0fdfa Bundle dist versions of redux and redux-thunk
Instead of importing the modules from sources (which you should do if
you properly define NODE_ENV and use uglifyjs from webpack) import the
already compiled files on the npm packages.

This results in 5kb less on the compiled bundle.

Change-Id: I83732ea79a59b611c117ddcf4c262948c795f642
2017-03-08 12:41:03 +01:00
joakin fa2b10a2e7 Hygiene: Move build/ext.popups/ to src/
This way, src contains sources, and dist contains distribution files.

Also, add some documentation about the folders in the README and an adr.

Change-Id: Ie0b9f6475b8423b90e927633d883bde3cd5d5e4d
2017-02-14 09:59:59 -08:00
joakin ba4844cdc2 Tooling: Separate built resources from RL resources
In order to automatically verify in CI that the built assets are up to
date with the commited sources, we need to keep the built assets in
a folder separate from the RL assets.

* Rename the compiled assets folder to industry standard `dist`

Change-Id: I8c5898f9bb29fee7164a7038b835a5f7efd33dbc
2017-02-14 18:39:38 +01:00
jdlrobson 20e7564bed Webpack: Complete transition to webpack for ext.popups module
boot.js is renamed to index.js and popups is now bundled
up inside popups.js

To support qunit tests, the library is still exposed as
mw.popups with a FIXME to remove later when it is no longer
necessary

Bug: T156333
Change-Id: Ieb6b4b0344af2701f99ef0fcc786d2378fd2fceb
2017-02-13 13:48:52 +01:00
jdlrobson 93b2428895 webpack: Build gateway via webpack
Bug: T156333
Change-Id: Ifbb696c5e615679c2c61bde7df7224bd5e55fcdb
2017-02-13 13:42:22 +01:00
jdlrobson c6ca8f173f Webpack: Build previews with webpack
Change-Id: Ieb9e3bf1bee550e4234a5796c0b51405ba458b1f
2017-02-13 13:42:22 +01:00
jdlrobson 915bf23627 Hygiene: Reducers packaged via webpack
Bug: T156333
Change-Id: I14b0a9faf063ac7e89b7a012fb47d27ef4ed9d82
2017-02-13 13:42:22 +01:00
jdlrobson 49df4b9572 Tooling: Begin to use webpack for JS code generation
Generate changeListeners via webpack
We now use a build folder to build the JavaScript for
our ResourceLoader modules. This is the first change
in a line of changes.
A source map is provided for debug support.

Bug: T156333
Change-Id: I771843d1ddb4b50adedc3fa53b30c2f1d8a76acb
2017-02-13 13:42:22 +01:00