From f1441e4a84d58d7baf774f3b800df7eb91f65950 Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Mon, 5 Aug 2024 22:16:50 +0200 Subject: [PATCH] Support watching for source changes with Rollup 4 Plugins have to call `addWatchFile` now. See https://github.com/2wce/rollup-plugin-sourcemaps2/issues/59. --- src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7eb805f..a2f01e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import fs from 'fs'; +import { resolve as resolvePath } from 'path'; import { promisify } from 'util'; import { Plugin, ExistingRawSourceMap } from 'rollup'; import pluginUtils, { CreateFilter } from '@rollup/pluginutils'; @@ -32,7 +33,9 @@ export default function sourcemaps({ return null; } - let code: string; + // Allow the original file to be watched + this.addWatchFile(resolvePath(id)); + try { code = (await promisifiedReadFile(id)).toString(); } catch {