Skip to content

Commit

Permalink
Allow to exclude web architectures in development mode
Browse files Browse the repository at this point in the history
This commit implements an --exclude-archs arg to the run command
which allows you to pass a comma-seperated list of architectures
to exclude.

Motivation:
Improve rebuild speeds, by allowing to leave out certain
web architectures during development.

Meteor rebuild speeds, although greatly improved in recent versions,
is still a common point of frustration as seen in the issues (meteor#10800)
and on the forum (https://forums.meteor.com/t/2x-to-3x-longer-build-time-also-on-testing-since-1-8-2-update/51028/3)

One reason for slow rebuilds is high memory pressure (meteor#9568).
The web.browser.legacy architecture is currently always being build
while most of us will only test this every once in a while.
So while we don't need it most of times during development
it does add to the high memory usage.
Furthermore, even though these builds are delayed,
long-running synchronous tasks have the potential to block the server startup (meteor#10261).
This last issue can be partially, but not fully, improved by meteor#10427
Therefore a commonly requested feature has been to disable the legacy build (meteor/meteor-feature-requests#333)

However, we may also temporarily disable cordova builds
and we may even want to disable just the web.browser build if we're just debugging
a bug in the legacy build.
Therefore I chose to create the more generic --exclude-archs option.
  • Loading branch information
sebakerckhof authored and Ben Newman committed Jan 13, 2020
1 parent ff2ecf2 commit 4c1a736
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 13 deletions.
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ N/A

* The `typescript` npm package has been updated to version 3.7.3.

* You can now use the `--exclude-archs` CLI argument for the run and test
commands to temporarily disable building certain web architectures.
For example: `meteor run --exclude-archs web.browser.legacy`.
You can pass multiple architectures comma seperated.
This can be used to improve rebuild times if you're not actively testing
those architectures during development.

## v1.8.2, 2019-11-14

### Breaking changes
Expand Down
23 changes: 12 additions & 11 deletions packages/appcache/appcache-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@ function eachResource({
}

function sizeCheck() {
const sizes = [ // Check size of each known architecture independently.
const RESOURCE_SIZE_LIMIT = 5 * 1024 * 1024; // 5MB
const largeSizes = [ // Check size of each known architecture independently.
"web.browser",
"web.browser.legacy",
].reduce((filt, arch) => {
].filter((arch) => !!WebApp.clientPrograms[arch])
.map((arch) => {
let totalSize = 0;

WebApp.clientPrograms[arch].manifest.forEach(resource => {
Expand All @@ -265,22 +267,21 @@ function sizeCheck() {
}
});

if (totalSize > 5 * 1024 * 1024) {
filt.push({
arch,
size: totalSize
});
return {
arch,
size: totalSize,
}
return filt;
}, []);
if (sizes.length > 0) {
})
.filter(({ size }) => size > RESOURCE_SIZE_LIMIT);

if (largeSizes.length > 0) {
Meteor._debug([
"** You are using the appcache package, but the size of",
"** one or more of your cached resources is larger than",
"** the recommended maximum size of 5MB which may break",
"** your app in some browsers!",
"** ",
...sizes.map(data => `** ${data.arch}: ${(data.size / 1024 / 1024).toFixed(1)}MB`),
...largeSizes.map(data => `** ${data.arch}: ${(data.size / 1024 / 1024).toFixed(1)}MB`),
"** ",
"** See http://docs.meteor.com/#appcache for more",
"** information and fixes."
Expand Down
19 changes: 19 additions & 0 deletions packages/webapp/webapp_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ WebAppInternals.staticFilesMiddleware = async function (
identifyBrowser(req.headers["user-agent"]),
);

if (! hasOwn.call(WebApp.clientPrograms, arch)) {
// We could come here in case we run with some architectures excluded
next();
return;
}

// If pauseClient(arch) has been called, program.paused will be a
// Promise that will be resolved when the program is unpaused.
const program = WebApp.clientPrograms[arch];
Expand Down Expand Up @@ -985,6 +991,19 @@ function runWebAppServer() {
request.browser,
);

if (! hasOwn.call(WebApp.clientPrograms, arch)) {
// We could come here in case we run with some architectures excluded
headers['Cache-Control'] = 'no-cache';
res.writeHead(404, headers);
if (Meteor.isDevelopment) {
res.end(`No client program found for the ${arch} architecture.`);
} else {
// Safety net, but this branch should not be possible.
res.end("404 Not Found");
}
return;
}

// If pauseClient(arch) has been called, program.paused will be a
// Promise that will be resolved when the program is unpaused.
await WebApp.clientPrograms[arch].paused;
Expand Down
23 changes: 21 additions & 2 deletions tools/cli/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ export function parseRunTargets(targets) {
});
};

const excludableWebArchs = ['web.browser', 'web.browser.legacy', 'web.cordova'];
function filterWebArchs(webArchs, excludeArchsOption) {
if (excludeArchsOption) {
const excludeArchs = excludeArchsOption.trim().split(/\s*,\s*/)
.filter(arch => excludableWebArchs.includes(arch));
webArchs = webArchs.filter(arch => !excludeArchs.includes(arch));
}
return webArchs;
}

///////////////////////////////////////////////////////////////////////////////
// options that act like commands
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -318,7 +328,8 @@ var runCommandOptions = {
// Allow the version solver to make breaking changes to the versions
// of top-level dependencies.
'allow-incompatible-update': { type: Boolean },
'extra-packages': { type: String }
'extra-packages': { type: String },
'exclude-archs': { type: String }
},
catalogRefresh: new catalog.Refresh.Never()
};
Expand Down Expand Up @@ -399,6 +410,7 @@ function doRunCommand(options) {
webArchs.push("web.cordova");
}
}
webArchs = filterWebArchs(webArchs, options['exclude-archs']);

let cordovaRunner;
if (!_.isEmpty(runTargets)) {
Expand Down Expand Up @@ -1635,7 +1647,9 @@ testCommandOptions = {
// For 'test-packages': Run in "full app" mode
'full-app': { type: Boolean, 'default': false },

'extra-packages': { type: String }
'extra-packages': { type: String },

'exclude-archs': { type: String }
}
};

Expand Down Expand Up @@ -1978,6 +1992,11 @@ var runTestAppForPackages = function (projectContext, options) {
minifyMode: options.production ? 'production' : 'development'
};
buildOptions.buildMode = "test";
let webArchs = projectContext.platformList.getWebArchs();
if (options.cordovaRunner) {
webArchs.push("web.cordova");
}
buildOptions.webArchs = filterWebArchs(webArchs, options['exclude-archs']);

if (options.deploy) {
// Run the constraint solver and build local packages.
Expand Down
6 changes: 6 additions & 0 deletions tools/cli/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ Options:
version constraints.
--extra-packages Run with additional packages (comma separated, for example:
--extra-packages "package-name1, [email protected]")
--exclude-archs Don't create bundles for certain web architectures
(comma separated, for example:
--exclude-archs "web.browser.legacy, web.cordova")

>>> debug
Run the project with server-side debugging enabled.
Expand Down Expand Up @@ -713,6 +716,9 @@ Options:
--driver-package Name of the optional test driver package to use to run
tests and display results. For example:
--driver-package practicalmeteor:mocha
--exclude-archs Don't create test bundles for certain web architectures
(comma separated, for example:
--exclude-archs "web.browser.legacy, web.cordova")

>>> self-test
Run tests of the 'meteor' tool.
Expand Down

0 comments on commit 4c1a736

Please sign in to comment.