Skip to content

Commit

Permalink
fix windows paths to work with rollup repalce plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mhhegazy committed Sep 30, 2017
1 parent 3522d76 commit 4cab7fc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4cab7fc

Please sign in to comment.