gristlabs_grist-core/buildtools/webpack.config.js
Paul Fitzpatrick bcbf57d590 (core) bump mocha version to allow parallel tests; move more tests to core
Summary:
This uses a newer version of mocha in grist-core so that tests can be run in parallel. That allows more tests to be moved without slowing things down overall. Tests moved are venerable browser tests; only the ones that "just work" or worked without too much trouble to are moved, in order to keep the diff from growing too large. Will wrestle with more in follow up.

Parallelism is at the file level, rather than the individual test.

The newer version of mocha isn't needed for grist-saas repo; tests are parallelized in our internal CI by other means. I've chosen to allocate files to workers in a cruder way than our internal CI, based on initial characters rather than an automated process. The automated process would need some reworking to be compatible with mocha running in parallel mode.

Test Plan: this diff was tested first on grist-core, then ported to grist-saas so saas repo history will correctly track history of moved files.

Reviewers: jarek

Reviewed By: jarek

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D3927
2023-06-27 02:55:34 -04:00

89 lines
2.9 KiB
JavaScript

const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const { ProvidePlugin } = require('webpack');
const path = require('path');
// Get path to top-level node_modules if in a yarn workspace.
// Otherwise node_modules one level up won't get resolved.
// This is used in Electron packaging.
const base = path.dirname(path.dirname(require.resolve('grainjs/package.json')));
module.exports = {
target: 'web',
entry: {
main: "app/client/app",
errorPages: "app/client/errorMain",
account: "app/client/accountMain",
billing: "app/client/billingMain",
activation: "app/client/activationMain",
test: "test/client-harness/client",
},
output: {
filename: "[name].bundle.js",
sourceMapFilename: "[file].map",
path: path.resolve("./static"),
// Workaround for a known issue with webpack + onerror under chrome, see:
// https://github.com/webpack/webpack/issues/5681
// "We use a source map plugin here with this special configuration
// because if we do not - the window.onerror function does not work properly in chrome
// and it swallows the errors because normally source maps have begin with webpack:///
// here we are changing how the module file names are created
// See this bug
// https://bugs.chromium.org/p/chromium/issues/detail?id=765909
// See this for syntax
// https://webpack.js.org/configuration/output/#output-devtoolmodulefilenametemplate
// "
devtoolModuleFilenameTemplate: "[resourcePath]?[loaders]",
crossOriginLoading: "anonymous",
},
// This creates .map files, and takes webpack a couple of seconds to rebuild while developing,
// but provides correct mapping back to typescript, and allows breakpoints to be set in
// typescript ("cheap-module-eval-source-map" is faster, but breakpoints are largely broken).
devtool: "source-map",
resolve: {
extensions: ['.ts', '.js'],
modules: [
path.resolve('.'),
path.resolve('./ext'),
path.resolve('./stubs'),
path.resolve('./node_modules'),
base,
],
fallback: {
'path': require.resolve("path-browserify"),
},
},
module: {
rules: [
{
test: /\.(js|ts)?$/,
loader: 'esbuild-loader',
options: {
loader: 'ts',
target: 'es2017',
sourcemap: true,
},
exclude: /node_modules/
},
{ test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}
]
},
plugins: [
// Some modules assume presence of Buffer and process.
new ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
}),
// To strip all locales except “en”
new MomentLocalesPlugin()
],
externals: {
// for test bundle: jsdom should not be touched within browser
jsdom: 'alert',
// for test bundle: jquery will be available as jQuery
jquery: 'jQuery'
},
};