From d74260eb44c5ed6d0f7c4635b1b6c6316f9151c3 Mon Sep 17 00:00:00 2001 From: Druska Date: Mon, 12 Aug 2019 12:36:07 -0400 Subject: [PATCH] Fix watch not processing original files https://github.com/jlmakes/karma-rollup-preprocessor/issues/55 --- lib/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 168a10e..7c0b03d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -14,15 +14,16 @@ function createPreprocessor(preconfig, config, emitter, logger) { } return async function preprocess(original, file, done) { - const location = path.relative(config.basePath, file.path) + const originalPath = file.originalPath + const location = path.relative(config.basePath, originalPath) try { const options = Object.assign({}, config.rollupPreprocessor, preconfig.options, { - input: file.path, - cache: cache.get(file.path), + input: originalPath, + cache: cache.get(originalPath), }) const bundle = await rollup.rollup(options) - cache.set(file.path, bundle.cache) + cache.set(originalPath, bundle.cache) if (watcher) { const [entry, ...dependencies] = bundle.watchFiles @@ -43,7 +44,7 @@ function createPreprocessor(preconfig, config, emitter, logger) { * for processors that have alternate source file extensions, * make sure to use the output rollup file name */ - const parsedPath = path.parse(file.path) + const parsedPath = path.parse(originalPath) file.path = `${parsedPath.dir}/${result.fileName}` const processed =