From 4cab7fc8a8ec41ebe81f918c0818d210c5e71108 Mon Sep 17 00:00:00 2001 From: "Mohamed H. Hegazy" Date: Sat, 30 Sep 2017 03:09:23 +0200 Subject: [PATCH] fix windows paths to work with rollup repalce plugin --- scripts/rollup/build.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 4204926aadd07..39ee18089fe46 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -299,6 +299,17 @@ function getCommonJsConfig(bundleType) { } } +// for use with rollup repalce plugin: +// windows paths breaks the string if we dosn't replace all "\" with "/" +// it only make effect on windows paths +function normalizeWindowsPathsInReplaceModules(mapToReplace) { + const newMap = {}; + Object.keys(mapToReplace).forEach(key => { + newMap[key] = mapToReplace[key].replace(/\\/g, '/'); + }); + return newMap; +} + function getPlugins( entry, babelOpts, @@ -326,7 +337,7 @@ function getPlugins( // We have to do this check because Rollup breaks on empty object. // TODO: file an issue with rollup-plugin-replace. if (Object.keys(replaceModules).length > 0) { - plugins.unshift(replace(replaceModules)); + plugins.unshift(replace(normalizeWindowsPathsInReplaceModules(replaceModules))); } const headerSanityCheck = getHeaderSanityCheck(bundleType, hasteName);