2019-03-07 20:31:55 +00:00
|
|
|
/* eslint-env node */
|
2020-04-27 18:58:30 +00:00
|
|
|
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
|
2019-03-07 20:31:55 +00:00
|
|
|
const path = require( 'path' );
|
2019-02-19 13:09:52 +00:00
|
|
|
|
2019-03-07 20:31:55 +00:00
|
|
|
const PUBLIC_PATH = '/w/extensions/Popups';
|
2017-05-08 18:50:59 +00:00
|
|
|
|
2018-10-05 17:15:43 +00:00
|
|
|
const distDir = path.resolve( __dirname, 'resources/dist' );
|
|
|
|
|
|
|
|
// The extension used for source map files.
|
|
|
|
const srcMapExt = '.map.json';
|
|
|
|
|
2019-03-07 20:31:55 +00:00
|
|
|
module.exports = ( env, argv ) => ( {
|
2018-10-05 17:15:43 +00:00
|
|
|
// Apply the rule of silence: https://wikipedia.org/wiki/Unix_philosophy.
|
|
|
|
stats: {
|
|
|
|
all: false,
|
2019-01-14 21:16:22 +00:00
|
|
|
// Output a timestamp when a build completes. Useful when watching files.
|
|
|
|
builtAt: true,
|
2018-10-05 17:15:43 +00:00
|
|
|
errors: true,
|
|
|
|
warnings: true
|
|
|
|
},
|
|
|
|
|
|
|
|
// Fail on the first build error instead of tolerating it for prod builds. This seems to
|
|
|
|
// correspond to optimization.noEmitOnErrors.
|
2019-03-07 20:31:55 +00:00
|
|
|
bail: argv.mode === 'production',
|
2018-10-05 17:15:43 +00:00
|
|
|
|
|
|
|
// Specify that all paths are relative the Webpack configuration directory not the current
|
|
|
|
// working directory.
|
|
|
|
context: __dirname,
|
|
|
|
|
|
|
|
entry: { index: './src' },
|
|
|
|
|
2019-03-07 20:31:55 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
redux: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
argv.mode === 'production' ?
|
|
|
|
'node_modules/redux/dist/redux.min.js' :
|
|
|
|
'node_modules/redux/dist/redux.js'
|
|
|
|
),
|
|
|
|
'redux-thunk': path.resolve(
|
|
|
|
__dirname,
|
|
|
|
argv.mode === 'production' ?
|
|
|
|
'node_modules/redux-thunk/dist/redux-thunk.min.js' :
|
|
|
|
'node_modules/redux-thunk/dist/redux-thunk.js'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [ {
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
// Beware of https://github.com/babel/babel-loader/issues/690. Changes to browsers require
|
|
|
|
// manual invalidation.
|
|
|
|
cacheDirectory: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
test: /\.svg$/,
|
|
|
|
loader: 'svg-inline-loader',
|
|
|
|
options: {
|
|
|
|
removeSVGTagAttrs: false // Keep width and height attributes.
|
|
|
|
}
|
|
|
|
} ]
|
|
|
|
},
|
2018-10-05 17:15:43 +00:00
|
|
|
optimization: {
|
|
|
|
// Don't produce production output when a build error occurs.
|
2019-03-07 20:31:55 +00:00
|
|
|
noEmitOnErrors: argv.mode === 'production',
|
2019-01-04 16:51:04 +00:00
|
|
|
|
|
|
|
// Use filenames instead of unstable numerical identifiers for file references. This
|
|
|
|
// increases the gzipped bundle size some but makes the build products easier to debug and
|
|
|
|
// appear deterministic. I.e., code changes will only alter the bundle they're packed in
|
|
|
|
// instead of shifting the identifiers in other bundles.
|
|
|
|
// https://webpack.js.org/guides/caching/#deterministic-hashes (namedModules replaces NamedModulesPlugin.)
|
|
|
|
namedModules: true
|
2018-10-05 17:15:43 +00:00
|
|
|
},
|
|
|
|
|
2017-01-26 21:31:41 +00:00
|
|
|
output: {
|
2019-03-07 20:31:55 +00:00
|
|
|
// Specify the destination of all build products.
|
2018-10-05 17:15:43 +00:00
|
|
|
path: distDir,
|
2017-01-26 21:31:41 +00:00
|
|
|
|
2019-03-07 20:31:55 +00:00
|
|
|
// Store outputs per module in files named after the modules. For the JavaScript entry
|
|
|
|
// itself, append .js to each ResourceLoader module entry name. This value is tightly
|
|
|
|
// coupled to sourceMapFilename.
|
2017-08-29 19:18:35 +00:00
|
|
|
filename: '[name].js',
|
2018-10-05 17:15:43 +00:00
|
|
|
|
|
|
|
// Rename source map extensions. Per T173491 files with a .map extension cannot be served
|
|
|
|
// from prod.
|
2019-03-07 20:31:55 +00:00
|
|
|
sourceMapFilename: `[file]${srcMapExt}`,
|
|
|
|
|
|
|
|
devtoolModuleFilenameTemplate: `${PUBLIC_PATH}/[resource-path]`
|
2017-01-26 21:31:41 +00:00
|
|
|
},
|
2018-10-05 17:15:43 +00:00
|
|
|
|
|
|
|
// Accurate source maps at the expense of build time. The source map is intentionally exposed
|
|
|
|
// to users via sourceMapFilename for prod debugging. This goes against convention as source
|
|
|
|
// code is publicly distributed.
|
|
|
|
devtool: 'source-map',
|
|
|
|
|
|
|
|
plugins: [
|
2019-03-07 20:31:55 +00:00
|
|
|
// Delete the output directory on each build.
|
2020-04-27 18:58:30 +00:00
|
|
|
new CleanWebpackPlugin( {
|
2020-06-22 21:49:14 +00:00
|
|
|
cleanOnceBeforeBuildPatterns: [ '**/*', '!.eslintrc.json' ]
|
2020-04-27 18:58:30 +00:00
|
|
|
} )
|
2018-10-05 17:15:43 +00:00
|
|
|
],
|
|
|
|
|
2018-03-16 17:56:40 +00:00
|
|
|
performance: {
|
2018-10-05 17:15:43 +00:00
|
|
|
// Size violations for prod builds fail; development builds are unchecked.
|
2019-03-07 20:31:55 +00:00
|
|
|
hints: argv.mode === 'production' ? 'error' : false,
|
2018-10-05 17:15:43 +00:00
|
|
|
|
|
|
|
// Minified uncompressed size limits for chunks / assets and entrypoints. Keep these numbers
|
|
|
|
// up-to-date and rounded to the nearest 10th of a kibibyte so that code sizing costs are
|
|
|
|
// well understood. Related to bundlesize minified, gzipped compressed file size tests.
|
Remove dead code around cog wheel dialogue
An "advanced" option was first introduced in 2014 via patch I374805e
(originally named "monitor-or-edit", renamed via patch I7b4f6d2).
The isNavPopupsEnabled() function was added in 2016 via patch
Ic660f48.
The code that disables the extension entirely the moment the NavPopups
gadget is enabled was added in 2017 via patch Ia474b1b (T151058) and
patch Ia837816 (T160081).
As of now, the "advanced" option can only be seen in an extreme edge
case:
* Only for anonymous users.
* Only if NavPopups is enabled by default for anonymous users.
* Only if the $wgPopupsConflictingNavPopupsGadgetName setting is
misconfigured.
* … or if NavPopups is not a gadget in the first place, but e.g.
loaded via Common.js.
In this situation the settings dialog opens with all *3* options. This
is broken for several reasons:
* The "simple" option enables the extension, but doesn't disable
NavPopups. Both trigger, resulting in both popups being displayed
the same time.
* Since "simple" is the default, this bogus behavior is the default
for anonymous users.
* The "off" option doesn't stick. Every time the settings dialog opens
"advanced" is checked instead.
* "Off" can't work anyway. There is no code to disable the gadget.
* Only the "advanced" option "works", but more by accident.
It's unclear how to fix this:
* There is no code that does anything with the "advanced" option. It's
not even stored. The behavior of the option is identical to "off".
* The code appears as if "advanced" was meant to be shown instead of
"off". I.e. anonymous users can only choose one of the popups, but
not disable both. But there is no code to hide the "off" option.
* The bug when both popups are displayed was fixed in 2017 via an
entirely different mechanism. Re-introducing "advanced" does not
only mean duplication, it's unclear how the 2 mechanisms are meant
to work together.
It really, really feels like this was just forgotten.
Bug: T278949
Change-Id: Iab21f3a649a5b2f19ebb0d0dbb45ce1450c65678
2021-02-08 16:53:51 +00:00
|
|
|
maxAssetSize: 44.0 * 1024,
|
|
|
|
maxEntrypointSize: 44.0 * 1024,
|
2018-10-05 17:15:43 +00:00
|
|
|
|
|
|
|
// The default filter excludes map files but we rename ours.
|
|
|
|
assetFilter: ( filename ) => !filename.endsWith( srcMapExt )
|
|
|
|
}
|
2019-03-07 20:31:55 +00:00
|
|
|
} );
|