From 6f259003eb91999b22f7681e581be1b9ceb92eb2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 31 Jul 2017 19:30:26 -0400 Subject: [PATCH 1/4] Run all bare files before requiring eager entry point modules. --- tools/isobuild/linker.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/isobuild/linker.js b/tools/isobuild/linker.js index d117fb88f7..8e62c3e8db 100644 --- a/tools/isobuild/linker.js +++ b/tools/isobuild/linker.js @@ -398,6 +398,9 @@ _.extend(Module.prototype, { // Now that we have installed everything in this package or // application, immediately require the non-lazy modules and // evaluate the bare files. + + const eagerModuleFiles = []; + _.each(this.files, file => { if (file.bare) { chunks.push("\n", file.getPrelinkedOutput({ @@ -405,6 +408,12 @@ _.extend(Module.prototype, { noLineNumbers: this.noLineNumbers })); } else if (moduleCount > 0 && ! file.lazy) { + eagerModuleFiles.push(file); + } + }); + + if (eagerModuleFiles.length > 0) { + _.each(eagerModuleFiles, file => { if (file.mainModule) { exportsName = "exports"; } @@ -415,8 +424,8 @@ _.extend(Module.prototype, { JSON.stringify("./" + file.installPath), ");" ); - } - }); + }); + } return exportsName; } From a4d9f8c0f81cb2f6338e1ea4496e73551a7834ec Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 2 Aug 2017 15:13:18 -0400 Subject: [PATCH 2/4] Fix comments about bare files and add a note to History.md. --- History.md | 6 ++++++ tools/isobuild/linker.js | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/History.md b/History.md index 113cb7a099..66611a6eab 100644 --- a/History.md +++ b/History.md @@ -24,6 +24,12 @@ [Issue #5121](https://github.com/meteor/meteor/issues/5121) [PR #8917](https://github.com/meteor/meteor/pull/8917) +* Files contained by `client/compatibility/` directories or added with + `api.addFiles(files, ..., { bare: true })` are now evaluated before + importing modules with `require`, which may be a breaking change if you + depend on the interleaving of `bare` files with eager module evaluation. + [PR #8972](https://github.com/meteor/meteor/pull/8972) + ## v1.5.1, 2017-07-12 * Node has been upgraded to version 4.8.4. diff --git a/tools/isobuild/linker.js b/tools/isobuild/linker.js index 8e62c3e8db..5a7b09fa60 100644 --- a/tools/isobuild/linker.js +++ b/tools/isobuild/linker.js @@ -233,8 +233,8 @@ _.extend(Module.prototype, { _.each(this.files, file => { if (file.bare) { - // Bare files will be added in between the synchronous require - // calls in _chunkifyEagerRequires. + // Bare files will be added before the synchronous require calls + // in _chunkifyEagerRequires. return; } @@ -384,10 +384,9 @@ _.extend(Module.prototype, { }, // Adds require calls to the chunks array for all modules that should be - // eagerly evaluated, and also includes bare files in the appropriate - // order with respect to the require calls. Returns the name of the - // variable that holds the main exports object, if api.mainModule was - // used to define a main module. + // eagerly evaluated, and also includes any bare files before the + // require calls. Returns the name of the variable that holds the main + // exports object, if api.mainModule was used to define a main module. _chunkifyEagerRequires(chunks, moduleCount, sourceWidth) { assert.ok(_.isArray(chunks)); assert.ok(_.isNumber(moduleCount)); @@ -396,8 +395,8 @@ _.extend(Module.prototype, { let exportsName; // Now that we have installed everything in this package or - // application, immediately require the non-lazy modules and - // evaluate the bare files. + // application, first evaluate the bare files, then require the + // non-lazy (eager) modules. const eagerModuleFiles = []; From b061f4b765b0544ca17295e17bff0df8b7a6f581 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 4 Aug 2017 08:50:55 -0400 Subject: [PATCH 3/4] Increase mongo connection timeout to reduce self-test mongo errors. Certain self-test's like "modules - test app" are encountering mongo connection timeout errors on some runs. Increasing the connection timeout helps address these errors. --- tools/runners/run-mongo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/runners/run-mongo.js b/tools/runners/run-mongo.js index e3cf6b3a53..b3d93ea412 100644 --- a/tools/runners/run-mongo.js +++ b/tools/runners/run-mongo.js @@ -593,7 +593,7 @@ var launchMongo = function (options) { 'meteor', new mongoNpmModule.Server('127.0.0.1', options.port, { poolSize: 1, - socketOptions: {connectTimeoutMS: 30000}, + socketOptions: {connectTimeoutMS: 60000}, }), {safe: true}); From b1fd243978e208a5b1ac70ee53167ad0485003de Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 4 Aug 2017 08:57:25 -0400 Subject: [PATCH 4/4] Reduce the "modules - test app" self-test start-up wait time. The increased mongo connection timeout in 522d86dc4e71c49241abe794bb01f05adc0882cc means that the we can decrease the "modules - test app" self-test application start-up wait internval significantly (since mongo will now start properly and the self-test can continue). --- tools/tests/modules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tests/modules.js b/tools/tests/modules.js index c9fac18c9b..5fa92593d2 100644 --- a/tools/tests/modules.js +++ b/tools/tests/modules.js @@ -24,7 +24,7 @@ selftest.define("modules - test app", function () { "--driver-package", "dispatch:mocha-phantomjs" ); - run.waitSecs(180); + run.waitSecs(60); run.match("App running at"); run.match("SERVER FAILURES: 0"); run.match("CLIENT FAILURES: 0");