diff --git a/tools/isobuild/import-scanner.js b/tools/isobuild/import-scanner.js index a259c30295..0ee4683f15 100644 --- a/tools/isobuild/import-scanner.js +++ b/tools/isobuild/import-scanner.js @@ -121,7 +121,8 @@ export default class ImportScanner { } getOutputFiles(options) { - return this.outputFiles; + // Return all installable output files. + return this.outputFiles.filter(file => !! file.installPath); } _findImportedModuleIdentifiers(file) { diff --git a/tools/isobuild/package-source.js b/tools/isobuild/package-source.js index fd0a0ae283..2652a16353 100644 --- a/tools/isobuild/package-source.js +++ b/tools/isobuild/package-source.js @@ -1316,6 +1316,16 @@ _.extend(PackageSource.prototype, { const fileOptions = {}; const dirs = files.pathDirname(relPath).split(files.pathSep); + // If the file is restricted to the opposite architecture, make sure + // it is not evaluated eagerly. + if (arch === "os") { + if (dirs.indexOf("client") >= 0) { + fileOptions.lazy = true; + } + } else if (dirs.indexOf("server") >= 0) { + fileOptions.lazy = true; + } + if (dirs.indexOf("node_modules") >= 0) { fileOptions.lazy = true; fileOptions.transpile = false; @@ -1373,7 +1383,6 @@ _.extend(PackageSource.prototype, { const anyLevelExcludes = [ /^tests\/$/, /^node_modules\/$/, - arch === "os" ? /^client\/$/ : /^server\/$/, ...sourceReadOptions.exclude ]; diff --git a/tools/tests/apps/modules/client/eager.js b/tools/tests/apps/modules/client/eager.js new file mode 100644 index 0000000000..f3e9aa9c6f --- /dev/null +++ b/tools/tests/apps/modules/client/eager.js @@ -0,0 +1 @@ +export const name = module.id; diff --git a/tools/tests/apps/modules/tests.js b/tools/tests/apps/modules/tests.js index 5feb891315..91447b64a6 100644 --- a/tools/tests/apps/modules/tests.js +++ b/tools/tests/apps/modules/tests.js @@ -5,6 +5,12 @@ import {Meteor as ImportedMeteor} from "meteor/meteor"; describe("app modules", () => { it("can be imported using absolute identifiers", () => { assert.strictEqual(require("/tests"), exports); + assert.strictEqual( + // Client modules should be importable by server modules, though not + // vice-versa. + require("/client/eager").name, + "/client/eager.js" + ); }); it("can have different file extensions", () => {