From 20da99c219bda314fb1074697dd5320c3c9bcd5b Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 11 Jan 2019 16:52:23 -0500 Subject: [PATCH] Do not treat client and server directories specially in packages. (#10414) Fixes #10393. Bumping compiler.BUILT_BY and LINKER_CACHE_SALT because PR #10414 changes the behavior of the build system in a subtle way that does not automatically trigger recompilation. --- History.md | 8 ++++++++ tools/isobuild/compiler-plugin.js | 2 +- tools/isobuild/compiler.js | 2 +- tools/isobuild/package-source.js | 14 +++++++++++--- .../packages/modules-test-package/client.js | 7 ++++++- .../packages/modules-test-package/client/where.js | 1 + .../packages/modules-test-package/common.js | 7 +++++++ .../packages/modules-test-package/server.js | 1 + .../packages/modules-test-package/server/where.js | 2 ++ 9 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 tools/tests/apps/modules/packages/modules-test-package/client/where.js create mode 100644 tools/tests/apps/modules/packages/modules-test-package/server/where.js diff --git a/History.md b/History.md index db684004b9..323c469252 100644 --- a/History.md +++ b/History.md @@ -8,6 +8,14 @@ N/A ### Changes +* In Meteor packages, `client/` and `server/` directories no longer have + any special meaning. In application code, `client/` directories are + ignored during the server build, and `server/` directories are ignored + during the client build, as before. This special behavior previously + applied to packages as well, but has now been removed. + [Issue #10393](https://github.com/meteor/meteor/issues/10393) + [PR #10414](https://github.com/meteor/meteor/pull/10414) + ## v1.8.0.2, 2019-01-07 ### Breaking changes diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index b3ae075895..7ac64cbf5c 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -65,7 +65,7 @@ const hasOwn = Object.prototype.hasOwnProperty; // Cache the (slightly post-processed) results of linker.fullLink. const CACHE_SIZE = process.env.METEOR_LINKER_CACHE_SIZE || 1024*1024*100; const CACHE_DEBUG = !! process.env.METEOR_TEST_PRINT_LINKER_CACHE_DEBUG; -const LINKER_CACHE_SALT = 21; // Increment this number to force relinking. +const LINKER_CACHE_SALT = 22; // Increment this number to force relinking. const LINKER_CACHE = new LRU({ max: CACHE_SIZE, // Cache is measured in bytes. We don't care about servePath. diff --git a/tools/isobuild/compiler.js b/tools/isobuild/compiler.js index 0d1daecceb..2bc4e5c832 100644 --- a/tools/isobuild/compiler.js +++ b/tools/isobuild/compiler.js @@ -34,7 +34,7 @@ var compiler = exports; // dependencies. (At least for now, packages only used in target creation (eg // minifiers) don't require you to update BUILT_BY, though you will need to quit // and rerun "meteor run".) -compiler.BUILT_BY = 'meteor/31'; +compiler.BUILT_BY = 'meteor/32'; // This is a list of all possible architectures that a build can target. (Client // is expanded into 'web.browser' and 'web.cordova') diff --git a/tools/isobuild/package-source.js b/tools/isobuild/package-source.js index 2ebdb83dc4..79e3e6eb41 100644 --- a/tools/isobuild/package-source.js +++ b/tools/isobuild/package-source.js @@ -1157,10 +1157,18 @@ _.extend(PackageSource.prototype, { } } + if (isApp) { + // In the app, server/ directories are ignored by client builds, and + // client/ directories are ignored by server builds. In packages, + // these directories should not matter (#10393). + anyLevelExcludes.push( + archinfo.matches(arch, "os") + ? /^client\/$/ + : /^server\/$/ + ); + } + anyLevelExcludes.push( - archinfo.matches(arch, "os") - ? /^client\/$/ - : /^server\/$/, ...sourceReadOptions.exclude, ); diff --git a/tools/tests/apps/modules/packages/modules-test-package/client.js b/tools/tests/apps/modules/packages/modules-test-package/client.js index 03e4e68991..54af6efe9b 100644 --- a/tools/tests/apps/modules/packages/modules-test-package/client.js +++ b/tools/tests/apps/modules/packages/modules-test-package/client.js @@ -1,9 +1,14 @@ import assert from "assert"; -import {checkPackageVars} from "./common"; +import { + checkWhere, + checkPackageVars, +} from "./common"; export const where = "client"; export * from "./common"; +checkWhere(where); + var style = require("./css/imported.css"); if (! style) { require("./css/not-imported.css"); diff --git a/tools/tests/apps/modules/packages/modules-test-package/client/where.js b/tools/tests/apps/modules/packages/modules-test-package/client/where.js new file mode 100644 index 0000000000..52de0b33a0 --- /dev/null +++ b/tools/tests/apps/modules/packages/modules-test-package/client/where.js @@ -0,0 +1 @@ +export * from "../server/where.js"; diff --git a/tools/tests/apps/modules/packages/modules-test-package/common.js b/tools/tests/apps/modules/packages/modules-test-package/common.js index a64688f120..b9037f6771 100644 --- a/tools/tests/apps/modules/packages/modules-test-package/common.js +++ b/tools/tests/apps/modules/packages/modules-test-package/common.js @@ -5,6 +5,13 @@ export const ModulesTestPackage = "loaded"; import { parse } from "acorn"; assert.strictEqual(typeof parse, "function"); +export function checkWhere(where) { + const { where: serverWhere } = require("./server/where.js"); + const { where: clientWhere } = require("./client/where.js"); + assert.strictEqual(serverWhere, where); + assert.strictEqual(clientWhere, where); +} + export function checkPackageVars() { if (Meteor.isClient) { assert.strictEqual(ClientPackageVar, "client"); diff --git a/tools/tests/apps/modules/packages/modules-test-package/server.js b/tools/tests/apps/modules/packages/modules-test-package/server.js index fb8294f778..d2b5b833a9 100644 --- a/tools/tests/apps/modules/packages/modules-test-package/server.js +++ b/tools/tests/apps/modules/packages/modules-test-package/server.js @@ -6,6 +6,7 @@ assert.strictEqual(common.ModulesTestPackage, "loaded"); export { ModulesTestPackage } from "./common"; export const where = "server"; +common.checkWhere(where); ServerPackageVar = "server"; common.checkPackageVars(); diff --git a/tools/tests/apps/modules/packages/modules-test-package/server/where.js b/tools/tests/apps/modules/packages/modules-test-package/server/where.js new file mode 100644 index 0000000000..aac3fa79df --- /dev/null +++ b/tools/tests/apps/modules/packages/modules-test-package/server/where.js @@ -0,0 +1,2 @@ +import { Meteor } from "meteor/meteor"; +export const where = Meteor.isServer ? "server" : "client";