From eafd20d4877497f6c504a37611c2430e38446a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Sat, 3 Apr 2021 08:10:48 -0400 Subject: [PATCH] fix: add all babel config files to file dependency (#887) --- src/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index c468f42b..07eec2a1 100644 --- a/src/index.js +++ b/src/index.js @@ -209,10 +209,19 @@ async function loader(source, inputSourceMap, overrides) { result = await transform(source, options); } - // TODO: Babel should really provide the full list of config files that - // were used so that this can also handle files loaded with 'extends'. - if (typeof config.babelrc === "string") { - this.addDependency(config.babelrc); + // Availabe since Babel 7.12 + // https://github.com/babel/babel/pull/11907 + if (config.files) { + config.files.forEach(configFile => this.addDependency(configFile)); + } else { + // .babelrc.json + if (typeof config.babelrc === "string") { + this.addDependency(config.babelrc); + } + // babel.config.js + if (config.config) { + this.addDependency(config.config); + } } if (result) {