From 973ae5042e360ecf2f1aff6f23f9d972cd32f406 Mon Sep 17 00:00:00 2001 From: Kristian Dimitrov Date: Tue, 23 Jul 2019 13:55:59 +0300 Subject: [PATCH] fix: restore getEntryPathRegExp for backward compatibility with older webpack.config.js --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 74afd066..7effb6c3 100644 --- a/index.js +++ b/index.js @@ -60,6 +60,18 @@ exports.getAppPath = (platform, projectDir) => { } }; +/** + * For backward compatibility. This method is deprecated. Do not use it anymore. + * This method also has a bug of not escaping valid regex symbols in entry path. + * For module rules use: "include" instead of "test". + */ +exports.getEntryPathRegExp = (appFullPath, entryModule) => { + const entryModuleFullPath = path.join(appFullPath, entryModule); + // Windows paths contain `\`, so we need to convert each of the `\` to `\\`, so it will be correct inside RegExp + const escapedPath = entryModuleFullPath.replace(/\\/g, "\\\\"); + return new RegExp(escapedPath); +} + exports.getSourceMapFilename = (hiddenSourceMap, appFolderPath, outputPath) => { const appFolderRelativePath = path.join(path.relative(outputPath, appFolderPath)); let sourceMapFilename = "[file].map";