diff --git a/src/Bundler/Pipeline/ContentPipeline.php b/src/Bundler/Pipeline/ContentPipeline.php index 11961dc..4cfc525 100644 --- a/src/Bundler/Pipeline/ContentPipeline.php +++ b/src/Bundler/Pipeline/ContentPipeline.php @@ -209,8 +209,8 @@ private function checkIfChanged(File $output_file, DependencyNodeInterface $depe $files = []; // Collect all inline dependencies, since if any of those changed we need to recompile. - $walker = new TreeWalker(function (DependencyNodeInterface $d) use (&$files) { - if (!$d->isInlineDependency()) { + $walker = new TreeWalker(function (DependencyNodeInterface $d) use ($dependency, &$files) { + if ($d !== $dependency && !$d->isInlineDependency()) { return false; } diff --git a/test/Bundler/Pipeline/ContentPipelineTest.php b/test/Bundler/Pipeline/ContentPipelineTest.php index 795d0c9..d8b89d9 100644 --- a/test/Bundler/Pipeline/ContentPipelineTest.php +++ b/test/Bundler/Pipeline/ContentPipelineTest.php @@ -18,6 +18,7 @@ use Hostnet\Component\Resolver\Import\RootFile; use Hostnet\Component\Resolver\Module; use Hostnet\Component\Resolver\Report\NullReporter; +use Hostnet\Component\Resolver\Report\ReporterInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Psr\Log\NullLogger; @@ -156,6 +157,54 @@ public function testPushDevAlreadyUpToDate() ); } + public function testPushDevInlineChanged() + { + $reporter = new class implements ReporterInterface + { + public $files; + + public function reportOutputFile(File $file): void + { + } + public function reportFileDependencies(File $file, array $dependencies): void + { + } + public function reportFileState(File $file, string $state): void + { + $this->files[$file->path] = $state; + } + public function reportFileContent(File $file, string $content): void + { + } + }; + + $this->config->isDev()->willReturn(true); + $this->config->getSourceRoot()->willReturn('fixtures'); + $this->config->getCacheDir()->willReturn(__DIR__ . '/cache/new'); + $this->config->getReporter()->willReturn($reporter); + + $input_file = new RootFile(new Module('fixtures/bar.foo', 'fixtures/bar.foo')); + $target_file = new File('fixtures/output.foo'); + $reader = new FileReader(__DIR__); + + $file = tempnam(__DIR__, 'asset'); + + try { + $input_file->addChild($dep = new Dependency(new File($file), true)); + + $this->content_pipeline->addProcessor(new IdentityProcessor('foo')); + $output = $this->content_pipeline->push([$input_file, $dep], $reader, $target_file); + + self::assertEquals("foobar\n", $output); + self::assertEquals([ + 'fixtures/bar.foo' => ReporterInterface::STATE_BUILT, + $file => ReporterInterface::STATE_INLINE, + ], $reporter->files); + } finally { + unlink($file); + } + } + /** * @expectedException \LogicException * @expectedExceptionMessage Failed to compile resource "input.js".