diff --git a/History.md b/History.md index ccfed32a64..54761ce421 100644 --- a/History.md +++ b/History.md @@ -53,6 +53,12 @@ * The `"env"` field is now supported in `.babelrc` files. [PR #8963](https://github.com/meteor/meteor/pull/8963) +* 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 d117fb88f7..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,11 @@ _.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 = []; + _.each(this.files, file => { if (file.bare) { chunks.push("\n", file.getPrelinkedOutput({ @@ -405,6 +407,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 +423,8 @@ _.extend(Module.prototype, { JSON.stringify("./" + file.installPath), ");" ); - } - }); + }); + } return exportsName; } 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}); 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");