From de3fef17cafe4e2e7c572af2a2fe9499edf042c0 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 22 Jun 2018 11:16:59 -0400 Subject: [PATCH] Stop eagerly forcing compilation of lazy CssOutputResources. This should be a better fix for the problem I tried to fix with 479e505d7121a9ea4f77512e175246045adfdf45. If we're going to be using compileOneFileLater by default, that's what we should be testing in the compiler plugins self-tests. --- packages/caching-compiler/caching-compiler.js | 3 +-- .../multi-file-caching-compiler.js | 3 +-- tools/isobuild/compiler-plugin.js | 15 +++++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/caching-compiler/caching-compiler.js b/packages/caching-compiler/caching-compiler.js index f8198b360c..308a7a83c8 100644 --- a/packages/caching-compiler/caching-compiler.js +++ b/packages/caching-compiler/caching-compiler.js @@ -316,8 +316,7 @@ CachingCompiler = class CachingCompiler extends CachingCompilerBase { }; if (this.compileOneFileLater && - inputFile.supportsLazyCompilation && - ! this._cacheDebugEnabled) { + inputFile.supportsLazyCompilation) { await this.compileOneFileLater(inputFile, getResult); } else { const result = await getResult(); diff --git a/packages/caching-compiler/multi-file-caching-compiler.js b/packages/caching-compiler/multi-file-caching-compiler.js index 91b03ca386..4b4ceaf72e 100644 --- a/packages/caching-compiler/multi-file-caching-compiler.js +++ b/packages/caching-compiler/multi-file-caching-compiler.js @@ -148,8 +148,7 @@ extends CachingCompilerBase { }; if (this.compileOneFileLater && - inputFile.supportsLazyCompilation && - ! this._cacheDebugEnabled) { + inputFile.supportsLazyCompilation) { if (! this.isRoot(inputFile)) { // If this inputFile is definitely not a root, then it must be // lazy, and this is our last chance to mark it as such, so that diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index 8f1ada97a8..aeaff516fa 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -722,7 +722,7 @@ class ResourceSlot { }); if (this.packageSourceBatch.useMeteorInstall && - options.lazy) { + cssResource.lazy) { // If the current packageSourceBatch supports modules, and this CSS // file is lazy, add it as a lazy JS module instead of adding it // unconditionally as a CSS resource, so that it can be imported @@ -778,12 +778,15 @@ class ResourceSlot { // stub, so setting .implicit marks the resource as disposable. }).implicit = true; - // If there was an error processing this file, cssResource.data will - // not be a Buffer, and accessing cssResource.data here should cause - // the error to be reported via inputFile.error. - if (Buffer.isBuffer(cssResource.data)) { - this.outputResources.push(cssResource); + if (! cssResource.lazy && + ! Buffer.isBuffer(cssResource.data)) { + // If there was an error processing this file, cssResource.data + // will not be a Buffer, and accessing cssResource.data here + // should cause the error to be reported via inputFile.error. + return; } + + this.outputResources.push(cssResource); } }